Loading lib_com/ivas_prot_fx.h +1 −1 Original line number Diff line number Diff line Loading @@ -1868,7 +1868,7 @@ void ivas_wb_tbe_dec_fx( Word16 *synth, /* o : WB synthesis/final synthesis */ Word16 *Q_synth ); void ivas_GenShapedWBExcitation_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*/ Loading lib_com/lsf_tools_fx.c +147 −0 Original line number Diff line number Diff line Loading @@ -631,6 +631,153 @@ Word16 lpc2lsp_fx( return ( 1 ); } #ifdef FIX_ISSUE_1165 /*===================================================================*/ /* FUNCTION : lpc2lsp_ivas_fx () */ /*-------------------------------------------------------------------*/ /* PURPOSE : Convert LPC coefficients to LSP coefficients */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* */ /* _ (Word32 []) a : LPC coefficients, Q27 */ /* _ (Word16 []) old_freq: Previous frame LSP coefficients, Q15 */ /* _ (Word16 []) order: LPC order */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word16 []) freq: LSP coefficients, Q15 */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ (Word16) flag: 1 means all 10 LSPs are found, 0 otherwise */ /*===================================================================*/ /*NOTE: This function was created to avoid a crash that happens in the*/ /* first for loop of this function while performing L_shl on a in*/ /* lpc2lsp_fx, this computation assigns value to Lacc, which is */ /* kept in Q26 here to avoid L_shl when a has saturated value. */ Word16 lpc2lsp_ivas_fx( Word32 *a, Word16 *freq, Word16 *old_freq, Word16 order ) { Word16 i; Word16 rt, low, high, prev_rt, rc; Word32 p[11], q[11]; /* Q26 */ Word32 Ltemp, v_low; Word32 Lacc; Word16 tfreq[21]; /* First construct the P,Q polynomial */ /* p[0] = q[0] = 1 */ /* p[i] = -lpcCoeff[i] - lpcCoeff[11-i] - p[i-1] ( 1<=i<=5)*/ /* q[i] = -lpcCoeff[i] + lpcCoeff[11-i] + q[i-1] ( 1<=i<=5)*/ Ltemp = L_deposit_h( 0x400 ); /* Ltemp is 1.0 in Q26 */ p[0] = Ltemp; move32(); q[0] = Ltemp; move32(); FOR( i = 1; i < ( order / 2 ) + 1; i++ ) { Lacc = L_shr( a[order - i], 1 ); move32(); /* Q26 */ Lacc = L_sub( Lacc, L_shr( a[i - 1], 1 ) ); /* Lacc=-lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ q[i] = L_add( ( Lacc ), q[i - 1] ); move32(); /* Q26 */ Lacc = L_add( Lacc, a[i - 1] ); /* Lacc=lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ p[i] = L_sub( L_negate( Lacc ), p[i - 1] ); move32(); /* Q26 */ } /* Search roots of the P and Q polynomials */ v_low = polynomial_eval_fx( 0, p, order ); /* Q25 */ move16(); move16(); move16(); move16(); low = 0; high = 8; prev_rt = 0; rc = 0; /* root counter */ FOR( i = 0; i < 32; i++ ) { rt = root_search_fx( low, high, &v_low, p, order ); low = high; move16(); high = add( high, 8 ); IF( GE_16( rt, prev_rt ) ) { tfreq[rc] = rt; move16(); rc = add( rc, 2 ); } prev_rt = add( rt, 6 ); } /* End for P roots */ tfreq[rc] = 0x3f80; move16(); /* Set a high enough value as fake root for Q search */ IF( LT_16( rc, order ) ) { /* lost P root */ /* copy from previous LSP and return */ FOR( i = 0; i < order; i++ ) { move16(); freq[i] = old_freq[i]; } return ( 0 ); } ELSE { /* Search for Q roots between P roots */ v_low = L_deposit_h( 0x800 ); /* Init a positive value for v_low */ rc = 1; move16(); FOR( i = 0; i < order / 2; i++ ) { low = shr( tfreq[rc - 1], 6 ); high = add( shr( tfreq[rc + 1], 6 ), 1 ); rt = root_search_fx( low, high, &v_low, q, order ); IF( rt < 0 ) { /* No Q root in this interval */ /* copy from previous LSP and return */ FOR( i = 0; i < order; i++ ) { move16(); freq[i] = old_freq[i]; } return ( 0 ); } ELSE { move16(); tfreq[rc] = rt; rc = add( rc, 2 ); } /* end else, find Q root */ } /* end for */ } /* end else */ FOR( i = 0; i < order; i++ ) { freq[i] = tfreq[i]; move16(); } return ( 1 ); } #endif /*===================================================================*/ /* FUNCTION : lsp2lpc_fx () */ /*-------------------------------------------------------------------*/ Loading lib_com/options.h +3 −0 Original line number Diff line number Diff line Loading @@ -120,4 +120,7 @@ #define FIX_ISSUE_1167 /* Ittiam: Fix for Issue 1167: Encoder crash for OSBA ISM3SBA1 at 13.2 and 16.4 kbps in gauss_L2_ivas_fx() */ #define FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC /* FhG: Reduce workload of binaural rendering: replace 1./tmp & sqrt by Isqrt32 */ #define FIX_1113_OPT_DIRAC_BIN_REND /* FhG: Various optimizations to ivas_dirac_dec_binaual_functions.c */ #define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */ #define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/ #define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */ #endif lib_com/prot_fx.h +8 −17 Original line number Diff line number Diff line Loading @@ -808,6 +808,14 @@ Word16 lpc2lsp_fx( Word16 *old_freq, Word16 order ); #ifdef FIX_ISSUE_1165 Word16 lpc2lsp_ivas_fx( Word32 *a, Word16 *freq, Word16 *old_freq, Word16 order ); #endif void lsp2lpc_fx( Word16 *a, Word16 *freq, Loading Loading @@ -2914,23 +2922,6 @@ void GenShapedWBExcitation_fx( const Word16 signal_type, const Word16 igf_flag ); void GenShapedWBExcitation_ivas_enc_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 *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 */ Loading lib_com/swb_tbe_com_fx.c +1 −303 Original line number Diff line number Diff line Loading @@ -1355,7 +1355,7 @@ void flip_spectrum_and_decimby4_fx( /* CALLED FROM : */ /*==========================================================================*/ void ivas_GenShapedWBExcitation_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*/ Loading Loading @@ -1950,308 +1950,6 @@ void GenShapedWBExcitation_fx( return; } void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q(Q_bwe_exc) */ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q(Q_bwe_exc) */ Word32 *mem_csfilt, /* i/o : memory Q(Q_bwe_exc+16) */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q(Q_bwe_exc) */ 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 *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 */ const Word16 voice_factors[], /* i : voicing factor Q15 */ const Word16 uv_flag, /* i : unvoiced flag */ const Word16 igf_flag ) { Word16 i, j, k; Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; Word16 lpc_whtn[LPC_WHTN_ORDER_WB + 1]; Word16 R_h[LPC_WHTN_ORDER_WB + 2], R_l[LPC_WHTN_ORDER_WB + 2]; Word16 Q_R; Word16 excTmp[L_FRAME16k]; Word16 excTmp2[L_FRAME16k / 4]; Word16 excTmp2_frac[L_FRAME16k / 4]; Word16 exc4k[L_FRAME16k / 4]; Word16 exc4k_frac[L_FRAME16k / 4]; Word32 exc4k_32[L_FRAME16k / 4]; Word32 pow1, pow22; Word16 scale; Word32 excNoisyEnv[L_FRAME16k / 4]; Word16 csfilt_num2[1] = { 1638 }; /* Q15*/ Word16 neg_csfilt_den2[2] = { -32768, 31457 }; /* Q15 */ Word32 L_tmp, Ltemp1, Ltemp2; Word16 temp1, temp2, exp; Word32 Lmax; Word16 max_val, n1, n2, sc; Word32 LepsP[LPC_WHTN_ORDER_WB + 1]; Word16 tmp_vfac; Word16 avg_voice_fac; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif move16(); move16(); move16(); /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); FOR( i = 1; i < NB_SUBFR; i++ ) { L_tmp = L_mac( L_tmp, voice_factors[i], 8192 /*0.25 in Q15 */ ); } avg_voice_fac = round_fx( L_tmp ); test(); test(); test(); test(); IF( igf_flag != 0 && ( EQ_16( coder_type, VOICED ) || GT_16( avg_voice_fac, 11469 /* 0.35 in Q15 */ ) ) ) /*Q15 -> 0.35f*/ { csfilt_num2[0] = 6554; move16(); /*Q15 -> 0.2f*/ neg_csfilt_den2[1] = 26214; move16(); /*Q15 -> 0.8f*/ } ELSE IF( igf_flag != 0 && ( EQ_16( coder_type, UNVOICED ) || LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) /*Q15 -> 0.2f*/ { csfilt_num2[0] = 328; move16(); /*Q15 -> 0.01f*/ neg_csfilt_den2[1] = 32440; move16(); /*Q15 -> 0.99f*/ } set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER_WB ); Decimate_allpass_steep_fx( bwe_exc_extended, mem_genSHBexc_filt_down1, L_FRAME32k, excTmp ); flip_spectrum_and_decimby4_fx( excTmp, exc4k, L_FRAME16k, mem_genSHBexc_filt_down2, mem_genSHBexc_filt_down3, 0 ); IF( uv_flag ) { create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); IF( LT_16( Q_bwe_exc, 5 ) ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ move16(); } } } ELSE { autocorr_fx( exc4k, LPC_WHTN_ORDER_WB + 1, R_h, R_l, &Q_R, L_FRAME16k / 4, win_flatten_4k_fx, 0, 1 ); /* Ensure R[0] isn't zero when entering Levinson Durbin */ R_l[0] = s_max( R_l[0], 1 ); move16(); FOR( i = 1; i <= LPC_WHTN_ORDER_WB; i++ ) { L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } E_LPC_lev_dur( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER_WB, NULL ); Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER_WB + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, LPC_WHTN_ORDER_WB, 0, 3 ); /* Ensure pow1 is greater than zero when computing normalization */ max_val = 0; move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { excTmp2[i] = abs_s( exc4kWhtnd[i] ); move16(); /* Q_bwe_exc */ max_val = s_max( max_val, excTmp2[i] ); move16(); } IF( max_val == 0 ) { pow1 = 1; move16(); n1 = 0; move16(); } ELSE { n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); #else excTmp2_frac[i] = shl( excTmp2[i], n1 ); #endif move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); #else excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); #endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ } create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4k_32[i] = Mpy_32_16_1( excNoisyEnv[i], exc4k[i] ); move32(); /* Q_bwe_exc+6 */ Lmax = L_max( Lmax, L_abs( exc4k_32[i] ) ); } IF( Lmax == 0 ) { pow22 = 1; move16(); n2 = 0; move16(); set16_fx( exc4k_frac, 0, L_FRAME16k / 4 ); } ELSE { n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif move16(); } n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); pow22 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } test(); test(); IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #else scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ #endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif move16(); } } ELSE { sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ k = 0; move16(); FOR( i = 0; i < 4; i++ ) { test(); IF( igf_flag != 0 && EQ_16( coder_type, VOICED ) ) { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ #ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); #else BASOP_SATURATE_WARNING_OFF_EVS tmp_vfac = shl( voice_factors[i], 1 ); BASOP_SATURATE_WARNING_ON_EVS #endif } ELSE { tmp_vfac = voice_factors[i]; move16(); } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); #ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ #endif L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ #endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ #else L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif move16(); k = add( k, 1 ); } } } } syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); return; } /*-------------------------------------------------------------------* * GenWBSynth() * Loading Loading
lib_com/ivas_prot_fx.h +1 −1 Original line number Diff line number Diff line Loading @@ -1868,7 +1868,7 @@ void ivas_wb_tbe_dec_fx( Word16 *synth, /* o : WB synthesis/final synthesis */ Word16 *Q_synth ); void ivas_GenShapedWBExcitation_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*/ Loading
lib_com/lsf_tools_fx.c +147 −0 Original line number Diff line number Diff line Loading @@ -631,6 +631,153 @@ Word16 lpc2lsp_fx( return ( 1 ); } #ifdef FIX_ISSUE_1165 /*===================================================================*/ /* FUNCTION : lpc2lsp_ivas_fx () */ /*-------------------------------------------------------------------*/ /* PURPOSE : Convert LPC coefficients to LSP coefficients */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* */ /* _ (Word32 []) a : LPC coefficients, Q27 */ /* _ (Word16 []) old_freq: Previous frame LSP coefficients, Q15 */ /* _ (Word16 []) order: LPC order */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word16 []) freq: LSP coefficients, Q15 */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ (Word16) flag: 1 means all 10 LSPs are found, 0 otherwise */ /*===================================================================*/ /*NOTE: This function was created to avoid a crash that happens in the*/ /* first for loop of this function while performing L_shl on a in*/ /* lpc2lsp_fx, this computation assigns value to Lacc, which is */ /* kept in Q26 here to avoid L_shl when a has saturated value. */ Word16 lpc2lsp_ivas_fx( Word32 *a, Word16 *freq, Word16 *old_freq, Word16 order ) { Word16 i; Word16 rt, low, high, prev_rt, rc; Word32 p[11], q[11]; /* Q26 */ Word32 Ltemp, v_low; Word32 Lacc; Word16 tfreq[21]; /* First construct the P,Q polynomial */ /* p[0] = q[0] = 1 */ /* p[i] = -lpcCoeff[i] - lpcCoeff[11-i] - p[i-1] ( 1<=i<=5)*/ /* q[i] = -lpcCoeff[i] + lpcCoeff[11-i] + q[i-1] ( 1<=i<=5)*/ Ltemp = L_deposit_h( 0x400 ); /* Ltemp is 1.0 in Q26 */ p[0] = Ltemp; move32(); q[0] = Ltemp; move32(); FOR( i = 1; i < ( order / 2 ) + 1; i++ ) { Lacc = L_shr( a[order - i], 1 ); move32(); /* Q26 */ Lacc = L_sub( Lacc, L_shr( a[i - 1], 1 ) ); /* Lacc=-lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ q[i] = L_add( ( Lacc ), q[i - 1] ); move32(); /* Q26 */ Lacc = L_add( Lacc, a[i - 1] ); /* Lacc=lpcCoeff[i-1] + lpcCoeff[order-i]//Q26 */ p[i] = L_sub( L_negate( Lacc ), p[i - 1] ); move32(); /* Q26 */ } /* Search roots of the P and Q polynomials */ v_low = polynomial_eval_fx( 0, p, order ); /* Q25 */ move16(); move16(); move16(); move16(); low = 0; high = 8; prev_rt = 0; rc = 0; /* root counter */ FOR( i = 0; i < 32; i++ ) { rt = root_search_fx( low, high, &v_low, p, order ); low = high; move16(); high = add( high, 8 ); IF( GE_16( rt, prev_rt ) ) { tfreq[rc] = rt; move16(); rc = add( rc, 2 ); } prev_rt = add( rt, 6 ); } /* End for P roots */ tfreq[rc] = 0x3f80; move16(); /* Set a high enough value as fake root for Q search */ IF( LT_16( rc, order ) ) { /* lost P root */ /* copy from previous LSP and return */ FOR( i = 0; i < order; i++ ) { move16(); freq[i] = old_freq[i]; } return ( 0 ); } ELSE { /* Search for Q roots between P roots */ v_low = L_deposit_h( 0x800 ); /* Init a positive value for v_low */ rc = 1; move16(); FOR( i = 0; i < order / 2; i++ ) { low = shr( tfreq[rc - 1], 6 ); high = add( shr( tfreq[rc + 1], 6 ), 1 ); rt = root_search_fx( low, high, &v_low, q, order ); IF( rt < 0 ) { /* No Q root in this interval */ /* copy from previous LSP and return */ FOR( i = 0; i < order; i++ ) { move16(); freq[i] = old_freq[i]; } return ( 0 ); } ELSE { move16(); tfreq[rc] = rt; rc = add( rc, 2 ); } /* end else, find Q root */ } /* end for */ } /* end else */ FOR( i = 0; i < order; i++ ) { freq[i] = tfreq[i]; move16(); } return ( 1 ); } #endif /*===================================================================*/ /* FUNCTION : lsp2lpc_fx () */ /*-------------------------------------------------------------------*/ Loading
lib_com/options.h +3 −0 Original line number Diff line number Diff line Loading @@ -120,4 +120,7 @@ #define FIX_ISSUE_1167 /* Ittiam: Fix for Issue 1167: Encoder crash for OSBA ISM3SBA1 at 13.2 and 16.4 kbps in gauss_L2_ivas_fx() */ #define FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC /* FhG: Reduce workload of binaural rendering: replace 1./tmp & sqrt by Isqrt32 */ #define FIX_1113_OPT_DIRAC_BIN_REND /* FhG: Various optimizations to ivas_dirac_dec_binaual_functions.c */ #define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */ #define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/ #define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */ #endif
lib_com/prot_fx.h +8 −17 Original line number Diff line number Diff line Loading @@ -808,6 +808,14 @@ Word16 lpc2lsp_fx( Word16 *old_freq, Word16 order ); #ifdef FIX_ISSUE_1165 Word16 lpc2lsp_ivas_fx( Word32 *a, Word16 *freq, Word16 *old_freq, Word16 order ); #endif void lsp2lpc_fx( Word16 *a, Word16 *freq, Loading Loading @@ -2914,23 +2922,6 @@ void GenShapedWBExcitation_fx( const Word16 signal_type, const Word16 igf_flag ); void GenShapedWBExcitation_ivas_enc_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 *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 */ Loading
lib_com/swb_tbe_com_fx.c +1 −303 Original line number Diff line number Diff line Loading @@ -1355,7 +1355,7 @@ void flip_spectrum_and_decimby4_fx( /* CALLED FROM : */ /*==========================================================================*/ void ivas_GenShapedWBExcitation_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*/ Loading Loading @@ -1950,308 +1950,6 @@ void GenShapedWBExcitation_fx( return; } void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q(Q_bwe_exc) */ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q(Q_bwe_exc) */ Word32 *mem_csfilt, /* i/o : memory Q(Q_bwe_exc+16) */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q(Q_bwe_exc) */ 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 *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 */ const Word16 voice_factors[], /* i : voicing factor Q15 */ const Word16 uv_flag, /* i : unvoiced flag */ const Word16 igf_flag ) { Word16 i, j, k; Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; Word16 lpc_whtn[LPC_WHTN_ORDER_WB + 1]; Word16 R_h[LPC_WHTN_ORDER_WB + 2], R_l[LPC_WHTN_ORDER_WB + 2]; Word16 Q_R; Word16 excTmp[L_FRAME16k]; Word16 excTmp2[L_FRAME16k / 4]; Word16 excTmp2_frac[L_FRAME16k / 4]; Word16 exc4k[L_FRAME16k / 4]; Word16 exc4k_frac[L_FRAME16k / 4]; Word32 exc4k_32[L_FRAME16k / 4]; Word32 pow1, pow22; Word16 scale; Word32 excNoisyEnv[L_FRAME16k / 4]; Word16 csfilt_num2[1] = { 1638 }; /* Q15*/ Word16 neg_csfilt_den2[2] = { -32768, 31457 }; /* Q15 */ Word32 L_tmp, Ltemp1, Ltemp2; Word16 temp1, temp2, exp; Word32 Lmax; Word16 max_val, n1, n2, sc; Word32 LepsP[LPC_WHTN_ORDER_WB + 1]; Word16 tmp_vfac; Word16 avg_voice_fac; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif move16(); move16(); move16(); /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); FOR( i = 1; i < NB_SUBFR; i++ ) { L_tmp = L_mac( L_tmp, voice_factors[i], 8192 /*0.25 in Q15 */ ); } avg_voice_fac = round_fx( L_tmp ); test(); test(); test(); test(); IF( igf_flag != 0 && ( EQ_16( coder_type, VOICED ) || GT_16( avg_voice_fac, 11469 /* 0.35 in Q15 */ ) ) ) /*Q15 -> 0.35f*/ { csfilt_num2[0] = 6554; move16(); /*Q15 -> 0.2f*/ neg_csfilt_den2[1] = 26214; move16(); /*Q15 -> 0.8f*/ } ELSE IF( igf_flag != 0 && ( EQ_16( coder_type, UNVOICED ) || LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) /*Q15 -> 0.2f*/ { csfilt_num2[0] = 328; move16(); /*Q15 -> 0.01f*/ neg_csfilt_den2[1] = 32440; move16(); /*Q15 -> 0.99f*/ } set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER_WB ); Decimate_allpass_steep_fx( bwe_exc_extended, mem_genSHBexc_filt_down1, L_FRAME32k, excTmp ); flip_spectrum_and_decimby4_fx( excTmp, exc4k, L_FRAME16k, mem_genSHBexc_filt_down2, mem_genSHBexc_filt_down3, 0 ); IF( uv_flag ) { create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); IF( LT_16( Q_bwe_exc, 5 ) ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ move16(); } } } ELSE { autocorr_fx( exc4k, LPC_WHTN_ORDER_WB + 1, R_h, R_l, &Q_R, L_FRAME16k / 4, win_flatten_4k_fx, 0, 1 ); /* Ensure R[0] isn't zero when entering Levinson Durbin */ R_l[0] = s_max( R_l[0], 1 ); move16(); FOR( i = 1; i <= LPC_WHTN_ORDER_WB; i++ ) { L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } E_LPC_lev_dur( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER_WB, NULL ); Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER_WB + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, LPC_WHTN_ORDER_WB, 0, 3 ); /* Ensure pow1 is greater than zero when computing normalization */ max_val = 0; move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { excTmp2[i] = abs_s( exc4kWhtnd[i] ); move16(); /* Q_bwe_exc */ max_val = s_max( max_val, excTmp2[i] ); move16(); } IF( max_val == 0 ) { pow1 = 1; move16(); n1 = 0; move16(); } ELSE { n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); #else excTmp2_frac[i] = shl( excTmp2[i], n1 ); #endif move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); #else excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); #endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ } create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4k_32[i] = Mpy_32_16_1( excNoisyEnv[i], exc4k[i] ); move32(); /* Q_bwe_exc+6 */ Lmax = L_max( Lmax, L_abs( exc4k_32[i] ) ); } IF( Lmax == 0 ) { pow22 = 1; move16(); n2 = 0; move16(); set16_fx( exc4k_frac, 0, L_FRAME16k / 4 ); } ELSE { n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif move16(); } n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); pow22 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } test(); test(); IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #else scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ #endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif move16(); } } ELSE { sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ k = 0; move16(); FOR( i = 0; i < 4; i++ ) { test(); IF( igf_flag != 0 && EQ_16( coder_type, VOICED ) ) { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ #ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); #else BASOP_SATURATE_WARNING_OFF_EVS tmp_vfac = shl( voice_factors[i], 1 ); BASOP_SATURATE_WARNING_ON_EVS #endif } ELSE { tmp_vfac = voice_factors[i]; move16(); } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); #ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ #endif L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ #endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ #else L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif move16(); k = add( k, 1 ); } } } } syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); return; } /*-------------------------------------------------------------------* * GenWBSynth() * Loading