Loading lib_com/cng_exc_fx.c +0 −283 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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 */ Loading Loading @@ -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) } Loading lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading lib_com/prot_fx.h +0 −61 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ ); Loading Loading @@ -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 */ Loading lib_com/swb_tbe_com_fx.c +0 −267 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_dec/acelp_core_dec_fx.c +0 −22 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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; Loading Loading
lib_com/cng_exc_fx.c +0 −283 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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 */ Loading Loading @@ -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) } Loading
lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading
lib_com/prot_fx.h +0 −61 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ ); Loading Loading @@ -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 */ Loading
lib_com/swb_tbe_com_fx.c +0 −267 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib_dec/acelp_core_dec_fx.c +0 −22 Original line number Diff line number Diff line Loading @@ -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 ); Loading @@ -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; Loading