diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 3329d33d1364ebda635a1f9ae8715f2f5198a82f..3a3acced08ee10dc5f78cd64ea45069673b28f17 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -401,10 +401,7 @@ - - - diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index b13f120be36ca98b0b9a3c67b1a3e373c407168a..d88992f20e8474180b3fffc31306a54fdbec3a8c 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -292,18 +292,9 @@ enc_all_c - - enc_all_c - - - enc_all_c - enc_all_c - - enc_all_c - enc_all_c diff --git a/lib_com/prot.h b/lib_com/prot.h index 4fe464c21ef78e6d99fd4efefab709fc08a8274a..9985ca978d25841413a23beec53528ddca5ac455 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2994,31 +2994,25 @@ void speech_music_classif( int16_t *high_lpn_flag, /* o : sp/mus LPN flag */ const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ ); -void ivas_find_wsp( - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr, /* i : length of subframe */ - const Word16 nb_subfr, /* i : number of subframes */ - const Word16 *A_fx, /* i : A(z) filter coefficients */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame */ - const Word16 tilt_fact, /* i : tilt factor */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory */ - const Word16 gamma, /* i : weighting factor */ - const Word16 L_look /* i : look-ahead */ -); -void find_wsp( - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_subfr, /* i : length of subframe */ - const int16_t nb_subfr, /* i : number of subframes */ - const float *A, /* i : A(z) filter coefficients */ - float *Aw, /* o : weighted A(z) filter coefficients */ - const float *speech, /* i : pointer to the denoised speech frame */ - const float tilt_fact, /* i : tilt factor */ - float *wsp, /* o : poitnter to the weighted speech frame */ - float *mem_wsp, /* i/o: W(Z) denominator memory */ - const float gamma, /* i : weighting factor */ - const int16_t L_look /* i : look-ahead */ +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*/ ); void gain_enc_amr_wb( diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2e475c41bf95d3ffb309813bad6faa10b521edff..3f06fcf450ee6bf4ee62f1bd2577018c6b7ac16b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11026,9 +11026,9 @@ Word16 getTcxonly_ivas_fx( void SetModeIndex_ivas_fx( Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word16 last_element_mode, /* i : last IVAS element mode */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ + 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( diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 71f03277a304616289d35959616ded29a5b11dd6..e2c81a8d11eb1f4bc9eb3d13c786d5a02d515829 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1968,8 +1968,8 @@ void CNG_enc_ivas_fx( { L_tmp1 = L_mult0( hTdCngEnc->CNG_att_fx, 26214 /* 1/20.0f in Q19 */ ); // Q26 (7 + 19) L_tmp1 = BASOP_Util_fPow( 1342177280 /*10 in Q27 */, 4, L_tmp1, 5, &exp ); - att = extract_h( L_shl( L_tmp1, exp ) ); // Q15 - v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */ + att = extract_h( L_shl( L_sub( L_tmp1, EPSILON_FX ), exp ) ); // Q15 // Subtracting by EPSILON_FX to avoid assertion when L_tmp1 value is 1073741824 and exp =1 + v_multc_fixed_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */ } ELSE IF( st_fx->bwidth != NB ) { diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index 2ed302c313375a73c2b079016af443a7e0cfa650..e09166f8a2f6ec504872d09f44fce67d336c3608 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -160,7 +160,8 @@ void init_coder_ace_plus_ivas_fx( st->currEnergyHF_fx = 0; move32(); - + st->currEnergyHF_e_fx = 0; + move16(); test(); /* Initialize LPC analysis/quantization */ IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) @@ -463,7 +464,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol hTcxEnc->exp_buf_speech_ltp = 0; move16(); } - set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ + set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */ st->exp_buf_wspeech_enc = 0; move16(); } diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index ba842b9ccd1542e261c12e381de5cab619dc2661..e5c3903a1789031ba9481c8f483235735965d117 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -219,6 +219,8 @@ void core_coder_mode_switch_ivas_fx( } st->currEnergyHF_fx = 0; move32(); + st->currEnergyHF_e_fx = 0; + move16(); Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 079a0e61fecb501ee45b34041450550cd1ed1188..01a866d549632e9f9d7582538fd568160c855c87 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -738,7 +738,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( } else if ( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - speech_fx = st->buf_speech_enc + +st->encoderPastSamples_enc; + speech_fx = st->buf_speech_enc + st->encoderPastSamples_enc; speech_ltp_fx = st->hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; } @@ -770,7 +770,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( Q_exp != 0 ) { Scale_sig( st->buf_speech_enc_pe, st->encoderPastSamples_enc + st->encoderLookahead_enc, sub( Q_exp, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); // *Q_new - Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new + st->exp_buf_speech_enc_pe = sub( Q15, Q_exp ); + move16(); + Scale_sig( &( st->mem_wsp_enc ), 1, Q_exp ); // *Q_new } IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) ) diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 923f7e2f23df518de4887d1e2921e5d59107f928..4196b9cb63f8ff3e0acf25bac42e2d71c9646549 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -58,9 +58,9 @@ *-------------------------------------------------------------------*/ /*! r: maximum energy ratio */ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */ +static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ + const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ + const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ ) { Word16 i, j, end, flag; @@ -74,9 +74,9 @@ static Word16 find_ener_decrease_fx( /* o : maximum dE2 = 0; move16(); - j = ind_deltaMax + 2; + j = add( ind_deltaMax, 2 ); /* Q0 */ move16(); - end = j + L_ENR; + end = add( j, L_ENR ); move16(); maxEnr = L_add( pt_enr_ssf[j], 0 ); j = add( j, 1 ); @@ -87,7 +87,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum test(); IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) ) { - maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/ + maxEnr = pt_enr_ssf[i]; /* Qx */ j = add( j, 1 ); } ELSE @@ -100,7 +100,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum minEnr = L_add( maxEnr, 0 ); FOR( i = j; i < end; i++ ) { - minEnr = L_min( minEnr, pt_enr_ssf[i] ); + minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */ } @@ -130,17 +130,17 @@ static Word16 find_ener_decrease_fx( /* o : maximum *-------------------------------------------------------------------*/ Word16 find_uv_ivas_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 */ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ - 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 */ - const Word16 last_core_orig, /* i : original last core */ + 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 q_hp_E ) @@ -170,9 +170,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ IF( hSC_VBR != NULL ) { - Last_Resort = hSC_VBR->Last_Resort; + Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ move16(); - vadnoise = hSC_VBR->vadnoise_fx; + vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */ move16(); } ELSE @@ -233,7 +233,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); } - dE1 = L_max( dE1, fac_32 ); + dE1 = L_max( dE1, fac_32 ); /* Q13 */ pt_enr_ssf++; pt_enr_ssf1++; @@ -243,14 +243,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ { IF( st_fx->idchan == 0 ) { - hStereoClassif->dE1_ch1_fx = dE1; + hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */ move32(); hStereoClassif->dE1_ch1_e = 31 - Q13; move16(); } ELSE { - hStereoClassif->dE1_ch2_fx = dE1; + hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */ move32(); hStereoClassif->dE1_ch2_e = 31 - Q13; move16(); @@ -259,7 +259,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ if ( dE1X != NULL ) { - *dE1X = dE1; + *dE1X = dE1; /* Q13 */ move32(); } @@ -270,17 +270,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef BASOP_NOGLOB - mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); -#else /* BASOP_NOGLOB */ + mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ +#else /* BASOP_NOGLOB */ mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] ); -#endif /* BASOP_NOGLOB */ - mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ +#endif /* BASOP_NOGLOB */ + mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ - Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 ); - Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 ); -#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP - mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ + 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 */ +#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP + mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ #else mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ #endif @@ -299,7 +299,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ move32(); nb_cond = 1; move16(); /* no additional condition for WB input */ - IF( EQ_16( st_fx->input_bwidth, NB ) ) + IF( st_fx->input_bwidth == NB ) { dE2_th = 21 << 10; move32(); @@ -324,9 +324,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ { IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) { - st_fx->old_ind_deltaMax = ind_deltaMax; + st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ move16(); - Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); + Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ } ELSE { @@ -345,8 +345,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ { IF( st_fx->old_ind_deltaMax >= 0 ) { - Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); - dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); + 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 ) ) { @@ -366,7 +366,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ tmp_offset_flag = 1; move16(); - IF( NE_16( st_fx->input_bwidth, NB ) ) + IF( st_fx->input_bwidth != NB ) { ee0_th = 154; /*2.4 in Q6 */ move16(); @@ -387,14 +387,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef BASOP_NOGLOB - 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], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ -#else /* BASOP_NOGLOB */ + 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], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ +#else /* BASOP_NOGLOB */ 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], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ { tmp_offset_flag = 0; move16(); @@ -419,14 +419,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ - IF( NE_16( st_fx->input_bwidth, NB ) ) + 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, 22938, st_fx->lp_noise_fx ); - if ( Last_Resort == 0 ) + 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, 21299, st_fx->lp_noise_fx ); + 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 ); } @@ -434,10 +434,10 @@ 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, 19661, st_fx->lp_noise_fx ); + 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 ); /* Q8 */ + 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 ) ) @@ -448,7 +448,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ /* 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 */ + if ( st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */ { mean_voi3_offset = 1638; /*0.05f Q15*/ move16(); @@ -458,7 +458,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ /* make decision whether frame is unvoiced */ coder_type = GENERIC; move16(); - IF( EQ_16( st_fx->input_bwidth, NB ) ) + IF( st_fx->input_bwidth == NB ) { test(); test(); @@ -470,18 +470,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - test(); #ifdef BASOP_NOGLOB - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282, 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 */ - ( LT_32( ee[0], 640 ) ) && ( 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 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + 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) */ + IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 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) */ #else if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ @@ -510,18 +509,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - test(); #ifdef BASOP_NOGLOB - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, 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 */ - ( LT_32( ee[0], 397 ) ) && ( 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 ) ) && ( 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 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + 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 ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), 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 */ + ( 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) */ #else if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */ /* ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ @@ -553,9 +551,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ 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] ) ); - dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); - dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); + 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(); @@ -566,11 +564,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */ + 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 ) ) ) @@ -578,7 +576,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ coder_type = VOICED; move16(); } - ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) + ELSE IF( st_fx->Opt_SC_VBR && st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) { test(); test(); @@ -587,11 +585,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */ + 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 /* 1.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ ( LT_16( dpit1, 5 << 6 ) ) && ( LT_16( dpit2, 5 << 6 ) ) && ( LT_16( dpit3, 5 << 6 ) ) ) @@ -605,14 +603,14 @@ Word16 find_uv_ivas_fx( /* o : coding typ /* 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 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 ); + 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 */ ); /* 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 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) ) + 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(); @@ -625,7 +623,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ * Channel-aware mode - set RF mode and total bitrate *-----------------------------------------------------------------*/ - st_fx->rf_mode = st_fx->Opt_RF_ON; + st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ move16(); IF( EQ_16( coder_type, GENERIC ) ) @@ -634,11 +632,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */ - ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */ - ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ + 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; @@ -683,7 +681,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) { - st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); + st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ move16(); } @@ -694,7 +692,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && ( GT_16( dE3, 5 << 8 ) || /* energy increases */ #ifdef BASOP_NOGLOB - ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ + ( GT_16( relE, -3328 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* normalized correlation is high */ #else ( GT_16( relE, -3328 ) && ( GT_16( add( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ #endif @@ -710,7 +708,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ 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; + st_fx->coder_type_raw = coder_type; /* Q0 */ move16(); return coder_type; diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 778e7b51a80dbabf5cc77cdc978df6cfbed03b26..5cd9db2797f8e7b8da3f9a2f3326c8056ac8967e 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -23,9 +23,9 @@ * energy is trailing off after a spike *-------------------------------------------------------------------*/ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10 */ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search */ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer */ +static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ + const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ + const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ ) { Word16 i, j, end, flag; @@ -34,6 +34,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum Word16 dE2, exp0, exp1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif dE2 = 0; @@ -52,7 +53,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum test(); IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) ) { - maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Q0*/ + maxEnr = L_add( pt_enr_ssf[i], 0 ); /*Qx*/ j = add( j, 1 ); } ELSE @@ -65,7 +66,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum minEnr = L_add( maxEnr, 0 ); FOR( i = j; i < end; i++ ) { - minEnr = L_min( minEnr, pt_enr_ssf[i] ); + minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */ } @@ -94,23 +95,23 @@ static Word16 find_ener_decrease_fx( /* o : maximum * Decision about coder type *-------------------------------------------------------------------*/ -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*/ +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*/ #ifdef IVAS_CODE Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ #endif - 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 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 */ + 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 */ + const Word16 last_core_orig /* i : original last core Q0*/ #ifdef IVAS_CODE , STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ @@ -135,6 +136,7 @@ Word16 find_uv_fx( /* o : coding type SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif Word16 Last_Resort; @@ -142,13 +144,17 @@ Word16 find_uv_fx( /* o : coding type IF( hSC_VBR != NULL ) { - Last_Resort = hSC_VBR->Last_Resort; + 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 ); @@ -163,7 +169,7 @@ Word16 find_uv_fx( /* o : coding type *-----------------------------------------------------------------*/ /* Find maximum energy per short subblocks */ - pt_speech = speech - SSF; + pt_speech = speech - SSF; /* Q_new */ pt_enr_ssf = enr_ssf + 2 * NB_SSF; FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) { @@ -203,7 +209,7 @@ Word16 find_uv_fx( /* o : coding type move16(); } - dE1 = L_max( dE1, fac_32 ); + dE1 = L_max( dE1, fac_32 ); /* Q13 */ pt_enr_ssf++; pt_enr_ssf1++; @@ -234,17 +240,17 @@ Word16 find_uv_fx( /* o : coding type /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef BASOP_NOGLOB - mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); -#else /* BASOP_NOGLOB */ + mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ +#else /* BASOP_NOGLOB */ mean_ee = L_add( L_add( st_fx->ee_old_fx, ee[0] ), ee[1] ); -#endif /* BASOP_NOGLOB */ - mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ +#endif /* BASOP_NOGLOB */ + 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 ); - Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 ); -#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP - mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ + 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 */ +#ifdef BASOP_NOGLOB // -dtx 12650 amrwb\Dtx3.INP + mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ #else mean_voi3 = mac_r( Ltmp0, st_fx->voicing_fx[2], 10923 ); /*Q15*/ #endif @@ -268,7 +274,7 @@ Word16 find_uv_fx( /* o : coding type dE2_th = 21 << 10; move32(); #ifdef BASOP_NOGLOB - if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #else if ( GE_16( add( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif @@ -288,9 +294,9 @@ Word16 find_uv_fx( /* o : coding type { IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) { - st_fx->old_ind_deltaMax = ind_deltaMax; + st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ move16(); - Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); + Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ } ELSE { @@ -309,8 +315,8 @@ Word16 find_uv_fx( /* o : coding type { IF( st_fx->old_ind_deltaMax >= 0 ) { - Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); - dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); + 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 ) ) { @@ -382,11 +388,11 @@ Word16 find_uv_fx( /* o : coding type 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, 22938, st_fx->lp_noise_fx ); + 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, 21299, st_fx->lp_noise_fx ); + 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 ); } @@ -394,10 +400,10 @@ Word16 find_uv_fx( /* o : coding type { /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491, 19661, st_fx->lp_noise_fx ); + 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 ); /* Q8 */ + 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 ) ) @@ -433,16 +439,16 @@ Word16 find_uv_fx( /* o : coding type test(); test(); #ifdef BASOP_NOGLOB - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282, 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 */ - ( LT_32( ee[0], 640 ) ) && ( 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 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 ) ) && /* + 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) */ + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 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) */ #else if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22282, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ @@ -475,16 +481,16 @@ Word16 find_uv_fx( /* o : coding type test(); test(); #ifdef BASOP_NOGLOB - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, 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 ) ) && ( 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 ) ) && ( 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 ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 ) ) && /* + 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 ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), 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) */ #else if ( ( ( LT_16( add( mean_voi3, corr_shift ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ @@ -516,9 +522,9 @@ Word16 find_uv_fx( /* o : coding type 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] ) ); - dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); - dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); + 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(); @@ -529,11 +535,11 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF( ( GT_16( voicing_fr[0], 19825 ) ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 19825 ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 19825 ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 19825 ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 256 ) ) && /* energy concentrated in low frequencies */ + 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 ) ) ) @@ -550,11 +556,11 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF( GT_16( voicing_fr[0], 8192 ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 8192 ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 8192 ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 8192 ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */ + 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 ) ) ) @@ -568,14 +574,14 @@ Word16 find_uv_fx( /* o : coding type /* 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 ), voicing_fr[2], 8192 ), voicing_fr[1], 8192 ), voicing_fr[0], 8192 ); + 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 ) && GT_16( st_fx->voicing_sm_fx, 31785 ) ) ) + 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(); @@ -588,7 +594,7 @@ Word16 find_uv_fx( /* o : coding type * Channel-aware mode - set RF mode and total bitrate *-----------------------------------------------------------------*/ - st_fx->rf_mode = st_fx->Opt_RF_ON; + st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ move16(); IF( EQ_16( coder_type, GENERIC ) ) @@ -597,11 +603,11 @@ Word16 find_uv_fx( /* o : coding type test(); test(); test(); - IF( ( LT_16( voicing_fr[0], 6554 ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[1], 6554 ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[2], 6554 ) ) && /* normalized correlation high in 3rd sf. */ - ( LT_16( voicing_fr[3], 6554 ) ) && /* normalized correlation high in 4th sf. */ - ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ + 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; @@ -641,7 +647,7 @@ Word16 find_uv_fx( /* o : coding type test(); if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) { - st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); + st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ } /* reset spike hysteresis */ diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c index 9ba0a3c0764e86263dd28cebfe9af965e82e59a4..00729bde0ca3e5ac6d67d4ebf4fe522f504bb94e 100644 --- a/lib_enc/find_wsp.c +++ b/lib_enc/find_wsp.c @@ -41,14 +41,14 @@ #include "wmc_auto.h" #include "prot_fx.h" /*-------------------------------------------------------------------* - * find_wsp() + * ivas_find_wsp_fx() * * Compute weighted speech used in open-loop pitch search *-------------------------------------------------------------------*/ -void ivas_find_wsp( - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr, /* i : length of subframe */ - const Word16 nb_subfr, /* i : number of subframes */ +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, @@ -63,7 +63,7 @@ void ivas_find_wsp( /* i/o: W(Z) denominator memory */ // Q_new const Word16 gamma, /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead */ + const Word16 L_look /* i : look-ahead Q0*/ ) { Word16 *p_Aw_fx, tmp_fx; @@ -79,7 +79,7 @@ void ivas_find_wsp( * Compute weighted speech for all subframes *-----------------------------------------------------------------*/ p_Aw_fx = Aw_fx; - for ( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) + 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 ); diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index de81f19214e626801376295422c993120a79672c..7468c3dc77c5fd6064b8665f05a46dbb5e6c806b 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -31,17 +31,17 @@ * void */ void find_wsp_fx( - const Word16 Az[], /* i : A(z) filter coefficients */ - const Word16 speech[], /* i : pointer to the denoised speech frame */ - Word16 wsp[], /* o : poitnter to the weighted speech frame */ - Word16 *mem_wsp, /* i/o: W(Z) denominator memory */ - const Word16 preemph_fac, /* i : pre - emphasis factor Q15 */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 lookahead, /* i : look-ahead */ - const Word16 L_subfr, /* i : length of subframe */ - Word16 *Aw, /* o : weighted A(z) filter coefficients */ - const Word16 gamma, /* i : weighting factor */ - const Word16 nb_subfr /* i : number of subframes */ + const Word16 Az[], /* i : A(z) filter coefficients Q12*/ + const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/ + Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/ + Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/ + const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 lookahead, /* i : look-ahead Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/ + const Word16 gamma, /* i : weighting factor Q15*/ + const Word16 nb_subfr /* i : number of subframes Q0*/ ) { Word16 i_subfr, wtmp; diff --git a/lib_enc/frame_spec_dif_cor_rate_fx.c b/lib_enc/frame_spec_dif_cor_rate_fx.c index 117ced6baf87ef4209f4d88104b659e4b4c84856..3e2eb40155f5e006eda820818db061688d9d2299 100644 --- a/lib_enc/frame_spec_dif_cor_rate_fx.c +++ b/lib_enc/frame_spec_dif_cor_rate_fx.c @@ -20,10 +20,10 @@ * *-------------------------------------------------------------------*/ void frame_spec_dif_cor_rate_fx( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - Word32 *spec_amp, /* i : spectral amplitude*/ - Word16 sacle, /* i : the scaling of spec_amp*/ - Word16 f_tonality_rate[3] /* o : tonality rate*/ + VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ + Word32 *spec_amp, /* i : spectral amplitude scale*/ + Word16 sacle, /* i : the scaling of spec_amp */ + Word16 f_tonality_rate[3] /* o : tonality rate Qx*/ ) { @@ -36,22 +36,23 @@ void frame_spec_dif_cor_rate_fx( Word32 m, dx, dy; Word16 *pre_spec_low_dif = hVAD_CLDFB->pre_spec_low_dif; const Word32 FIX_cost1 = 2147484 /* 0.001f Q31 */; - + move16(); + move32(); p_dx_Q = &dx_Q; maxVal = 0; move32(); FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ ) { - tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] ); + tmp = L_sub( spec_amp[i + 6], spec_amp[i + 5] ); /* scale */ if ( tmp < 0 ) { tmp = 0; move32(); } - tmpspec_low_dif[i] = tmp; + tmpspec_low_dif[i] = tmp; /* scale */ move32(); - maxVal = L_max( maxVal, tmp ); + maxVal = L_max( maxVal, tmp ); /* scale */ } resu = 31; move16(); @@ -71,14 +72,14 @@ void frame_spec_dif_cor_rate_fx( FOR( i = 0; i < PRE_SPEC_DIF_NUM; i++ ) { - spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) ); - m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] ); - dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp ); - dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] ); + spec_low_dif_tmp = round_fx( L_shl( tmpspec_low_dif[i], scalefactor ) ); /* scale + scalefactor - 16 */ + m = L_mac0( m, spec_low_dif_tmp, pre_spec_low_dif[i] ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */ + dx = L_mac0( dx, spec_low_dif_tmp, spec_low_dif_tmp ); /* scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif */ + dy = L_mac0( dy, pre_spec_low_dif[i], pre_spec_low_dif[i] ); /* scale + scalefactor - 16 */ pre_spec_low_dif[i] = spec_low_dif_tmp; move16(); } - dx = L_mult0( round_fx( dx ), round_fx( dy ) ); + dx = L_mult0( round_fx( dx ), round_fx( dy ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */ tmpq = add( sacle, scalefactor ); tmpq = sub( tmpq, 16 ); tmpq2 = add( tmpq, hVAD_CLDFB->scale_spec_low_dif ); @@ -88,11 +89,11 @@ void frame_spec_dif_cor_rate_fx( move16(); IF( LT_16( *p_dx_Q, 31 ) ) { - dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) ); + dx = L_add( dx, L_shr( FIX_cost1, limitScale32( sub( 31, *p_dx_Q ) ) ) ); /* 2 * (scale + scalefactor - 16 + hVAD_CLDFB->scale_spec_low_dif) - 32 */ } ELSE { - dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 ); + dx = L_add( L_shr( dx, limitScale32( sub( *p_dx_Q, 31 ) ) ), FIX_cost1 ); /* Q31 */ *p_dx_Q = 31; move16(); } @@ -110,10 +111,10 @@ void frame_spec_dif_cor_rate_fx( f_tonality_rate[0] = spec_dif_cor_rate; move16(); - tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ ); + tmp = L_mac0( L_mult0( f_tonality_rate[1], 31456 /* 0.96 Q15 */ ), spec_dif_cor_rate, 1311 /* 0.04 Q15 */ ); /* tmpq */ f_tonality_rate[1] = shl( round_fx( tmp ), 1 ); move16(); - tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ ); + tmp = L_mac0( L_mult0( f_tonality_rate[2], 29490 /* 0.90 Q15 */ ), spec_dif_cor_rate, 3277 /* 0.1 Q15 */ ); /* tmpq */ f_tonality_rate[2] = shl( round_fx( tmp ), 1 ); move16(); hVAD_CLDFB->scale_spec_low_dif = tmpq; diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 30caee67e01193ed958623185ab36ec51ea19e42..2988a8fb847696a49d359953e79c31dd6abdf460 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -50,14 +50,14 @@ static Word16 Find_Opt_gainQ_fx( Word16 *coeff, Word16 *exp_coeff, Word16 *gain_ /*==========================================================================*/ void Es_pred_enc_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */ - Word16 *indice, /* o : indice of quantization */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 *res, /* i : residual signal */ - const Word16 *voicing, /* i : normalized correlation in three 1/2frames */ - const Word16 nb_bits, /* i : allocated number of bits */ - const Word16 no_ltp, /* i : no_ltp flag */ - Word16 Q_new /* i : Scaling in speech Q0 */ + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + Word16 *indice, /* o : indice of quantization Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 *res, /* i : residual signal Q_new*/ + const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/ + const Word16 nb_bits, /* i : allocated number of bits Q0*/ + const Word16 no_ltp, /* i : no_ltp flag Q0*/ + Word16 Q_new /* i : Scaling in speech Q0*/ ) { Word16 i, i_subfr, size, tmp16, tmp16_2, Q_res; @@ -67,6 +67,7 @@ void Es_pred_enc_fx( Word32 ener_fx, Lmean_ener_code, Ltmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif Lmean_ener_code = L_deposit_l( 0 ); @@ -90,11 +91,11 @@ void Es_pred_enc_fx( FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { /* calculate the energy of residual signal */ - tmp16 = mult_r( res[i_subfr + 0], 8192 ); /* remove 2bits */ + tmp16 = mult_r( res[i_subfr + 0], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ ener_fx = L_mult( tmp16, tmp16 ); FOR( i = 1; i < L_SUBFR; i++ ) { - tmp16 = mult_r( res[i_subfr + i], 8192 ); /* remove 2bits */ + tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ #ifdef BASOP_NOGLOB ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); #else @@ -119,6 +120,7 @@ void Es_pred_enc_fx( if ( ( ener_dB < 0 ) && ( no_ltp == 0 ) ) { ener_dB = 0; + move16(); } /* update the average energy of residual signal */ @@ -142,22 +144,22 @@ void Es_pred_enc_fx( { case 5: { - qua_table = Es_pred_qua_5b_fx; + qua_table = Es_pred_qua_5b_fx; // Q8 BREAK; } case 4: { - qua_table = Es_pred_qua_4b_fx; + qua_table = Es_pred_qua_4b_fx; // Q8 BREAK; } case 3: { - qua_table = Es_pred_qua_3b_fx; + qua_table = Es_pred_qua_3b_fx; // Q8 BREAK; } default: { - qua_table = Es_pred_qua_5b_fx; + qua_table = Es_pred_qua_5b_fx; // Q8 BREAK; } } @@ -166,13 +168,13 @@ void Es_pred_enc_fx( { mean_ener_code16 = extract_h( Lmean_ener_code ); /*Q8*/ - qua_table = Es_pred_qua_4b_no_ltp_fx; + qua_table = Es_pred_qua_4b_no_ltp_fx; // Q8 } /*size = extract_l(pow2_fx[nb_bits]); */ /*maximum number of bit is 6 */ size = shl( 1, nb_bits ); /*maximum number of bit is 6 */ /* find the nearest neighbour (codevector) */ - *Es_pred = qua_table[0]; + *Es_pred = qua_table[0]; // Q8 move16(); tmp16 = abs_s( sub( mean_ener_code16, qua_table[0] ) ); *indice = 0; @@ -191,7 +193,7 @@ void Es_pred_enc_fx( move16(); *indice = i; move16(); - *Es_pred = qua_table[i]; + *Es_pred = qua_table[i]; // Q8 move16(); } } @@ -209,24 +211,24 @@ void Es_pred_enc_fx( * - the mean-squared weighted error criterion is used for codebook search *---------------------------------------------------------------------*/ void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 element_mode, /* i : element 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 */ - const Word16 *xn, /* i : target vector */ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation */ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word16 Es_pred, /* i : predicted scaled innovation energy */ - Word16 *gain_pit, /* o : quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */ + 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*/ ) { @@ -242,6 +244,7 @@ void gain_enc_mless_fx( Word32 L_frac_num, L_frac_den, L_div; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*-----------------------------------------------------------------* @@ -304,6 +307,7 @@ void gain_enc_mless_fx( /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = Isqrt_lc( L_tmp, &exp_inov ); *gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); /* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */ /*----------------------------------------------------------------* @@ -325,7 +329,7 @@ void gain_enc_mless_fx( * select the codebook, size and number of bits * set the gains searching range *-----------------------------------------------------------------*/ - nBits = gains_mode[shr( i_subfr, 6 )]; + nBits = gains_mode[i_subfr >> 6]; move16(); test(); @@ -364,9 +368,9 @@ void gain_enc_mless_fx( } L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ - frac_den = extract_h( L_frac_den ); - frac_den = s_max( frac_den, 1 ); - L_frac_den = L_max( L_frac_den, 1 ); + frac_den = extract_h( L_frac_den ); /* Q15 */ + frac_den = s_max( frac_den, 1 ); /* Q15 */ + L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */ exp = norm_l( L_frac_den ); tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/ @@ -409,11 +413,13 @@ void gain_enc_mless_fx( { L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/ exp_num = exp1; + move16(); } ELSE { L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/ exp_num = exp2; + move16(); } L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ @@ -428,6 +434,7 @@ void gain_enc_mless_fx( move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) ); + move16(); /* set number of bits for two SQs */ nBits2 = shr( add( nBits, 1 ), 1 ); @@ -447,6 +454,7 @@ void gain_enc_mless_fx( tmp = div_s( 16384, gcode0 ); /*Q15*/ L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/ *gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/ + move32(); } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); @@ -477,7 +485,7 @@ void gain_enc_mless_fx( case 6: { qua_table = gain_qua_mless_6b_fx; - if ( GT_16( element_mode, EVS_MONO ) ) + if ( element_mode > EVS_MONO ) { #ifdef IVAS_CODE qua_table = gain_qua_mless_6b_stereo; @@ -494,7 +502,7 @@ void gain_enc_mless_fx( } case 5: { - qua_table = gain_qua_mless_5b_fx; + qua_table = gain_qua_mless_5b_fx; // Q14 move16(); if ( EQ_16( clip_gain, 1 ) ) { @@ -504,7 +512,7 @@ void gain_enc_mless_fx( } default: { - qua_table = gain_qua_mless_6b_fx; + qua_table = gain_qua_mless_6b_fx; // Q14 move16(); if ( EQ_16( clip_gain, 1 ) ) { @@ -525,7 +533,7 @@ void gain_enc_mless_fx( /*-----------------------------------------------------------------* * search for the best quantizer *-----------------------------------------------------------------*/ - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size ); + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, qua_table, size ); // Q0 push_indice_fx( hBstr, IND_GAIN, index, nBits ); } @@ -541,24 +549,24 @@ void gain_enc_mless_fx( } void gain_enc_mless_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 element_mode, /* i : element 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 */ - const Word16 *xn, /* i : target vector */ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation */ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word16 Es_pred, /* i : predicted scaled innovation energy */ - Word16 *gain_pit, /* o : quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */ + 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*/ ) { @@ -574,6 +582,7 @@ void gain_enc_mless_ivas_fx( Word32 L_frac_num, L_frac_den, L_div; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*-----------------------------------------------------------------* @@ -636,6 +645,7 @@ void gain_enc_mless_ivas_fx( /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = Isqrt_lc( L_tmp, &exp_inov ); *gain_inov = extract_h( L_shl( L_tmp, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); /* gcode0 = pow(10, 0.05 * (Es_pred - Ei)) */ /*----------------------------------------------------------------* @@ -657,7 +667,7 @@ void gain_enc_mless_ivas_fx( * select the codebook, size and number of bits * set the gains searching range *-----------------------------------------------------------------*/ - nBits = gains_mode[shr( i_subfr, 6 )]; + nBits = gains_mode[i_subfr >> 6]; move16(); test(); @@ -696,9 +706,9 @@ void gain_enc_mless_ivas_fx( } L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ - frac_den = extract_h( L_frac_den ); - frac_den = s_max( frac_den, 1 ); - L_frac_den = L_max( L_frac_den, 1 ); + frac_den = extract_h( L_frac_den ); /* Q15 */ + frac_den = s_max( frac_den, 1 ); /* Q15 */ + L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */ exp = norm_l( L_frac_den ); tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/ @@ -741,11 +751,13 @@ void gain_enc_mless_ivas_fx( { L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/ exp_num = exp1; + move16(); } ELSE { L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/ exp_num = exp2; + move16(); } L_frac_num = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ @@ -779,6 +791,7 @@ void gain_enc_mless_ivas_fx( tmp = div_s( 16384, gcode0 ); /*Q15*/ L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/ *gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/ + move32(); } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); @@ -798,8 +811,7 @@ void gain_enc_mless_ivas_fx( { case 7: { - qua_table = gain_qua_mless_7b_fx; - move16(); + qua_table = gain_qua_mless_7b_fx; // Q14 if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 30 ); @@ -808,12 +820,11 @@ void gain_enc_mless_ivas_fx( } case 6: { - qua_table = gain_qua_mless_6b_fx; - if ( GT_16( element_mode, EVS_MONO ) ) + qua_table = gain_qua_mless_6b_fx; // Q14 + if ( element_mode > EVS_MONO ) { qua_table = gain_qua_mless_6b_stereo_fx; } - move16(); if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 14 ); @@ -822,8 +833,7 @@ void gain_enc_mless_ivas_fx( } case 5: { - qua_table = gain_qua_mless_5b_fx; - move16(); + qua_table = gain_qua_mless_5b_fx; // Q14 if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 6 ); @@ -832,8 +842,7 @@ void gain_enc_mless_ivas_fx( } default: { - qua_table = gain_qua_mless_6b_fx; - move16(); + qua_table = gain_qua_mless_6b_fx; // Q14 if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 14 ); @@ -862,7 +871,7 @@ void gain_enc_mless_ivas_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); return; @@ -880,21 +889,21 @@ void gain_enc_mless_ivas_fx( *---------------------------------------------------------------------*/ void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 i_subfr, /* i : subframe index */ - 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 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const Word16 Q_xn /* i : xn and y1 scaling */ + 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 */ ) { Word16 index, nBits_pitch, nBits_code; @@ -909,6 +918,7 @@ void gain_enc_SQ_fx( Word32 L_frac_num, L_frac_den, L_div; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*-----------------------------------------------------------------* @@ -931,16 +941,19 @@ void gain_enc_SQ_fx( /* Compute scalar product */ coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); move16(); /* -18 (y2 Q9) */ /* Compute scalar product */ coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[3] = add( sub( exp, 9 ), Q_xn ); move16(); /* -9 (y2 Q9), (xn y2) */ /* Compute scalar product */ coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[4] = add( sub( exp, 9 ), Q_xn ); move16(); /* -9 (y2 Q9), (y1 y2) */ @@ -1031,9 +1044,9 @@ void gain_enc_SQ_fx( } L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ - frac_den = extract_h( L_frac_den ); - frac_den = s_max( frac_den, 1 ); - L_frac_den = L_max( L_frac_den, 1 ); + frac_den = extract_h( L_frac_den ); /* Q15 */ + frac_den = s_max( frac_den, 1 ); /* Q15 */ + L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */ exp = norm_l( L_frac_den ); tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/ @@ -1081,11 +1094,13 @@ void gain_enc_SQ_fx( { L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/ exp_num = exp1; + move16(); } ELSE { L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/ exp_num = exp2; + move16(); } #ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ @@ -1111,14 +1126,14 @@ void gain_enc_SQ_fx( test(); test(); - IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) ) + IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) ) { - *gain_pit = 15565; + *gain_pit = 15565; /* 0.95 in Q14 */ move16(); } - ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) ) + ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) ) { - *gain_pit = 10650; + *gain_pit = 10650; /* 0.65 in Q14 */ move16(); } @@ -1126,7 +1141,8 @@ void gain_enc_SQ_fx( * search for the best quantized values *-----------------------------------------------------------------*/ - nBits_pitch = gains_mode[shr( i_subfr, 6 )]; + nBits_pitch = gains_mode[i_subfr >> 6]; + move16(); /* set number of bits for two SQs */ nBits_code = shr( add( nBits_pitch, 1 ), 1 ); @@ -1136,8 +1152,7 @@ void gain_enc_SQ_fx( /*tmp1 = (G_PITCH_MAX - G_PITCH_MIN) / ((1 << nBits_pitch) - 1);*/ /* set quantization step */ tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */ - index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); - move16(); + index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); // Q0 push_indice_fx( hBstr, IND_GAIN_PIT, index, nBits_pitch ); /* gain_code Q */ @@ -1147,6 +1162,7 @@ void gain_enc_SQ_fx( tmp = div_s( 16384, gcode0 ); /*Q15*/ L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/ *gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/ + move32(); } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg ); @@ -1164,28 +1180,28 @@ void gain_enc_SQ_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); return; } void gain_enc_SQ_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 i_subfr, /* i : subframe index */ - 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 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const Word16 Q_xn /* i : xn and y1 scaling */ + 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 */ ) { Word16 index, nBits_pitch, nBits_code; @@ -1200,6 +1216,7 @@ void gain_enc_SQ_ivas_fx( Word32 L_frac_num, L_frac_den, L_div; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*-----------------------------------------------------------------* @@ -1222,16 +1239,19 @@ void gain_enc_SQ_ivas_fx( /* Compute scalar product */ coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); move16(); /* -18 (y2 Q9) */ /* Compute scalar product */ coeff[3] = extract_h( Dot_product12( xn, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[3] = add( sub( exp, 9 ), Q_xn ); move16(); /* -9 (y2 Q9), (xn y2) */ /* Compute scalar product */ coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) ); + move16(); exp_coeff[4] = add( sub( exp, 9 ), Q_xn ); move16(); /* -9 (y2 Q9), (y1 y2) */ @@ -1322,9 +1342,9 @@ void gain_enc_SQ_ivas_fx( } L_frac_den = L_sub( L_tmp1, L_tmp2 ); /*Q31*/ - frac_den = extract_h( L_frac_den ); - frac_den = s_max( frac_den, 1 ); - L_frac_den = L_max( L_frac_den, 1 ); + frac_den = extract_h( L_frac_den ); /* Q15 */ + frac_den = s_max( frac_den, 1 ); /* Q15 */ + L_frac_den = L_max( L_frac_den, 1 ); /* Q31 */ exp = norm_l( L_frac_den ); tmp = div_s( shl( 1, sub( 14, exp ) ), frac_den ); /*Q(14-exp)*/ @@ -1358,15 +1378,17 @@ void gain_enc_SQ_ivas_fx( #ifdef BASOP_NOGLOB *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ -#else /* BASOP_NOGLOB */ + move16(); +#else /* BASOP_NOGLOB */ *gain_pit = round_fx( L_shl( L_div, add( exp, exp_div ) ) ); /*Q14*/ -#endif /* BASOP_NOGLOB */ + move16(); +#endif /* BASOP_NOGLOB */ // To be checked #ifdef BASOP_NOGLOB L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/ #else /* BASOP_NOGLOB */ - L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ + L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ #endif /* BASOP_NOGLOB */ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -1377,16 +1399,18 @@ void gain_enc_SQ_ivas_fx( { L_tmp2 = L_shr( L_tmp2, sub( exp1, exp2 ) ); /*Q31*/ exp_num = exp1; + move16(); } ELSE { L_tmp1 = L_shr( L_tmp1, sub( exp2, exp1 ) ); /*Q31*/ exp_num = exp2; + move16(); } #ifdef BASOP_NOGLOB L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #else /* BASOP_NOGLOB */ - L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ + L_frac_num = L_sub( L_tmp2, L_tmp1 ); /*Q31*/ #endif /* BASOP_NOGLOB */ L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ @@ -1407,14 +1431,14 @@ void gain_enc_SQ_ivas_fx( test(); test(); - IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) ) + IF( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 /* 0.95 in Q14 */ ) ) { - *gain_pit = 15565; + *gain_pit = 15565; /* 0.95 in Q14 */ move16(); } - ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 ) ) + ELSE IF( EQ_16( clip_gain, 2 ) && GT_16( *gain_pit, 10650 /* 0.65 in Q14 */ ) ) { - *gain_pit = 10650; + *gain_pit = 10650; /* 0.65 in Q14 */ move16(); } @@ -1422,7 +1446,8 @@ void gain_enc_SQ_ivas_fx( * search for the best quantized values *-----------------------------------------------------------------*/ - nBits_pitch = gains_mode[shr( i_subfr, 6 )]; + nBits_pitch = gains_mode[i_subfr >> 6]; + move16(); /* set number of bits for two SQs */ nBits_code = shr( add( nBits_pitch, 1 ), 1 ); @@ -1433,7 +1458,6 @@ void gain_enc_SQ_ivas_fx( tmp1 = mult_r( G_PITCH_MAX_Q13, div_s( 1, sub( shl( 1, nBits_pitch ), 1 ) ) ); /*Q13*/ /* set quantization step */ index = usquant_fx( *gain_pit, gain_pit, G_PITCH_MIN_Q14, tmp1, shl( 1, nBits_pitch ) ); - move16(); push_indice( hBstr, IND_GAIN_PIT, index, nBits_pitch ); /* gain_code Q */ @@ -1443,6 +1467,7 @@ void gain_enc_SQ_ivas_fx( tmp = div_s( 16384, gcode0 ); /*Q15*/ L_tmp = Mult_32_16( *gain_code, tmp ); /*Q16*/ *gain_code = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/ + move32(); } index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_Q14, LG10_G_CODE_MAX_Q13, nBits_code, &expg ); @@ -1460,7 +1485,7 @@ void gain_enc_SQ_ivas_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); return; @@ -1471,12 +1496,12 @@ void gain_enc_SQ_ivas_fx( * * Quantization of gain for Gaussian codebook *-------------------------------------------------------------------*/ -Word16 gain_enc_gaus_fx( /* o : Return index of quantization */ - Word32 *gain, /* i/o: Code gain to quantize */ - const Word16 bits, /* i : number of bits to quantize */ - 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 */ +Word16 gain_enc_gaus_fx( /* o : Return index of quantization */ + 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*/ ) { Word16 index, exp_gain, frac_gain, wtmp; @@ -1484,6 +1509,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Word32 Ltmp, enr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*enr = 20.0 * log10(*gain + 0.001) codebook gain in dB */ exp_gain = norm_l( *gain ); @@ -1499,10 +1525,10 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant wtmp = sub( wenr, lowBound ); /* Q8 */ - index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); + index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); // Q0 /* index [0 (1<> 6]; // Q0 + move16(); /*----------------------------------------------------------------* * find the code pitch (for current subframe) @@ -1774,7 +1808,7 @@ void gain_enc_tc_ivas_fx( i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */ g_code_fx = i_mult2( g_code_fx, tmp16 ); /* apply sign */ #ifdef BASOP_NOGLOB - *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); + *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); /* Q16 */ #else *gain_code_fx = L_shr( L_deposit_l( g_code_fx ), i ); #endif @@ -1828,6 +1862,7 @@ void gain_enc_tc_ivas_fx( tmp16 = div_s( 16384, gcode0_fx ); /*Q15*/ L_tmp = Mult_32_16( *gain_code_fx, tmp16 ); /*Q16*/ *gain_code_fx = L_shr( L_tmp, add( 14, exp_gcode0 ) ); /*Q16*/ + move32(); } ELSE { @@ -1868,7 +1903,7 @@ void gain_enc_tc_ivas_fx( { /* 2-bit -> 3-bit decoding */ index = shr( index, 1 ); - wgain_code = tbl_gain_code_tc_fx[shl( index, 1 )]; + wgain_code = tbl_gain_code_tc_fx[index * 2]; // Q13 move16(); /**gain_code *= gcode0;*/ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ @@ -1878,7 +1913,7 @@ void gain_enc_tc_ivas_fx( } ELSE /* nBits == 3 */ { - wgain_code = tbl_gain_code_tc_fx[index]; + wgain_code = tbl_gain_code_tc_fx[index]; // Q13 move16(); /**gain_code *= gcode0;*/ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ @@ -1900,7 +1935,7 @@ void gain_enc_tc_ivas_fx( 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 ) ); + *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); // Q6 move32(); return; } @@ -1910,14 +1945,14 @@ void gain_enc_tc_ivas_fx( * Find the best quantizer *-----------------------------------------------------------------*/ static Word16 Find_Opt_gainQ_fx( - Word16 *coeff, + Word16 *coeff, /* exp(exp_coeff) */ Word16 *exp_coeff, - Word16 *gain_pit, - Word32 *gain_code, - Word16 gcode0, + Word16 *gain_pit, /* Q14 */ + Word32 *gain_code, /* Q16 */ + Word16 gcode0, /* exp(exp_gcode0) */ Word16 exp_gcode0, - const Word16 *cdbk, /* i : Codebook used */ - const Word16 size /* i : size of Codebook used */ + const Word16 *cdbk, /* i : Codebook used Q14*/ + const Word16 size /* i : size of Codebook used Q0*/ ) { Word16 index, i, j; @@ -1930,6 +1965,7 @@ static Word16 Find_Opt_gainQ_fx( Word32 L_tmp, L_tmp1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif @@ -1993,7 +2029,7 @@ static Word16 Find_Opt_gainQ_fx( } /* searching of codebook */ - p = cdbk; + p = cdbk; // Q14 move16(); dist_min = L_deposit_h( MAX_16 ); index = 0; @@ -2005,8 +2041,8 @@ static Word16 Find_Opt_gainQ_fx( g_code = *p++; move16(); - g_code = mult_r( g_code, gcode0 ); - g2_pitch = mult_r( g_pitch, g_pitch ); + g_code = mult_r( g_code, gcode0 ); // exp_gcode - 1 + g2_pitch = mult_r( g_pitch, g_pitch ); // Q13 g_pit_cod = mult_r( g_code, g_pitch ); L_tmp = L_mult( g_code, g_code ); g2_code_lo = L_Extract_lc( L_tmp, &g2_code ); @@ -2019,11 +2055,11 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff_lo[3], g_code ); L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod ); L_tmp = L_shr( L_tmp, 12 ); - L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); - L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); - L_tmp = L_mac( L_tmp, coeff[2], g2_code ); - L_tmp = L_mac( L_tmp, coeff[3], g_code ); - L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); + L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef BASOP_NOGLOB L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); @@ -2038,7 +2074,7 @@ static Word16 Find_Opt_gainQ_fx( dist_min = L_min( L_tmp, dist_min ); } - p = &cdbk[add( index, index )]; + p = &cdbk[add( index, index )]; // Q14 move16(); *gain_pit = *p++; /* selected pitch gain in Q14 */ @@ -2070,10 +2106,10 @@ static Word16 Find_Opt_gainQ_fx( *---------------------------------------------------------------------*/ void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ + 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 */ @@ -2084,10 +2120,10 @@ void gain_enc_lbr_fx( 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 */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const int16_t L_subfr /* i : subframe length */ + 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*/ ) { @@ -2097,6 +2133,8 @@ void gain_enc_lbr_fx( Word16 coeff[5], exp_coeff[5]; Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf; Word32 L_tmp, L_tmp1, L_inov; + move16(); + move16(); L_subfr_sf = 6; move16(); @@ -2128,18 +2166,21 @@ void gain_enc_lbr_fx( } #endif coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) ); + move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */ move16(); /* Compute scalar product -2* */ coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) ); + move16(); exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */ move16(); /* Compute scalar product 2* */ coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) ); + move16(); exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */ move16(); @@ -2155,6 +2196,7 @@ void gain_enc_lbr_fx( exp_inov = sub( exp_code, add( 18, L_subfr_sf ) ); L_inov = Isqrt_lc( L_inov, &exp_inov ); *gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); /*-----------------------------------------------------------------* @@ -2172,9 +2214,10 @@ void gain_enc_lbr_fx( * calculate prediction of gcode * search for the best codeword *-----------------------------------------------------------------*/ + test(); IF( i_subfr == 0 ) { - b = b_1sfr_fx; + b = b_1sfr_fx; // Q12 move16(); n_pred = 2; move16(); @@ -2183,43 +2226,38 @@ void gain_enc_lbr_fx( { case 8: { - cdbk = gp_gamma_1sfr_8b_fx; - move16(); + cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 60 ); } - move16(); BREAK; } case 7: { - cdbk = gp_gamma_1sfr_7b_fx; - move16(); + cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 27 ); } - move16(); BREAK; } case 6: { - cdbk = gp_gamma_1sfr_6b_fx; - move16(); + cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 10 ); } - move16(); BREAK; } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); + move16(); /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode)); gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); @@ -2251,7 +2289,7 @@ void gain_enc_lbr_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0 gc_mem[0] = *gain_code; move16(); /*Q16*/ @@ -2269,30 +2307,26 @@ void gain_enc_lbr_fx( { case 7: { - cdbk = gp_gamma_2sfr_7b_fx; - move16(); + cdbk = gp_gamma_2sfr_7b_fx; /* Q14/Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 30 ); } - move16(); BREAK; } case 6: { - cdbk = gp_gamma_2sfr_6b_fx; - move16(); + cdbk = gp_gamma_2sfr_6b_fx; /* Q14/Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 12 ); } - move16(); BREAK; } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2305,6 +2339,7 @@ void gain_enc_lbr_fx( L_tmp1 = Mpy_32_16( exp, frac, 9864 ); move16(); /* Q16 */ aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); aux[3] = shr( gp_mem[0], 2 ); move16(); /*Q12*/ @@ -2323,15 +2358,15 @@ void gain_enc_lbr_fx( /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); - gc_mem[1] = *gain_code; + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0 + gc_mem[1] = *gain_code; // Q16 move32(); - gp_mem[1] = *gain_pit; + gp_mem[1] = *gain_pit; // Q14 move16(); } ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) ) { - b = b_3sfr_fx; + b = b_3sfr_fx; // Q12 move16(); n_pred = 6; move16(); @@ -2349,15 +2384,14 @@ void gain_enc_lbr_fx( } ELSE { - cdbk = gp_gamma_3sfr_6b_fx; - move16(); + cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 11 ); } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2369,6 +2403,7 @@ void gain_enc_lbr_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); /*aux[3] = (float)log10(gc_mem[1]); = log2(gc_mem[1])*log10(2);*/ @@ -2377,6 +2412,7 @@ void gain_enc_lbr_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); aux[4] = shr( gp_mem[0], 2 ); move16(); /*Q12*/ @@ -2426,14 +2462,14 @@ void gain_enc_lbr_fx( index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); - gc_mem[2] = *gain_code; + gc_mem[2] = *gain_code; // Q16 move32(); - gp_mem[2] = *gain_pit; + gp_mem[2] = *gain_pit; // Q14 move16(); } ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) ) { - b = b_4sfr_fx; + b = b_4sfr_fx; // Q12 move16(); n_pred = 8; move16(); @@ -2451,16 +2487,14 @@ void gain_enc_lbr_fx( } ELSE { - cdbk = gp_gamma_4sfr_6b_fx; - move16(); + cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 11 ); - move16(); } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2472,6 +2506,7 @@ void gain_enc_lbr_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); /*aux[3] = (float)log10(gc_mem[1]); = log2(gc_mem[1])*log10(2);*/ @@ -2480,6 +2515,7 @@ void gain_enc_lbr_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[1])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); /*aux[4] = (float)log10(gc_mem[2]); @@ -2489,6 +2525,7 @@ void gain_enc_lbr_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[2])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); aux[5] = shr( gp_mem[0], 2 ); move16(); /*Q12*/ @@ -2510,7 +2547,7 @@ void gain_enc_lbr_fx( /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0 } /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -2518,7 +2555,7 @@ void gain_enc_lbr_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); { push_indice_fx( hBstr, IND_GAIN, index, nBits ); @@ -2527,10 +2564,10 @@ void gain_enc_lbr_fx( } void gain_enc_lbr_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ + 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 */ @@ -2541,10 +2578,10 @@ void gain_enc_lbr_ivas_fx( 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) */ - const int16_t L_subfr /* i : subframe length */ + 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*/ ) { @@ -2554,6 +2591,7 @@ void gain_enc_lbr_ivas_fx( Word16 coeff[5], exp_coeff[5]; Word16 exp, exp_code, exp_inov, exp_gcode0, frac, tmp, L_subfr_sf; Word32 L_tmp, L_tmp1, L_inov; + move16(); L_subfr_sf = 6; move16(); @@ -2585,18 +2623,21 @@ void gain_enc_lbr_ivas_fx( } #endif coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) ); + move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */ move16(); /* Compute scalar product -2* */ coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_subfr, &exp ) ) ); + move16(); exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */ move16(); /* Compute scalar product 2* */ coeff[4] = extract_h( Dot_product12( y1, y2, L_subfr, &exp ) ); + move16(); exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */ move16(); @@ -2612,6 +2653,7 @@ void gain_enc_lbr_ivas_fx( exp_inov = sub( exp_code, add( 18, L_subfr_sf ) ); L_inov = Isqrt_lc( L_inov, &exp_inov ); *gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); /*-----------------------------------------------------------------* @@ -2629,9 +2671,10 @@ void gain_enc_lbr_ivas_fx( * calculate prediction of gcode * search for the best codeword *-----------------------------------------------------------------*/ + test(); IF( i_subfr == 0 ) { - b = b_1sfr_fx; + b = b_1sfr_fx; // Q12 move16(); n_pred = 2; move16(); @@ -2640,43 +2683,38 @@ void gain_enc_lbr_ivas_fx( { case 8: { - cdbk = gp_gamma_1sfr_8b_fx; - move16(); + cdbk = gp_gamma_1sfr_8b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 60 ); } - move16(); BREAK; } case 7: { - cdbk = gp_gamma_1sfr_7b_fx; - move16(); + cdbk = gp_gamma_1sfr_7b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 27 ); } - move16(); BREAK; } case 6: { - cdbk = gp_gamma_1sfr_6b_fx; - move16(); + cdbk = gp_gamma_1sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 10 ); } - move16(); BREAK; } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); + move16(); /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode)); gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); @@ -2717,7 +2755,7 @@ void gain_enc_lbr_ivas_fx( } ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) ) { - b = b_2sfr_fx; + b = b_2sfr_fx; // Q12 move16(); n_pred = 4; move16(); @@ -2726,8 +2764,7 @@ void gain_enc_lbr_ivas_fx( { case 7: { - cdbk = gp_gamma_2sfr_7b_fx; - move16(); + cdbk = gp_gamma_2sfr_7b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 30 ); @@ -2736,8 +2773,7 @@ void gain_enc_lbr_ivas_fx( } case 6: { - cdbk = gp_gamma_2sfr_6b_fx; - move16(); + cdbk = gp_gamma_2sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 12 ); @@ -2747,7 +2783,7 @@ void gain_enc_lbr_ivas_fx( } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; /* 1 in Q12 */ move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2778,21 +2814,21 @@ void gain_enc_lbr_ivas_fx( /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); - gc_mem[1] = *gain_code; + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0 + gc_mem[1] = *gain_code; // Q16 move32(); - gp_mem[1] = *gain_pit; + gp_mem[1] = *gain_pit; // Q14 move16(); } ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) ) { - b = b_3sfr_fx; + b = b_3sfr_fx; // Q12 move16(); n_pred = 6; move16(); IF( EQ_16( nBits, 7 ) ) { - cdbk = gp_gamma_3sfr_7b_fx; + cdbk = gp_gamma_3sfr_7b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 28 ); @@ -2800,15 +2836,14 @@ void gain_enc_lbr_ivas_fx( } ELSE { - cdbk = gp_gamma_3sfr_6b_fx; - move16(); + cdbk = gp_gamma_3sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 11 ); } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; // Q12 move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2820,6 +2855,7 @@ void gain_enc_lbr_ivas_fx( exp = sub( sub( 30, exp ), 16 ); /*Q_format(gc_mem[0])=16*/ L_tmp1 = Mpy_32_16( exp, frac, 9864 ); /* Q16 */ aux[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ + move16(); /*aux[3] = (float)log10(gc_mem[1]); = log2(gc_mem[1])*log10(2);*/ @@ -2878,21 +2914,20 @@ void gain_enc_lbr_ivas_fx( index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); - gc_mem[2] = *gain_code; + gc_mem[2] = *gain_code; /* Q16 */ move32(); - gp_mem[2] = *gain_pit; + gp_mem[2] = *gain_pit; /* Q14 */ move16(); } ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) ) { - b = b_4sfr_fx; + b = b_4sfr_fx; /* Q12 */ move16(); n_pred = 8; move16(); IF( EQ_16( nBits, 7 ) ) { - cdbk = gp_gamma_4sfr_7b_fx; - move16(); + cdbk = gp_gamma_4sfr_7b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 25 ); @@ -2900,15 +2935,14 @@ void gain_enc_lbr_ivas_fx( } ELSE { - cdbk = gp_gamma_4sfr_6b_fx; - move16(); + cdbk = gp_gamma_4sfr_6b_fx; /* Q14 / Q9 */ if ( EQ_16( clip_gain, 1 ) ) { size = sub( size, 11 ); } } /* calculate predicted gain */ - aux[0] = 4096; + aux[0] = 4096; // Q12 move16(); aux[1] = shl( ctype, 12 ); move16(); @@ -2960,7 +2994,7 @@ void gain_enc_lbr_ivas_fx( /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); - index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); + index = Find_Opt_gainQ_fx( coeff, exp_coeff, gain_pit, gain_code, gcode0, exp_gcode0, cdbk, size ); // Q0 } /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -2968,7 +3002,7 @@ void gain_enc_lbr_ivas_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); { push_indice( hBstr, IND_GAIN, index, nBits ); @@ -2989,20 +3023,20 @@ void gain_enc_lbr_ivas_fx( void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector */ - const Word16 Q_xn, /* i : xn and yy1 format Q0 */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */ + 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*/ ) { @@ -3015,15 +3049,16 @@ void gain_enc_amr_wb_fx( const Word16 *t_qua_gain, *p; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*----------------------------------------------------------------* * Find the initial quantization pitch index * Set gains search range *----------------------------------------------------------------*/ - IF( core_brate >= ACELP_12k65 ) + IF( GE_32( core_brate, ACELP_12k65 ) ) { - t_qua_gain = t_qua_gain7b_fx; + t_qua_gain = t_qua_gain7b_fx; // Q14 move16(); /* pt at 1/4th of table */ p = t_qua_gain7b_fx + RANGE; @@ -3038,14 +3073,14 @@ void gain_enc_amr_wb_fx( } min_ind = 0; move16(); - g_pitch = *gain_pit; + g_pitch = *gain_pit; // Q14 move16(); FOR( i = 0; i < j; i++ ) { if ( GT_16( g_pitch, *p ) ) { - min_ind = add( min_ind, 1 ); + min_ind = add( min_ind, 1 ); // Q0 } p += 2; } @@ -3055,7 +3090,7 @@ void gain_enc_amr_wb_fx( } ELSE { - t_qua_gain = t_qua_gain6b_fx; + t_qua_gain = t_qua_gain6b_fx; // Q14 min_ind = 0; move16(); size = RANGE; @@ -3090,14 +3125,20 @@ void gain_enc_amr_wb_fx( /* Compute scalar product */ coeff[2] = extract_h( Dot_product12( y2, y2, L_SUBFR, &exp ) ); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */ + move16(); + move16(); /* Compute scalar product -2* */ coeff[3] = extract_h( L_negate( Dot_product12( xn, y2, L_SUBFR, &exp ) ) ); exp_coeff[3] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 xn y2) */ + move16(); + move16(); /* Compute scalar product 2* */ coeff[4] = extract_h( Dot_product12( yy1, y2, L_SUBFR, &exp ) ); exp_coeff[4] = add( sub( exp, 9 - 1 ), Q_xn ); /* -9 (y2 Q9), +1 (2 yy1 y2) */ + move16(); + move16(); /*----------------------------------------------------------------* * Find energy of code and compute: @@ -3112,6 +3153,7 @@ void gain_enc_amr_wb_fx( exp_inov = sub( exp_code, 18 + 6 ); L_inov = Isqrt_lc( L_inov, &exp_inov ); *gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ + move16(); exp_code = sub( exp_code, 18 + 6 + 31 ); frac = Log2_lc( L_tmp, &exp ); @@ -3208,7 +3250,7 @@ void gain_enc_amr_wb_fx( /* Codebook search */ dist_min = L_add( MAX_32, 0 ); - p = &t_qua_gain[shl( min_ind, 1 )]; + p = &t_qua_gain[shl( min_ind, 1 )]; // Q14 move16(); index = 0; @@ -3220,8 +3262,8 @@ void gain_enc_amr_wb_fx( g_code = *p++; move16(); - g_code = mult_r( g_code, gcode0 ); - g2_pitch = mult_r( g_pitch, g_pitch ); + g_code = mult_r( g_code, gcode0 ); // exp(gcode) - 1 + g2_pitch = mult_r( g_pitch, g_pitch ); // Q13 g_pit_cod = mult_r( g_code, g_pitch ); L_tmp = L_mult( g_code, g_code ); L_Extract( L_tmp, &g2_code, &g2_code_lo ); @@ -3234,11 +3276,11 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff_lo[3], g_code ); L_tmp = L_mac( L_tmp, coeff_lo[4], g_pit_cod ); L_tmp = L_shr( L_tmp, 12 ); - L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); - L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); - L_tmp = L_mac( L_tmp, coeff[2], g2_code ); - L_tmp = L_mac( L_tmp, coeff[3], g_code ); - L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); + L_tmp = L_mac( L_tmp, coeff[0], g2_pitch ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[1], g_pitch ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[2], g2_code ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ + L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef BASOP_NOGLOB L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); @@ -3292,13 +3334,13 @@ void gain_enc_amr_wb_fx( * update table of past quantized energies *----------------------------------------------------------------*/ - past_qua_en[3] = past_qua_en[2]; + past_qua_en[3] = past_qua_en[2]; // Q10 move16(); - past_qua_en[2] = past_qua_en[1]; + past_qua_en[2] = past_qua_en[1]; // Q10 move16(); - past_qua_en[1] = past_qua_en[0]; + past_qua_en[1] = past_qua_en[0]; // Q10 move16(); - past_qua_en[0] = qua_ener; + past_qua_en[0] = qua_ener; // Q10 move16(); @@ -3306,7 +3348,7 @@ void gain_enc_amr_wb_fx( exp = s_max( exp, 0 ); tmp = div_s( shr( 8192, exp ), *gain_inov ); - *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); + *norm_gain_code = L_shr( Mult_32_16( *gain_code, tmp ), sub( 1, exp ) ); // Q16 move32(); push_indice_fx( hBstr, IND_GAIN, index, nBits ); diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index e7c66738847aeba5512e56f56b3fb895f45af8a3..7d046db5ff8c5601d00294cdb54ad60dd53717d3 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -1072,7 +1072,8 @@ ivas_error init_encoder_ivas_fx( } st->currEnergyHF_fx = 0; move32(); - + st->currEnergyHF_e_fx = 0; + move16(); #ifdef MSAN_FIX st->prevEnergyHF_fx = 0; move32(); diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 8177681ec65612ccc0ce363cc77550566e255b25..e1f138a84b4f8219a235de75b0a1da43cc672d27 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1135,7 +1135,7 @@ ivas_error ivas_compute_core_buffers_fx( * Compute Weighted Input *---------------------------------------------------------------*/ - ivas_find_wsp( 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 ); + 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 ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 3ed7d549af205c392e0cbcabad4e6adb833cdadc..cbff81a81183d9fbd47c5501e65df326d382d822 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1218,7 +1218,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); move16(); - ivas_find_wsp( 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 ); + 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 ); Word16 Q_wsp = *Q_new; move16(); diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index b16e7fb0349662217ab999f660977530de45f002..f1c6cb24a06a09caeac5783811c63f2352278687 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -702,7 +702,7 @@ ivas_error front_vad_spar_fx( st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); st->mem_wsp_q = Q_inp_12k8; move16(); - ivas_find_wsp( 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 ); + 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 ); IF( st->vad_flag == 0 ) { diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 52e5a76872f04e0034de431baa50ad9730df589b..d2873bdfe7e88bf25eb5895f58d9c713df02adc6 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1470,7 +1470,7 @@ void stereo_dft_enc_compute_itd_fx( move16(); FOR( Word16 ii = 0; ii < 11; ii++ ) { - L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[i + 1], Spd_L_e[i + 1], &L_temp_e ); + L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, Spd_L[ii + 1], Spd_L_e[ii + 1], &L_temp_e ); } // L_temp = sum2_32_fx( &Spd_L[1], 11, &L_temp_e ); sum_nrg_L_lb = BASOP_Util_Add_Mant32Exp( sum_nrg_L_lb, sum_nrg_L_lb_e, L_temp, L_temp_e, &sum_nrg_L_lb_e ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e9a09befcf34d98681ed09bdb645bb02ff8ead93..e0673b1cb99bfb3bba677e486fcd8004cae501f5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -263,37 +263,38 @@ void find_tilt_fx( Word16 find_uv_ivas_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 */ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ - 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 */ - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */ - const Word16 last_core_orig, /* i : original last core */ + 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 q_hp_E ); + 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*/ + 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*/ #ifdef IVAS_CODE Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ #endif - 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 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 */ + 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 */ + const Word16 last_core_orig /* i : original last core Q0*/ #ifdef IVAS_CODE , STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ @@ -511,17 +512,17 @@ void pitch_ol_init_fx( ); void Preemph_scaled( - Word16 new_speech[], /* i : Speech to scale already on 14 bits*/ - Word16 *Q_new, /* o : Scaling factor */ - Word16 *mem_preemph, /* i/o: Preemph memory */ - Word16 *Q_max, /* i/o: Q_new limitation */ - const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */ - const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/ - const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ - const Word16 L_Q_mem, /* i : Number of old scaling to take into account */ - const Word16 Lframe, /* i : Frame length */ - const Word16 last_coder_type, /* i : coder_type */ - const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/ + Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/ + Word16 *Q_new, /* o : Scaling factor */ + Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/ + Word16 *Q_max, /* i/o: Q_new limitation */ + const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/ + const Word16 bits, /* i : Bit to remove from the output to (15-bits) */ + const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ + const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/ + const Word16 Lframe, /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : coder_type Q0*/ + const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/ ); void Scale_mem_enc( @@ -537,17 +538,17 @@ void Scale_mem_enc( Word16 *old_input_lp ); Word32 Scale_mem_pre_proc( /* o : Min energy scaled */ - Word16 ini_frame_fx, /* i : Frame number */ + Word16 ini_frame_fx, /* i : Frame number Q0*/ Word16 Q_exp, /* i : Diff scaling factor */ Word16 *Q_new, /* i/o: Absolute scaling factor */ Word16 *old_speech, /* i/o: Speech memory */ - Word16 *mem_wsp, /* i/o: wsp vector memory */ - Word32 *enrO, /* i/o: Enr mem */ - Word32 *bckr, /* i/o: Back ground_fx ener mem */ - Word32 *ave_enr, /* i/o: Ave_enr mem */ - Word32 *ave_enr2, /* i/o: Ave_enr2 mem */ - Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */ - Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */ + Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/ + Word32 *enrO, /* i/o: Enr mem q_enrO*/ + Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/ + Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/ + Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/ + Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/ + Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/ Word32 *st_Bin_E_old ); void Scale_wsp( @@ -559,7 +560,7 @@ void Scale_wsp( Word16 *old_wsp, /* i/o: Old weighted speech buffer */ Word16 *mem_decim2, /* i/o: Decimation buffer */ Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */ - const Word16 Len_p_look /* i : L_frame + look ahead */ + const Word16 Len_p_look /* i : L_frame + look ahead Q0*/ ); Word16 signal_clas_fx( /* o : classification for current frames */ @@ -1810,12 +1811,12 @@ Word16 cng_energy_fx( ); void CNG_reset_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - LPD_state_HANDLE hLPDmemm, /* i/o: acelp memories */ - Word16 *pitch_buf, /* o : floating pitch for each subframe */ - Word16 *voice_factors /* o : voicing factors */ - , - Word16 VBR_cng_reset_flag ); + Encoder_State *st_fx, /* i/o: encoder state structure */ + LPD_state_HANDLE hLPDmem, /* i/o: acelp memories */ + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 VBR_cng_reset_flag /* Q0 */ +); void lsf_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -1842,14 +1843,14 @@ void lsf_enc_ivas_fx( const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); void Es_pred_enc_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */ - Word16 *indice, /* o : indice of quantization */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 *res, /* i : residual signal */ - const Word16 *voicing, /* i : normalized correlation in three 1/2frames */ - const Word16 nb_bits, /* i : allocated number of bits */ - const Word16 no_ltp, /* i : no_ltp flag */ - Word16 Q_new /* i : Scaling in speech Q0 */ + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + Word16 *indice, /* o : indice of quantization Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 *res, /* i : residual signal Q_new*/ + const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/ + const Word16 nb_bits, /* i : allocated number of bits Q0*/ + const Word16 no_ltp, /* i : no_ltp flag Q0*/ + Word16 Q_new /* i : Scaling in speech Q0*/ ); void encod_nelp_fx( @@ -3147,9 +3148,9 @@ void spec_flatness_fx( Word32 *spec_amp, /*(i) spectral amplitude*/ void SetModeIndex_fx( Encoder_State *st, - Word32 last_total_brate, - const Word16 last_element_mode, - const Word16 is_mct, + Word32 last_total_brate, /* Q0 */ + const Word16 last_element_mode, /* Q0 */ + const Word16 is_mct, /* Q0 */ const Word16 shift ); void MDCT_selector_fx( @@ -3208,10 +3209,10 @@ void IGFSCFEncoderRestoreContextState_fx( ); void frame_spec_dif_cor_rate_fx( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - Word32 *spec_amp, /* i : spectral amplitude*/ - Word16 sacle, /* i : the scaling of spec_amp*/ - Word16 f_tonality_rate[3] /* o : tonality rate*/ + VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ + Word32 *spec_amp, /* i : spectral amplitude scale*/ + Word16 sacle, /* i : the scaling of spec_amp */ + Word16 f_tonality_rate[3] /* o : tonality rate Qx*/ ); void est_energy_fx( @@ -3457,44 +3458,44 @@ Word16 inov_encode_ivas_fx( void gain_enc_mless_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 element_mode, /* i : element 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 */ - const Word16 *xn, /* i : target vector */ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation */ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word16 Es_pred, /* i : predicted scaled innovation energy */ - Word16 *gain_pit, /* o : quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */ + 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 gain_enc_mless_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 element_mode, /* i : element 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 */ - const Word16 *xn, /* i : target vector */ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation */ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word16 Es_pred, /* i : predicted scaled innovation energy */ - Word16 *gain_pit, /* o : quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */ + 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 */ @@ -3567,20 +3568,20 @@ void acelp_core_switch_enc_ivas_fx( Word16 Q_new ); void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector */ - const Word16 Q_xn, /* i : xn and yy1 format Q0 */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 *code, /* i : algebraic excitation */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */ - Word32 *gain_code, /* o : quantized codebook gain */ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */ + 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*/ ); @@ -3653,9 +3654,9 @@ void transf_cdbk_enc_ivas_fx( void gain_enc_lbr_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ + 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 */ @@ -3666,17 +3667,17 @@ void gain_enc_lbr_fx( 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 */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const Word16 L_subfr /* i : subframe length */ + 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*/ ); void gain_enc_lbr_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ + 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 */ @@ -3687,46 +3688,46 @@ void gain_enc_lbr_ivas_fx( 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 */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const int16_t L_subfr /* i : subframe length */ + 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*/ ); void gain_enc_SQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 i_subfr, /* i : subframe index */ - 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 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const Word16 Q_xn /* i : xn and y1 scaling */ + 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 gain_enc_SQ_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 i_subfr, /* i : subframe index */ - 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 */ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const Word16 Q_xn /* i : xn and y1 scaling */ + 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( @@ -3854,33 +3855,33 @@ void transf_cdbk_enc_fx( const Word16 shift /* i : shifting applied to y1, xn,... */ ); void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 xn_fx[], /* i : target vector */ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 code_fx[], /* i : algebraic excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */ - Word32 *gain_code_fx, /* o : quantized codebook gain */ - Word16 *gain_inov_fx, /* o : innovation gain */ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */ - const Word16 Q_xn /* i : xn and y1 scaling Q0 */ + 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 */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 xn_fx[], /* i : target vector */ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */ - const Word16 code_fx[], /* i : algebraic excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */ - Word32 *gain_code_fx, /* o : quantized codebook gain */ - Word16 *gain_inov_fx, /* o : innovation gain */ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */ - const Word16 Q_xn /* i : xn and y1 scaling Q0 */ + 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( @@ -3964,11 +3965,11 @@ void swb_bwe_enc_hr_fx( ); Word16 gain_enc_gaus_fx( /* o : Return index of quantization */ - Word32 *gain, /* i/o: Code gain to quantize */ - const Word16 bits, /* i : number of bits to quantize */ - 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 */ + 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 */ @@ -4650,14 +4651,14 @@ Word16 delta_pit_enc_fx( /* o : pitch index ); void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal */ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter */ - Word16 exc_fx[], /* o : adaptive codebook excitation */ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation */ - Word16 *imp_shape, /* o : adaptive codebook index */ - Word16 *imp_pos, /* o : position of the glotal impulse center index */ - Word32 *gain_trans_fx, /* o : transition gain Q7 */ - Word16 Q_new /* i : Current scaling */ + 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 */ ); Word16 abs_pit_enc_fx( /* o : pitch index */ diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c index 099940620cf6418683b6b04a2ceaccc3ec8d5e2b..e1f2442bc515d332408866e04caec69df6653d19 100644 --- a/lib_enc/rom_enc.c +++ b/lib_enc/rom_enc.c @@ -46,12 +46,12 @@ * VAD ROM tables *----------------------------------------------------------------------------------*/ -const int16_t hangover_hd_tbl[3] = {1, 1, 3}; -const int16_t hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2}; -const int16_t bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11}; -const int16_t bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12}; +const Word16 hangover_hd_tbl[3] = {1, 1, 3}; // Q0 +const Word16 hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2}; // Q0 +const Word16 bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11}; // Q0 +const Word16 bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12}; // Q0 -const int16_t BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} */ +const Word16 BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} Q0*/ typedef struct { Word16 r; @@ -76,16 +76,16 @@ const Word16 M_Wi_fix16[16] = 32609/* 9.9518473e-001f Q15 */,31356/* 9.5694034e-001f Q15 */,28898/* 8.8192126e-001f Q15 */,25329/* 7.7301045e-001f Q15 */,20787/* 6.3439328e-001f Q15 */,15446/* 4.7139674e-001f Q15 */, 9512/* 2.9028468e-001f Q15 */, 3212/* 9.8017140e-002f Q15 */ }; -const int16_t SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24}; +const Word16 SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24}; // Q0 /* 107374184.f = 32768.f * 32768.f * 0.1 */ -const int16_t NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9}; -const int16_t NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16}; -const int16_t NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; -const int16_t NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; +const Word16 NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9}; // Q0 +const Word16 NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16}; // Q0 +const Word16 NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 +const Word16 NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 const Word16 NREGION_PREOFF[12] = { 0,0,0,0,0,0,1,1,1,2,3,4 }; -const int16_t ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM}; -const int16_t * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB}; +const Word16 ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM}; // Q0 +const Word16 * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB}; // Q0 const Word32 MAX_LF_SNR_TAB_FX[5] = { 26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */,53687090/* 1.6 Q25 */,26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */ }; const Word32 COMVAD_INIT_SNR_DELTA_FX[5] = { 33554431/* 1.0 Q25 */, 20132659/* 0.6 Q25 */, 28856811/* 0.86 Q25 */, 38923139/* 1.16 Q25 */, 33554431/* 1.0 Q25 */ }; const Word32 LT_MIN_SILENCE_SNR_FX[4] = { 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */,150994940/* 4.5 Q25 */ }; @@ -106,12 +106,12 @@ const Word16 sqrt_han_window_fx[L_FFT / 2 + 1] = 31785, 31880, 31971, 32057, 32137, 32213, 32285, 32351, 32412, 32469, 32521, 32567, 32609, 32646, 32678, 32705, 32728, 32745, 32757, 32765, 32767 -}; +}; // Q15 /*----------------------------------------------------------------------------------* * Starting points for pulse position search in Algebraic innovation codebook *----------------------------------------------------------------------------------*/ -const int16_t tipos[40] = +const Word16 tipos[40] = { 0, 1, 2, 3, /* starting point &ipos[0], 1st iter */ 1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */ @@ -123,22 +123,22 @@ const int16_t tipos[40] = 3, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 0 /* end point for 28 pulses &ipos[39], 4th iter */ -}; +}; // Q0 /*----------------------------------------------------------------------------------* * Open-loop pitch tables *----------------------------------------------------------------------------------*/ -const int16_t nb_sect_12k8[3] = { 4, 4, 4 }; -const int16_t nb_subsect_12k8[3] = { 7, 7, 7 }; -const int16_t pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115}; +const Word16 nb_sect_12k8[3] = { 4, 4, 4 }; // Q0 +const Word16 nb_subsect_12k8[3] = { 7, 7, 7 }; // Q0 +const Word16 pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115}; // Q0 -const int16_t len_12k8[4] = { 40, 40, 62, 115 }; -const int16_t len1_12k8[4] = { 40, 50, 80, 115 }; -const int16_t sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 }; -const int16_t sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 }; -const int16_t sec_length_12k8[4] = { 7, 15, 30, 54 }; -const int16_t sec_length1_12k8[4] = { 10, 19, 37, 38 }; -const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 }; +const Word16 len_12k8[4] = { 40, 40, 62, 115 }; // Q0 +const Word16 len1_12k8[4] = { 40, 50, 80, 115 }; // Q0 +const Word16 sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 }; // Q0 +const Word16 sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 }; // Q0 +const Word16 sec_length_12k8[4] = { 7, 15, 30, 54 }; // Q0 +const Word16 sec_length1_12k8[4] = { 10, 19, 37, 38 }; // Q0 +const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 }; // Q15 const Word16 W_HIST_FX[DTX_HIST_SIZE] = { 13107, 10486, 8389, 6711, 5369, 4295, 3436, 687 }; /* Q16 */ const Word16 W_HIST_S_FX[DTX_HIST_SIZE] = { 20480, 11378, 8393, 6938, 6092, 5551, 5183, 5115 }; /* Q12 */ @@ -148,32 +148,32 @@ const Word16 preemphCompensation_fx[NB_BANDS] = { 19960/*9.7461f Q11*/, 19493/* * LSF quantizer *----------------------------------------------------------------------------------*/ -const int16_t lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 }; -const int16_t lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 }; +const Word16 lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 }; // Q0 +const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0 -const int16_t lsf_unified_fit_model_nb[4][16] = +const Word16 lsf_unified_fit_model_nb[4][16] = { {12506 , -17641 , -6444 , -6646 , -3523 , -2132 , -511 , -92 , 699 , 1062 , 2578 , 3564 , 3200 , -285 , 2928 , -250}, {20383 , 18855 , 8494 , 8062 , 8105 , 6211 , 5068 , 4408 , 3741 , 3458 , 2732 , 3174 , 2412 , 17421 , -21717 , 0}, {-717 , -617 , -144 , -117 , -229 , -144 , -141 , -98 , -92 , -69 , -51 , -87 , -37 , -3019 , 19864 , 8034}, {-2424 , 8999 , 5723 , 5629 , 4239 , 3423 , 2507 , 2019 , 1245 , 736 , -907 , -2237 , -2558 , -1979 , -652 , 1657} -}; +}; // Q0 -const int16_t lsf_unified_fit_model_wb[4][16] = +const Word16 lsf_unified_fit_model_wb[4][16] = { {8323 , -567 , 3402 , 1389 , 1437 , 1820 , 1407 , 1299 , 1292 , 1206 , 1031 , 928 , 898 , 832 , 840 , 681}, {24635 , 19605 , 9294 , 7407 , 6419 , 5459 , 4966 , 4189 , 3394 , 2964 , 2425 , 2110 , 2140 , 1972 , 1540 , 2252}, {-867 , -666 , -168 , -114 , -90 , -122 , -129 , -101 , -65 , -56 , -39 , -35 , -40 , -42 , -35 , -56}, {-2313 , 3035 , 1677 , 2854 , 2334 , 1232 , 1347 , 1034 , 863 , 707 , 886 , 891 , 432 , 357 , 206 , -310} -}; +}; // Q0 -const int16_t lsf_unified_fit_model_wbhb[4][16] = +const Word16 lsf_unified_fit_model_wbhb[4][16] = { {5312 , 1967 , 2914 , 1438 , 2595 , 1848 , 1980 , 2021 , 1535 , 1489 , 1651 , 1502 , 1447 , 1311 , 1353 , 1202}, {28135 , 16053 , 10129 , 7366 , 5898 , 5341 , 3290 , 2780 , 3146 , 2423 , 1613 , 1370 , 1294 , 1635 , 1105 , 1431}, {-615 , -308 , -147 , -119 , -104 , -105 , -30 , -28 , -50 , -39 , -15 , -14 , -14 , -21 , -19 , -29}, {1534 , 3569 , 3138 , 4023 , 2105 , 2023 , 2046 , 1264 , 1340 , 1067 , 780 , 547 , 188 , -540 , -722 , -479} -}; +}; // Q0 const Word32 Freq_Weight_Com_fx[160] = /*Q31 */ { 1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2147483647, @@ -240,7 +240,7 @@ const Word32 sm_means_fx[N_SMC_FEATURES] = { 114371648, 762918, 258533, 305622, 877131, 1071555, 1272603, 67350312, 1296274, -2461829, 1882791, -41135, -306269, 641721, 5859343, -}; +}; // Q20 const Word32 sm_scale_fx[N_SMC_FEATURES] = {//Q20 46789116, 166914, 66905, 70898, 117576, 108472, 96226, 17324576, @@ -257,12 +257,12 @@ const Word32 bcox_add_cnst_fx[N_SMC_FEATURES] = { 0, 0, -1886955264, -1559167616, 0, 0, 0, 0, -1672874752, 0, 0, 0, 0, 0, 0, -}; +}; // Q31 const Word32 bcox_lmbd_fx[N_SMC_FEATURES] = { 0, 0, -1426534784, -907320448, 0, 0, 0, 0, -1362524672, 0, 0, 0, 0, 0, 0, -}; +}; // Q31 const Word32 pca_mean_fx[N_SMC_FEATURES] = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -813,15 +813,15 @@ const Word32 lvm_noise_fx[N_MIXTURES] = }; /* Mel filterbank */ -const int16_t mel_fb_start[NB_MEL_BANDS] = +const Word16 mel_fb_start[NB_MEL_BANDS] = { 1, 1, 2, 3, 4, 5, 5, 7, 8, 9, 10, 11, 13, 14, 16, 17, 19, 21, 23, 25, 28, 30, 33, 35, 38, 41, 45, 48, 52, 56, 60, 65, 69, 74, 80, 86, 92, 98, 105, 112 -}; +}; // Q0 -const int16_t mel_fb_len[NB_MEL_BANDS] = +const Word16 mel_fb_len[NB_MEL_BANDS] = { 1, 2, 2, 2, 1, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 7, 7, 7, 8, 8, 9, 9, 9, 11, 12, 12, 12, 13, 14, 15, 16 -}; +}; // Q0 const Word32 mel_fb_fx[246] = { 1306887040, 840596608, 701826176, 1445657472, 297866656, 1849617024, 67613584, 2079870080, @@ -855,7 +855,7 @@ const Word32 mel_fb_fx[246] = 1556051584, 1278092800, 1002327744, 728722176, 457242624, 187856208, 28791110, 311244128, 591432000, 869390912, 1145155968, 1418761472, 1690241024, 1959627392, 2068014592, 1802719104, 1539422848, 1278095872, 1018709056, 761233728, 505641920, 251906256, -}; +}; // Q30 const Word32 dct_mtx_fx[NB_MEL_BANDS * NB_MEL_COEF] = { //Q31 479821728, 476863456, 470965184, 462163232, 450511904, 436083040, 418965536, 399264992, @@ -972,61 +972,61 @@ const Word32 thren_pg_fx[44] = 3444, }; /* Huffmann coding - searching thresholds for quantization of peak gains */ -const int16_t huffnorm_e[32] = +const Word16 huffnorm_e[32] = { 1062, 550, 314, 274, 273, 272, 156, 79, 69, 38, 18, 40, 5, 3, 0, 1, 3, 4, 11, 21, 41, 32, 35, 67, 133, 264, 530, 315, 551, 2126, 4254, 4255 -}; +}; // Q0 -const int16_t huffnorm_n[32] = +const Word16 huffnorm_n[32] = { 14831, 14830, 7414, 3706, 593, 927, 462, 297, 230, 116, 50, 36, 13, 8, 5, 1, 0, 2, 6, 7, 15, 19, 24, 56, 59, 51, 114, 117, 75, 149, 592, 1852 -}; +}; // Q0 -const int16_t huffsizn_e[32] = +const Word16 huffsizn_e[32] = { 13, 12, 11, 11, 11, 11, 10, 9, 9, 8, 7, 6, 5, 4, 3, 2, 2, 3, 4, 5, 6, 8, 8, 9, 10, 11, 12, 11, 12, 14, 15, 15 -}; +}; // Q0 -const int16_t huffsizn_n[32] = +const Word16 huffsizn_n[32] = { 14, 14, 13, 12, 10, 10, 9, 9, 8, 7, 7, 6, 5, 4, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 6, 7, 7, 7, 7, 8, 10, 11 -}; +}; // Q0 -const int16_t resize_huffnorm[32] = +const Word16 resize_huffnorm[32] = { 0, 0, 0, 0, 0, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 5, 11, 23, 47, 95, 191, 383, 767, 2047, 0, 0, 0, 0, 0, 0 -}; +}; // Q0 -const int16_t huffnorm[32] = +const Word16 huffnorm[32] = { 26, 58, 90, 122, 27, 59, 91, 123, 12, 28, 44, 60, 2, 6, 4, 6, 0, 2, 10, 14, 14, 30, 46, 62, 30, 62, 94, 126, 31, 63, 95, 127 -}; +}; // Q0 -const int16_t pgain_huffnorm[32] = +const Word16 pgain_huffnorm[32] = { 1, 1, 2, 3, 3, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 5, 3, 2, 3, 3, 4, 5, 0, 1 -}; +}; // Q0 -const int16_t hessize[8]= +const Word16 hessize[8]= { 7, 5, 3, 2, 1, 4, 6, 7 -}; +}; // Q0 -const int16_t hescode[8]= +const Word16 hescode[8]= { 11, 3, 1, 1, 1, 0, 4, 10 -}; +}; // Q0 /*----------------------------------------------------------------------------------* * BWD @@ -1053,15 +1053,15 @@ const Word16 hann_window_320_fx[BWD_TOTAL_WIDTH / 2] = 7761, 7796, 7830, 7863, 7894, 7923, 7951, 7978, 8003, 8026, 8048, 8068, 8087, 8105, 8121, 8135, 8147, 8158, 8168, 8176, 8182, 8187, 8190, 8192 -}; +}; // Q13 /*----------------------------------------------------------------------------------* * Starting line for the noise measurement in TCX. *----------------------------------------------------------------------------------*/ -const int16_t startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 }; +const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 }; // Q0 -const int16_t startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 }; +const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 }; // Q0 const Word32 LS_MIN_SILENCE_SNR[4] = { 251658233/* 7.5 Q25 */, 251658233/* 7.5 Q25 */, 228170137/* 6.8 Q25 */,228170137/* 6.8 Q25 */ }; @@ -1081,7 +1081,7 @@ const UWord8 E_ROM_tipos[40] = 3, 0, 1, 2, 0, 1, 2, 3, /* end point for 24 pulses &ipos[35], 4th iter */ 1, 2, 3, 0 /* end point for 36 pulses &ipos[39], 2nd iter */ -}; +}; // Q0 /* pow(3 * i + 1, 0.3) / pow(256 - 1, 0.3) */ const Word16 Weight[86] = @@ -1094,7 +1094,7 @@ const Word16 Weight[86] = 0x7D61, 0x7DDA, 0x7E51, 0x7EC8, 0x7F3E, 0x7FB3, 0x7FFF }; -const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} */ +const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} Q0*/ /* Inv possible delta used in gaus_enc (1.0/(1.0+delta*delta)) and delta = [1,7] */ const Word16 inv_delta_tab[7] = /*Q15*/ @@ -1195,4 +1195,4 @@ const complex_16 wnk_table_16[16] = { /* integer square (i*i) */ const Word16 int_sqr[17] = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256 -}; +}; // Q0 diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index 8479d5b4b296cf15d83c50212e6a6a48f0b0bc09..bad6e9f8644c7ac770aae1b9ff4ea3c1c63d66b5 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -45,141 +45,141 @@ /*----------------------------------------------------------------------------------* * General tables *----------------------------------------------------------------------------------*/ -extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window */ -extern const int16_t tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook */ -extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy */ -extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy */ +extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window Q15*/ +extern const Word16 tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook Q0*/ +extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q16*/ +extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q12*/ -extern const int16_t bwd_start_bin[]; -extern const int16_t bwd_end_bin[]; -extern const float h_fir[]; /* 2nd order fir filter for wsp, decimation by 2 */ -extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 */ -extern const Word16 preemphCompensation_fx[]; +extern const Word16 bwd_start_bin[]; // Q0 +extern const Word16 bwd_end_bin[]; // Q0 +extern const float h_fir[]; /* 2nd order fir filter for wsp, decimation by 2 */ +extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 Q15*/ +extern const Word16 preemphCompensation_fx[]; // Q11 /*----------------------------------------------------------------------------------* * VAD tables *----------------------------------------------------------------------------------*/ -extern const int16_t hangover_hd_tbl[3]; -extern const int16_t hangover_sf_tbl[6]; +extern const Word16 hangover_hd_tbl[3]; // Q0 +extern const Word16 hangover_sf_tbl[6]; // Q0 /*----------------------------------------------------------------------------------* * Open-loop pitch search tables *----------------------------------------------------------------------------------*/ -extern const int16_t nb_sect_12k8[]; -extern const int16_t nb_subsect_12k8[]; -extern const int16_t len_12k8[]; -extern const int16_t len1_12k8[]; -extern const int16_t sublen_12k8[]; -extern const int16_t sublen1_12k8[]; -extern const int16_t pit_max_12k8[]; -extern const int16_t sec_length_12k8[]; -extern const int16_t sec_length1_12k8[]; +extern const Word16 nb_sect_12k8[]; // Q0 +extern const Word16 nb_subsect_12k8[]; // Q0 +extern const Word16 len_12k8[]; // Q0 +extern const Word16 len1_12k8[]; // Q0 +extern const Word16 sublen_12k8[]; // Q0 +extern const Word16 sublen1_12k8[]; // Q0 +extern const Word16 pit_max_12k8[]; // Q0 +extern const Word16 sec_length_12k8[]; // Q0 +extern const Word16 sec_length1_12k8[]; // Q0 /*----------------------------------------------------------------------------------* * LSF quantizer *----------------------------------------------------------------------------------*/ -extern const int16_t lsf_numlevels[TCXLPC_NUMSTAGES]; -extern const int16_t lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES]; +extern const Word16 lsf_numlevels[TCXLPC_NUMSTAGES]; // Q0 +extern const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES]; // Q0 -extern const int16_t lsf_unified_fit_model_nb[4][16]; -extern const int16_t lsf_unified_fit_model_wb[4][16]; -extern const int16_t lsf_unified_fit_model_wbhb[4][16]; -extern const Word32 Freq_Weight_Com_fx[160]; -extern const Word32 Freq_Weight_UV_fx[160]; +extern const Word16 lsf_unified_fit_model_nb[4][16]; // Q0 +extern const Word16 lsf_unified_fit_model_wb[4][16]; // Q0 +extern const Word16 lsf_unified_fit_model_wbhb[4][16]; // Q0 +extern const Word32 Freq_Weight_Com_fx[160]; // Q31 +extern const Word32 Freq_Weight_UV_fx[160]; // Q31 /*----------------------------------------------------------------------------------* * Speech/music classification *----------------------------------------------------------------------------------*/ -extern const Word16 w_spmus_fx[HANG_LEN][HANG_LEN]; -extern const Word32 pca_components_fx[]; +extern const Word16 w_spmus_fx[HANG_LEN][HANG_LEN]; // Q15 +extern const Word32 pca_components_fx[]; // Q31 extern const Word32 pca_mean_fx[]; -extern const Word32 sm_means_fx[]; -extern const Word32 sm_scale_fx[]; -extern const Word32 bcox_lmbd_fx[N_SMC_FEATURES]; -extern const Word32 hout_intervals_fx[]; -extern const Word32 bcox_add_cnst_fx[N_SMC_FEATURES]; -extern const Word32 prec_chol_speech_fx[]; -extern const Word32 prec_chol_music_fx[]; -extern const Word32 prec_chol_noise_fx[]; -extern const Word32 means_speech_fx[]; // Q20 -extern const Word32 means_music_fx[]; // Q20 -extern const Word32 means_noise_fx[]; // Q20 -extern const Word32 mel_fb_fx[]; -extern const Word32 dct_mtx_fx[]; -extern const Word32 log_det_chol_speech_fx[]; // Q19 -extern const Word32 log_det_chol_music_fx[]; // Q19 -extern const Word32 log_det_chol_noise_fx[]; // Q19 -extern const Word16 m_speech_fx[]; -extern const Word32 invV_speech_fx[]; -extern const Word32 lvm_speech_fx[]; - -extern const Word32 prec_chol_speech_fx[]; -extern const Word32 prec_chol_music_fx[]; -extern const Word32 prec_chol_noise_fx[]; -extern const Word16 m_music_fx[]; -extern const Word32 invV_music_fx[]; -extern const Word32 lvm_music_fx[]; -extern const Word16 m_noise_fx[]; -extern const Word32 invV_noise_fx[]; -extern const Word32 lvm_noise_fx[]; - -extern const int16_t mel_fb_start[]; -extern const int16_t mel_fb_len[]; -extern const Word16 hann_window_320_fx[]; +extern const Word32 sm_means_fx[]; // Q20 +extern const Word32 sm_scale_fx[]; // Q20 +extern const Word32 bcox_lmbd_fx[N_SMC_FEATURES]; // Q31 +extern const Word32 hout_intervals_fx[]; // Q20 +extern const Word32 bcox_add_cnst_fx[N_SMC_FEATURES]; // Q31 +extern const Word32 prec_chol_speech_fx[]; // Q28 +extern const Word32 prec_chol_music_fx[]; // Q28 +extern const Word32 prec_chol_noise_fx[]; // Q28 +extern const Word32 means_speech_fx[]; // Q20 +extern const Word32 means_music_fx[]; // Q20 +extern const Word32 means_noise_fx[]; // Q20 +extern const Word32 mel_fb_fx[]; // Q30 +extern const Word32 dct_mtx_fx[]; // Q31 +extern const Word32 log_det_chol_speech_fx[]; // Q19 +extern const Word32 log_det_chol_music_fx[]; // Q19 +extern const Word32 log_det_chol_noise_fx[]; // Q19 +extern const Word16 m_speech_fx[]; // Q15 +extern const Word32 invV_speech_fx[]; // Q10 +extern const Word32 lvm_speech_fx[]; // Q10 + +extern const Word32 prec_chol_speech_fx[]; // Q28 +extern const Word32 prec_chol_music_fx[]; // Q28 +extern const Word32 prec_chol_noise_fx[]; // Q28 +extern const Word16 m_music_fx[]; // Q15 +extern const Word32 invV_music_fx[]; // Q10 +extern const Word32 lvm_music_fx[]; // Q10 +extern const Word16 m_noise_fx[]; // Q15 +extern const Word32 invV_noise_fx[]; // Q10 +extern const Word32 lvm_noise_fx[]; // Q10 + +extern const Word16 mel_fb_start[]; // Q0 +extern const Word16 mel_fb_len[]; // Q0 +extern const Word16 hann_window_320_fx[]; // Q13 /*----------------------------------------------------------------------------------* * Huffman coding *----------------------------------------------------------------------------------*/ -extern const int16_t huffsizn_e[32]; -extern const int16_t huffsizn_n[32]; +extern const Word16 huffsizn_e[32]; // Q0 +extern const Word16 huffsizn_n[32]; // Q0 -extern const int16_t huffnorm_e[32]; -extern const int16_t huffnorm_n[32]; -extern const int16_t hessize[8]; -extern const int16_t hescode[8]; +extern const Word16 huffnorm_e[32]; // Q0 +extern const Word16 huffnorm_n[32]; // Q0 +extern const Word16 hessize[8]; // Q0 +extern const Word16 hescode[8]; // Q0 /*----------------------------------------------------------------------------------* * VAD *----------------------------------------------------------------------------------*/ -extern const int16_t BAND_NUM_TAB[5]; +extern const Word16 BAND_NUM_TAB[5]; // Q0 extern const complex_16 M_in_fix16[16]; -extern const Word16 M_Wr_fix16[16]; -extern const Word16 M_Wi_fix16[16]; -extern const int16_t SP_CENTER_BAND_NUM_TAB[5]; -extern const int16_t NREGION_INDEX_NB[9]; -extern const int16_t NREGION_INDEX_WB[13]; -extern const int16_t NREGION_INDEX_SWB[16]; -extern const int16_t NREGION_INDEX_FB[16]; -extern const Word16 NREGION_PREOFF[16]; -extern const int16_t ENERGY_BAND_NUM[4]; -extern const int16_t *REGION_INDEX[4]; -extern const Word32 MAX_LF_SNR_TAB_FX[4]; -extern const Word32 COMVAD_INIT_SNR_DELTA_FX[5]; -extern const Word32 LT_MIN_SILENCE_SNR_FX[4]; +extern const Word16 M_Wr_fix16[16]; // Q15 +extern const Word16 M_Wi_fix16[16]; // Q15 +extern const Word16 SP_CENTER_BAND_NUM_TAB[5]; // Q0 +extern const Word16 NREGION_INDEX_NB[9]; // Q0 +extern const Word16 NREGION_INDEX_WB[13]; // Q0 +extern const Word16 NREGION_INDEX_SWB[16]; // Q0 +extern const Word16 NREGION_INDEX_FB[16]; // Q0 +extern const Word16 NREGION_PREOFF[16]; // Q0 +extern const Word16 ENERGY_BAND_NUM[4]; // Q0 +extern const Word16 *REGION_INDEX[4]; // Q0 +extern const Word32 MAX_LF_SNR_TAB_FX[4]; // Q25 +extern const Word32 COMVAD_INIT_SNR_DELTA_FX[5]; // Q25 +extern const Word32 LT_MIN_SILENCE_SNR_FX[4]; // Q25 /*----------------------------------------------------------------------------------* * Starting line for the noise measurement in TCX. *----------------------------------------------------------------------------------*/ -extern const int16_t startLineWB[N_TCX_STARTLINE_NOISE_WB]; -extern const int16_t startLineSWB[N_TCX_STARTLINE_NOISE_SWB]; +extern const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB]; // Q0 +extern const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB]; // Q0 // EVS basop -extern const Word32 LS_MIN_SILENCE_SNR[4]; -extern const Word16 SNR_SUB_BAND_NUM[4]; -extern const Word16 BAND_MUL[4]; +extern const Word32 LS_MIN_SILENCE_SNR[4]; // Q25 +extern const Word16 SNR_SUB_BAND_NUM[4]; // Q0 +extern const Word16 BAND_MUL[4]; // Q15 -extern const UWord8 E_ROM_tipos[]; /* ACELP indexing */ +extern const UWord8 E_ROM_tipos[]; /* ACELP indexing Q0*/ extern const Word16 Weight[86]; -extern const Word16 BAND_SCALE_AJ[5]; -extern const Word16 inv_delta_tab[7]; +extern const Word16 BAND_SCALE_AJ[5]; // Q0 +extern const Word16 inv_delta_tab[7]; // Q15 extern const Word16 i_t_1[10]; extern const Word16 i_t_2[23]; extern const Word16 SF_mult_fx[N_FEATURES]; diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c deleted file mode 100644 index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000 --- a/lib_enc/rst_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c index 85821ef0b028b6e360b6a57d40979f86ecd85985..d519bc12f9db4e464b977c66e13b329713fb216e 100644 --- a/lib_enc/rst_enc_fx.c +++ b/lib_enc/rst_enc_fx.c @@ -20,14 +20,15 @@ void CNG_reset_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ LPD_state_HANDLE hLPDmem, /* i/o: acelp memories */ - Word16 *pitch_buf, /* o : floating pitch for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 VBR_cng_reset_flag ) + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 VBR_cng_reset_flag /* Q0 */ +) { TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; init_gp_clip_fx( st_fx->clip_var_fx ); - Copy( UVWB_Ave_fx, st_fx->mem_AR_fx, M ); + Copy( UVWB_Ave_fx, st_fx->mem_AR_fx, M ); /* Qlog2(2.56) */ set16_fx( st_fx->mem_MA_fx, 0, M ); hLPDmem->mem_w0 = 0; move16(); diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index cfb3568bb669ed9fa5279c0f59236dfc84d98689..a7119b41f797ca4c9e5b386ba407610c1eed41d7 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -24,7 +24,7 @@ void Scale_wsp( Word16 *old_wsp, /* i/o: Old weighted speech buffer */ Word16 *mem_decim2, /* i/o: Decimation buffer */ Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */ - const Word16 Len_p_look /* i : L_frame + look ahead */ + const Word16 Len_p_look /* i : L_frame + look ahead Q0*/ ) { Word16 max, i, tmp; @@ -69,17 +69,17 @@ void Scale_wsp( * Find scaled preemphasis vector and its scaling factor *-------------------------------------------------------------------*/ void Preemph_scaled( - Word16 new_speech[], /* i : Speech to scale already on 14 bits*/ - Word16 *Q_new, /* o : Scaling factor */ - Word16 *mem_preemph, /* i/o: Preemph memory */ - Word16 *Q_max, /* i/o: Q_new limitation */ - const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */ - const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/ - const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ - const Word16 L_Q_mem, /* i : Number of old scaling to take into account */ - const Word16 Lframe, /* i : Frame length */ - const Word16 last_coder_type, /* i : coder_type */ - const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/ + Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/ + Word16 *Q_new, /* o : Scaling factor */ + Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/ + Word16 *Q_max, /* i/o: Q_new limitation */ + const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/ + const Word16 bits, /* i : Bit to remove from the output to (15-bits) */ + const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ + const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/ + const Word16 Lframe, /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : coder_type Q0*/ + const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/ ) { Word16 i, tmp_fixed; @@ -88,6 +88,7 @@ void Preemph_scaled( Word16 Q_min; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /*---------------------------------------------------------------* @@ -170,7 +171,7 @@ void Preemph_scaled( * Done backwards to save storage space *---------------------------------------------------------------*/ - tmp_fixed = new_speech[Lframe - 1]; + tmp_fixed = new_speech[Lframe - 1]; // Q_new move16(); FOR( i = sub( Lframe, 1 ); i > 0; i-- ) @@ -183,7 +184,7 @@ void Preemph_scaled( #endif /* BASOP_NOGLOB */ L_tmp = L_shl( L_tmp, *Q_new ); #ifdef BASOP_NOGLOB - new_speech[i] = round_fx_sat( L_tmp ); + new_speech[i] = round_fx_sat( L_tmp ); // Q_new #else new_speech[i] = round_fx( L_tmp ); #endif @@ -208,17 +209,17 @@ void Preemph_scaled( * Rescale memories *-------------------------------------------------------------------*/ Word32 Scale_mem_pre_proc( /* o : Min energy scaled */ - Word16 ini_frame_fx, /* i : Frame number */ + Word16 ini_frame_fx, /* i : Frame number Q0*/ Word16 Q_exp, /* i : Diff scaling factor */ Word16 *Q_new, /* i/o: Absolute scaling factor */ Word16 *old_speech, /* i/o: Speech memory */ - Word16 *mem_wsp, /* i/o: wsp vector memory */ - Word32 *enrO, /* i/o: Enr mem */ - Word32 *bckr, /* i/o: Back ground_fx ener mem */ - Word32 *ave_enr, /* i/o: Ave_enr mem */ - Word32 *ave_enr2, /* i/o: Ave_enr2 mem */ - Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */ - Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */ + Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/ + Word32 *enrO, /* i/o: Enr mem q_enrO*/ + Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/ + Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/ + Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/ + Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/ + Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/ Word32 *st_Bin_E_old ) { Word16 i; diff --git a/lib_enc/set_impulse.c b/lib_enc/set_impulse.c deleted file mode 100644 index fd4f3cb7c53af6bc1a4a149c6db6799b8f39655e..0000000000000000000000000000000000000000 --- a/lib_enc/set_impulse.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index ebdfe868973b39312baa154696c596ea89192f0c..90a405d7cf70b49279cdf803f1c28b9df0329d1a 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -47,14 +47,14 @@ static void convolve_tc2_fx( const Word16 g[], const Word16 h[], Word16 y[], con * * *---------------------------------------------------------------------------------------*/ void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal */ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter */ - Word16 exc_fx[], /* o : adaptive codebook excitation */ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation */ - Word16 *imp_shape, /* o : adaptive codebook index */ - Word16 *imp_pos, /* o : position of the glottal impulse center index */ - Word32 *gain_trans_fx, /* o : transition gain Q7 */ - Word16 Q_new /* i : Current scaling */ + 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 */ ) { Word16 i, j, m; @@ -67,6 +67,7 @@ void set_impulse_fx( const Word16 *pt_Glt; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif krit_max_fx = -32768; move16(); @@ -78,7 +79,7 @@ void set_impulse_fx( /* set searching ranges */ IF( LT_16( *imp_pos, L_SUBFR - INPOL ) ) { - end1 = add( *imp_pos, INPOL ); + end1 = add( *imp_pos, INPOL ); // Q0 } ELSE { @@ -87,7 +88,7 @@ void set_impulse_fx( } IF( GT_16( *imp_pos, INPOL ) ) { - start1 = sub( *imp_pos, INPOL ); + start1 = sub( *imp_pos, INPOL ); // Q0 } ELSE { @@ -119,8 +120,8 @@ void set_impulse_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef BASOP_NOGLOB - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 #else Lrr = L_mac( Lrr, gh_fx[i], gh_fx[i] ); Ldd = L_mac( Ldd, gh_fx[i], xn_fx[i] ); @@ -129,7 +130,7 @@ void set_impulse_fx( rr_fx[start1] = Lrr; move32(); #ifdef BASOP_NOGLOB - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #else dd_fx[start1] = round_fx( Ldd ); #endif @@ -144,24 +145,24 @@ void set_impulse_fx( { /* gh_fx[j] = gh_fx[j-1] + glottal_cdbk[m*L_IMPULSE+L_IMPULSE2-i]*h_orig_fx[j] */ gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), - Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); + Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); #ifdef BASOP_NOGLOB - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); -#else /* BASOP_NOGLOB */ + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 +#else /* BASOP_NOGLOB */ Lrr = L_mac( Lrr, gh_fx[j], gh_fx[j] ); Ldd = L_mac( Ldd, gh_fx[j], xn_fx[j] ); -#endif /* BASOP_NOGLOB */ +#endif /* BASOP_NOGLOB */ } - gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); + gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); #ifdef BASOP_NOGLOB - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); - dd_fx[i] = round_fx_sat( Ldd ); -#else /* BASOP_NOGLOB */ + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 + dd_fx[i] = round_fx_sat( Ldd ); // Q11 +#else /* BASOP_NOGLOB */ Lrr = L_mac( Lrr, gh_fx[0], gh_fx[0] ); Ldd = L_mac( Ldd, gh_fx[0], xn_fx[0] ); dd_fx[i] = round_fx( Ldd ); @@ -175,7 +176,7 @@ void set_impulse_fx( FOR( j = L_SUBFR - 1; j > 0; j-- ) { gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), - Glottal_cdbk_fx[m * L_IMPULSE], h_orig_fx[j] ); + Glottal_cdbk_fx[m * L_IMPULSE], h_orig_fx[j] ); // Q13 } } ELSE @@ -186,12 +187,12 @@ void set_impulse_fx( IF( GE_16( end1, start2 ) ) { /* DEnominator row */ - Lrr = L_mult( gh_fx[0], gh_fx[0] ); + Lrr = L_mult( gh_fx[0], gh_fx[0] ); // Q27 FOR( j = 1; j <= L_IMPULSE2; j++ ) { /*rr[L_SUBFR-1] += gh[j]*gh[j];*/ #ifdef BASOP_NOGLOB - Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); + Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 #else Lrr = L_mac( Lrr, gh_fx[j], gh_fx[j] ); #endif @@ -204,7 +205,7 @@ void set_impulse_fx( /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ #ifdef BASOP_NOGLOB rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], - gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); + gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 #else rr_fx[i] = L_mac( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); @@ -237,7 +238,7 @@ void set_impulse_fx( IF( GT_16( krit_fx, krit_max_fx ) ) { - krit_max_fx = krit_fx; + krit_max_fx = krit_fx; // Q18 move16(); *imp_pos = i; move16(); @@ -254,7 +255,7 @@ void set_impulse_fx( set16_fx( exc_fx, 0, L_SUBFR ); set16_fx( yy1_fx, 0, L_SUBFR ); tmp16 = sub( extract_l( L_mac0( L_IMPULSE2, *imp_shape, L_IMPULSE ) ), *imp_pos ); - pt_Glt = &Glottal_cdbk_fx[tmp16]; + pt_Glt = &Glottal_cdbk_fx[tmp16]; // Q13 move16(); j = add( *imp_pos, L_IMPULSE2 ); FOR( i = sub( *imp_pos, L_IMPULSE2 ); i <= j; i++ ) @@ -290,9 +291,9 @@ void set_impulse_fx( gain16 = div_s( num, den ); i = add( exp_num, sub( Q_new, 1 + 1 + 3 ) ); - i = sub( i, exp_den ); /* Gain_trans in Q7 */ - gain16 = i_mult2( gain16, tmp16 ); /* apply sign */ - *gain_trans_fx = L_shr( L_deposit_l( gain16 ), i ); + i = sub( i, exp_den ); /* Gain_trans in Q7 */ + gain16 = i_mult2( gain16, tmp16 ); /* apply sign */ + *gain_trans_fx = L_shr( L_deposit_l( gain16 ), i ); // Q7 move32(); } /*-------------------------------------------------------------------* @@ -304,8 +305,8 @@ static void convolve_tc_fx( const Word16 g[], /* i : input vector Qx */ const Word16 h[], /* i : impulse response (or second input vector) Q15 */ Word16 y[], /* o : output vector (result of convolution) 12 bits */ - const Word16 L_1, /* i : vector h size */ - const Word16 L_2 /* i : vector g size */ + const Word16 L_1, /* i : vector h size Q0 */ + const Word16 L_2 /* i : vector g size Q0 */ ) { Word16 i, n, len; @@ -314,13 +315,13 @@ static void convolve_tc_fx( FOR( n = 0; n < L_2; n++ ) { len = s_min( add( n, 1 ), L_1 ); - L_sum = L_mult( g[0], h[n] ); + L_sum = L_mult( g[0], h[n] ); /* Qx */ FOR( i = 1; i < len; i++ ) { - L_sum = L_mac( L_sum, g[i], h[n - i] ); + L_sum = L_mac( L_sum, g[i], h[n - i] ); /* Qx + 16 */ } - y[n] = round_fx( L_sum ); /* Q12*/ + y[n] = round_fx( L_sum ); /* Qx */ } } /*-------------------------------------------------------------------* @@ -332,29 +333,29 @@ static void convolve_tc2_fx( const Word16 g[], /* i : input vector Qx */ const Word16 h[], /* i : impulse response (or second input vector) Q15 */ Word16 y[], /* o : output vector (result of convolution) 12 bits */ - const Word16 pos_max /* o : artificial impulse position */ + const Word16 pos_max /* o : artificial impulse position Q0 */ ) { Word32 temp; Word16 i, n; Word16 i_start, i_end, i_end2; - i_start = sub( pos_max, L_IMPULSE2 ); + i_start = sub( pos_max, L_IMPULSE2 ); // Q0 i_start = s_max( i_start, 0 ); - i_end = add( pos_max, L_IMPULSE ); + i_end = add( pos_max, L_IMPULSE ); // Q0 i_end = s_min( i_end, L_SUBFR ); FOR( n = i_start; n < L_SUBFR; n++ ) { - temp = L_mult( g[0], h[n] ); + temp = L_mult( g[0], h[n] ); /* Qx + 16 */ i_end2 = s_min( add( n, 1 ), i_end ); FOR( i = 1; i < i_end2; i++ ) { - temp = L_mac( temp, g[i], h[n - i] ); + temp = L_mac( temp, g[i], h[n - i] ); // Qx + 16 } - y[n] = round_fx( temp ); + y[n] = round_fx( temp ); // Qx } } /*-------------------------------------------------------------------* @@ -363,12 +364,12 @@ static void convolve_tc2_fx( * correlation for different vectors' lengths *-------------------------------------------------------------------*/ static void correlate_tc_fx( - const Word16 *x, /* i: target signal */ - Word16 *y, /* o: correlation between x[] and h[] -Q3 */ - const Word16 *h, /* i: impulse response (of weighted synthesis filter) */ - const Word16 start, /* i: index of iterest */ - const Word16 L_1, /* i: vector size */ - const Word16 L_2 /* i: index of interest */ + const Word16 *x, /* i: target signal Qx*/ + Word16 *y, /* o: correlation between x[] and h[] -Q3*/ + const Word16 *h, /* i: impulse response (of weighted synthesis filter) Q15*/ + const Word16 start, /* i: index of iterest Q0*/ + const Word16 L_1, /* i: vector size Q0*/ + const Word16 L_2 /* i: index of interest Q0*/ ) { Word16 i, j; @@ -380,13 +381,13 @@ static void correlate_tc_fx( FOR( j = i; j < L_1; j++ ) { #ifdef BASOP_NOGLOB - s = L_mac_sat( s, x[j], h[j - i] ); + s = L_mac_sat( s, x[j], h[j - i] ); /* Qx + 16 */ #else s = L_mac( s, x[j], h[j - i] ); #endif } #ifdef BASOP_NOGLOB - y[i] = round_fx_sat( s ); + y[i] = round_fx_sat( s ); /* Qx */ #else y[i] = round_fx( s ); #endif diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c index 8c2130280a4b05b2e28e395bc076bb63ed98778f..1cc6168c38f3cdd3925f9c0cb17afa3e21aefa0b 100644 --- a/lib_enc/setmodeindex.c +++ b/lib_enc/setmodeindex.c @@ -54,12 +54,12 @@ void SetModeIndex_ivas_fx( Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word16 last_element_mode, /* i : last IVAS element mode */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ + 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*/ ) { - Word16 ini_frame_loc = st->ini_frame; + Word16 ini_frame_loc = st->ini_frame; // Q0 move16(); test(); @@ -85,12 +85,12 @@ void SetModeIndex_ivas_fx( ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) || - ( GT_16( st->element_mode, EVS_MONO ) && st->ini_frame == 0 ) ) + ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) { core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); } - st->ini_frame = ini_frame_loc; + st->ini_frame = ini_frame_loc; // Q0 move16(); return; diff --git a/lib_enc/setmodeindex_fx.c b/lib_enc/setmodeindex_fx.c index dff13ec8964ba2be52e6649edb3e78c08ff5fdfa..fc3025f5132805d4827637794a00375fb9202f2d 100644 --- a/lib_enc/setmodeindex_fx.c +++ b/lib_enc/setmodeindex_fx.c @@ -4,7 +4,6 @@ #include #include "options.h" -//#include "prot_fx.h" #include "cnst.h" #include "rom_com_fx.h" #include "rom_enc.h" @@ -23,12 +22,12 @@ void SetModeIndex_fx( Encoder_State *st, - Word32 last_total_brate, - const Word16 last_element_mode, - const Word16 is_mct, + Word32 last_total_brate, /* Q0 */ + const Word16 last_element_mode, /* Q0 */ + const Word16 is_mct, /* Q0 */ const Word16 shift ) { - Word16 ini_frame_loc = st->ini_frame; + Word16 ini_frame_loc = st->ini_frame; // Q0 test(); test(); @@ -52,7 +51,7 @@ void SetModeIndex_fx( { core_coder_mode_switch_fx( st, last_total_brate, is_mct, shift ); } - st->ini_frame = ini_frame_loc; + st->ini_frame = ini_frame_loc; // Q0 return; } diff --git a/lib_enc/sig_clas.c b/lib_enc/sig_clas.c deleted file mode 100644 index 0828accec986944779b557c4d45118d355476c85..0000000000000000000000000000000000000000 --- a/lib_enc/sig_clas.c +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - -#define K_COR_ENC 2.857f -#define C_COR_ENC -1.286f -#define K_EE_ENC 0.04167f -#define C_EE_ENC 0.0f -#define K_ZC_ENC -0.04f -#define C_ZC_ENC 2.4f -#define K_RELE_ENC 0.05f -#define C_RELE_ENC 0.45f -#define K_PC_ENC -0.07143f -#define C_PC_ENC 1.857f -#define K_SNR_ENC 0.1111f -#define C_SNR_ENC -0.3333f diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 317789ee228dd7655aa31461b38fcfebf0d3b7c1..bb977b432ecc2b0a6bc72f5775a7f9227452a986 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -684,7 +684,7 @@ void SetTCXModeInfo_ivas_fx( test(); test(); /* window switching based on transient detector output */ - IF( ( ( hTranDet->transientDetector.bIsAttackPresent ) || ( GT_32( Mpy_32_32( st->currEnergyHF_fx, 55063683 /*1.0f/39.0f Q31*/ ), st->prevEnergyHF_fx ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) ) && + IF( ( ( hTranDet->transientDetector.bIsAttackPresent ) || ( EQ_32( BASOP_Util_Cmp_Mant32Exp( Mpy_32_32( st->currEnergyHF_fx, 55063683 /*1.0f/39.0f Q31*/ ), st->currEnergyHF_e_fx, st->prevEnergyHF_fx, 17 ), 1 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) ) && ( ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) ) { hTcxEnc->tcxMode = TCX_10;