Loading lib_com/cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -1818,7 +1818,9 @@ typedef enum _DCTTYPE #define CNA_INIT_NBANDS 6 #define GAIN_Q_OFFSET_EVS 60.f #define GAIN_Q_OFFSET_EVS_FX_Q0 60 #define GAIN_Q_OFFSET_IVAS 45.f #define GAIN_Q_OFFSET_IVAS_FX_Q0 45 /*----------------------------------------------------------------------------------* * Bass post-filter constants Loading lib_dec/FEC_adapt_codebook_fx.c +16 −15 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ Word16 FEC_SinOnset_fx( P0 = PIT_MAX; move16(); /* Should never be the case, however... */ } ELSE if ( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) ELSE IF( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) { P0 = PIT16k_MAX; move16(); /* Should never be the case, however... */ Loading Loading @@ -134,13 +134,11 @@ Word16 FEC_SinOnset_fx( { L_tmp = L_mult( gain, H_low[i] ); /* Q_exc*Q15 -> Q_exc */ H_low_s[i] = round_fx( L_shl( L_tmp, exp2 ) ); move16(); } /*------------------------------------------------------------------------------------------* * Construct the harmonic part as a train of low-pass filtered pulses *------------------------------------------------------------------------------------------*/ move16(); move16(); move16(); pt_exc = exc_tmp + sub( L_frame, add( add( 1, MODE1_L_FIR_FER / 2 ), P0 ) ); /* beginning of the 1st pulse */ pt_end = exc_tmp + onset_len; len = (Word16) ( pt_exc - pt_end ); Loading @@ -165,7 +163,7 @@ Word16 FEC_SinOnset_fx( move16(); } } Copy( &exc_tmp[L_frame - L_EXC_MEM], exc, L_EXC_MEM ); Copy( &exc_tmp[sub( L_frame, L_EXC_MEM )], exc, L_EXC_MEM ); return Q_exc; } Loading @@ -191,7 +189,7 @@ Word16 FEC_enhACB_fx( Copy( exc_io, exc + L_FRAME16k - L_EXC_MEM, L_EXC_MEM ); Tc = shr( bfi_pitch, 6 ); Copy( exc + L_FRAME16k - Tc, exc + L_FRAME16k, L_SUBFR ); Copy( exc + sub( L_FRAME16k, Tc ), exc + L_FRAME16k, L_SUBFR ); /*------------------------------------------------------------ * Decode phase information transmitted in the bitstream Loading Loading @@ -229,6 +227,7 @@ Word16 FEC_enhACB_fx( move16(); Tlist[0] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), pit_search, DEC, &sign ); move16(); /*Terr = (short) abs(pit_search-Tlist[0]-P0);*/ Terr = abs_s( sub( pit_search, add( Tlist[0], P0 ) ) ); Loading @@ -236,6 +235,7 @@ Word16 FEC_enhACB_fx( dist_Plast = sub( Tc, Tlist[0] ); Tlist[1] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), add( pit_search, L_SUBFR ), DEC, &sign ); move16(); /*if(Terr > abs(Tlist[1]-Tc + P0))*/ Loading @@ -256,7 +256,6 @@ Word16 FEC_enhACB_fx( { /* performe excitation resynchronization here */ Do_WI = FEC_synchro_exc_fx( L_frame, exc, P0, dist_Plast, Tc ); move16(); Copy( exc + L_FRAME16k - L_EXC_MEM, exc_io, L_EXC_MEM ); } ELSE Loading Loading @@ -350,15 +349,16 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag * --------------------------------------------------------------------*/ L_min_energy = L_add( MAX_32, 0 ); L_tmp = L_mult( pt_exc[start_search], pt_exc[start_search] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 1], pt_exc[start_search + 1] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 2], pt_exc[start_search + 2] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 3], pt_exc[start_search + 3] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 4], pt_exc[start_search + 4] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 1 )], pt_exc[add( start_search, 1 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 2 )], pt_exc[add( start_search, 2 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 3 )], pt_exc[add( start_search, 3 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 4 )], pt_exc[add( start_search, 4 )] ); IF( LT_32( L_tmp, L_min_energy ) ) { L_min_energy = L_add( L_tmp, 0 ); min_pos[0] = add( add( pos, start_search ), 2 ); move16(); } FOR( i = start_search; i < -5; i++ ) Loading @@ -371,6 +371,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag L_min_energy = L_tmp; /* sets to 'L_tmp' in 1 clock */ move32(); min_pos[0] = add( add( pos, i ), 2 ); move16(); } } Loading Loading @@ -407,13 +408,15 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag nb_min = 1; move16(); points_by_pos[0] = abs_s( point_to_remove ); move16(); } ELSE { /* First position */ /* fact = (float)fabs(point_to_remove) / sqi[nb_min-2]; (nb_min*nb_min) */ fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[nb_min - 2] ); /*Q7 */ fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[sub( nb_min, 2 )] ); /*Q7 */ points_by_pos[0] = mult_r( fact, 256 ); /*Q7 */ move16(); total_point = points_by_pos[0]; move16(); Loading Loading @@ -475,9 +478,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag Copy( pt_exc1, pt_exc, tmp_len ); remaining_len = sub( remaining_len, tmp_len ); pt_exc1 += tmp_len; move16(); pt_exc += tmp_len; move16(); /* Find point to add and Add points */ tmp16 = mult_r( *pt_exc1, -1638 ); Loading lib_dec/FEC_clas_estim_fx.c +21 −12 Original line number Diff line number Diff line Loading @@ -110,9 +110,13 @@ void FEC_clas_estim_fx( move16(); codec_mode = st_fx->codec_mode; move16(); tcxonly = st_fx->tcxonly; /* i : tcxonly flag */ /*B*/ move16(); narrowBand = st_fx->narrowBand; /* i : narrowband flag */ /*B*/ move16(); preemph_fac = st_fx->preemph_fac; /* i : preemphasis factor */ /*B*/ move16(); /*------------------------------------------------------------------------* * Copy synthesized into local buffer *------------------------------------------------------------------------*/ Loading @@ -129,13 +133,14 @@ void FEC_clas_estim_fx( test(); test(); test(); test(); IF( ( EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, ACELP_6k60 ) || EQ_32( last_core_brate, ACELP_8k85 ) || EQ_32( last_core_brate, ACELP_12k65 ) || EQ_32( last_core_brate, ACELP_14k25 ) || EQ_32( last_core_brate, ACELP_15k85 ) || EQ_32( last_core_brate, ACELP_18k25 ) || EQ_32( last_core_brate, ACELP_19k85 ) || EQ_32( last_core_brate, ACELP_23k05 ) || EQ_32( last_core_brate, ACELP_23k85 ) ) && !Opt_AMR_WB && EQ_16( codec_mode, MODE2 ) && GT_16( L_frame, L_FRAME ) ) { Word16 oldLenClasBuff, newLenClasBuff; oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; move16(); lerp( &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); lerp( &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, oldLenClasBuff )], &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, newLenClasBuff )], newLenClasBuff, oldLenClasBuff ); } synth = old_synth + L_SYN_MEM_CLAS_ESTIM; Loading Loading @@ -280,7 +285,7 @@ void FEC_clas_estim_fx( pos = sub( L_frame, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[0] ); #ifdef BASOP_NOGLOB T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); #else Loading @@ -294,14 +299,14 @@ void FEC_clas_estim_fx( j = 16384; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[1] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[1] ); Ltmp = L_add( Ltmp, cor_max[1] ); IF( GT_16( pos, pos_limit ) ) { j = 10923; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[2] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[2] ); Ltmp = L_add( Ltmp, cor_max[2] ); } IF( GT_16( pos, pos_limit ) ) Loading @@ -309,7 +314,7 @@ void FEC_clas_estim_fx( j = 8192; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[3] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[3] ); Ltmp = L_add( Ltmp, cor_max[3] ); } } Loading Loading @@ -473,6 +478,8 @@ void FEC_clas_estim_fx( case ONSET: case SIN_ONSET: case VOICED_TRANSITION: test(); test(); IF( LT_16( fmerit1, 12780 /*0.39f Q15*/ ) ) { result = UNVOICED_CLAS; Loading Loading @@ -543,7 +550,7 @@ void FEC_clas_estim_fx( *decision_hyst = 200; move16(); } ELSE if ( *decision_hyst < 0 ) ELSE IF( *decision_hyst < 0 ) { *decision_hyst = 0; move16(); Loading Loading @@ -783,7 +790,7 @@ static Word16 FEC_dec_class_fx( IF( NE_16( st_fx->coder_type, VOICED ) ) { /* decode the class */ tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_CLS ); tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_CLS ); IF( tmpS == 0 ) { Loading Loading @@ -820,7 +827,7 @@ static Word16 FEC_dec_class_fx( test(); IF( GT_16( st_fx->acelp_cfg.FEC_mode, 1 ) ) { tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_ENR ); tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_ENR ); /* convert from logarithmic to linear domain (the range is 0 : 3.0 : 96 dB) */ tmpS = mult_r( shl( tmpS, 10 ), 24576 ); /* Q10*Q13->Q8 */ L_tmp = L_mult( tmpS, 10885 ); /* 0.332192 in Q15 */ Loading Loading @@ -867,7 +874,9 @@ Word16 FEC_pos_dec_fx( IF( EQ_16( st_fx->coder_type, GENERIC ) && GT_16( st_fx->acelp_cfg.FEC_mode, 2 ) ) { nBits = st_fx->acelp_cfg.pitch_bits[0]; /* The first pitch index is located right after the actual position + the last pulse position index + predicted innovation energy index */ bit_pos_pitch_index = st_fx->next_bit_pos + FEC_BITS_POS + nBits_es_Pred; bit_pos_pitch_index = add( add( st_fx->next_bit_pos, FEC_BITS_POS ), nBits_es_Pred ); test(); test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) ) { /* Harmonic flag is present */ Loading @@ -884,7 +893,7 @@ Word16 FEC_pos_dec_fx( pit16k_Q_dec_fx( pitch_index, 10, 1, &T0, &T0_frac, &T0_min, &T0_max, &st_fx->BER_detect ); /* decode last pulse position */ *last_pulse_pos = (Word16) get_next_indice( st_fx, FEC_BITS_POS ); *last_pulse_pos = (Word16) get_next_indice_fx( st_fx, FEC_BITS_POS ); /* respect the sign */ IF( GE_16( *last_pulse_pos, 128 ) ) Loading lib_dec/FEC_fx.c +24 −15 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ void FEC_exc_estim_fx( GSC_DEC_HANDLE hGSCDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif hGSCDec = st_fx->hGSCDec; Loading @@ -107,6 +108,7 @@ void FEC_exc_estim_fx( /* nb_subfr = L_frame/L_SUBFR */ nb_subfr = shr( L_frame, 6 ); Diff_len = 0; /* to avoid compilation flags */ move16(); set16_fx( exc_dct_in, 0, L_FRAME16k ); extrapolationFailed = 1; Loading Loading @@ -148,7 +150,9 @@ void FEC_exc_estim_fx( tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1]; tmp_pitmin = PIT16k_MIN_EXTEND; move16(); tmp_pitmax = PIT16k_MAX; move16(); IF( EQ_16( L_frame, L_FRAME ) ) { tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1]; Loading Loading @@ -278,7 +282,7 @@ void FEC_exc_estim_fx( test(); test(); test(); IF( st_fx->last_coder_type == UNVOICED && LE_16( st_fx->nbLostCmpt, 3 ) ) IF( EQ_16( st_fx->last_coder_type, UNVOICED ) && LE_16( st_fx->nbLostCmpt, 3 ) ) { /* last good frame was clearly unvoiced */ alpha = _ALPHA_UU_FX; Loading Loading @@ -412,7 +416,7 @@ void FEC_exc_estim_fx( /* last pitch cycle of the previous frame is repeatedly copied up to an extra subframe */ tmp = (Word16) ( ( exc + L_frame + L_SUBFR ) - pt_exc ); tmp = extract_l( ( exc + add( L_frame, L_SUBFR ) ) - pt_exc ); FOR( i = 0; i < tmp; i++ ) { *pt_exc++ = *pt1_exc++; Loading @@ -430,8 +434,8 @@ void FEC_exc_estim_fx( test(); IF( ( cond1 < 0 ) && ( new_pit > 0 ) && ( cond2 != 0 ) && ( cond3 > 0 ) && extrapolationFailed == 0 ) { Copy( exc, exc - L_frame - L_SUBFR, L_frame + L_SUBFR ); PulseResynchronization_fx( exc - L_frame - L_SUBFR, exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); Copy( exc, exc - add( L_frame, L_SUBFR ), add( L_frame, L_SUBFR ) ); PulseResynchronization_fx( exc - add( L_frame, L_SUBFR ), exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); } } test(); Loading @@ -457,7 +461,8 @@ void FEC_exc_estim_fx( /* end of the frame gain */ test(); test(); test(); IF( !( GE_16( st_fx->last_good, VOICED_CLAS ) && LT_16( st_fx->last_good, INACTIVE_CLAS ) && NE_16( st_fx->last_coder_type, AUDIO ) && GT_16( st_fx->nbLostCmpt, 1 ) ) ) { st_fx->lp_gainp_fx = shr( alpha, 1 ); /* alpha in Q15 */ Loading Loading @@ -504,13 +509,13 @@ void FEC_exc_estim_fx( move16(); /*ptr init*/ FOR( i = 0; i < Len; i++ ) { exc_dct_in[i + Diff_len] = mult_r( exc_dct_in[i + Diff_len], sm_table_fx[i] ); exc_dct_in[add( i, Diff_len )] = mult_r( exc_dct_in[add( i, Diff_len )], sm_table_fx[i] ); move16(); } FOR( ; i < max_len; i++ ) { exc_dct_in[i + Diff_len] = 0; exc_dct_in[add( i, Diff_len )] = 0; move16(); } Diff_len = add( Diff_len, 1 ); Loading @@ -527,14 +532,16 @@ void FEC_exc_estim_fx( { st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag; move16(); /* st_fx->L_frame / L_SUBFR */ tmp = shr( st_fx->L_frame, 6 ); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ if ( st_fx->element_mode == EVS_MONO ) IF( st_fx->element_mode == EVS_MONO ) { gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } else ELSE { gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ /* Transform back to time domain */ Loading Loading @@ -653,6 +660,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); } FOR( i = 0; i < L_frame; i++ ) Loading @@ -665,6 +673,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); /* gain -= step; */ L_tmp2 = L_sub( L_tmp2, L_step ); tmp = round_fx( L_tmp2 ); Loading @@ -679,6 +688,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); } } Loading @@ -699,7 +709,6 @@ void FEC_exc_estim_fx( /* For voiced and generic signals - prepare a HP filter for the random part of excitation */ /* tmp = -(1-tilt_code) to correctly represent 1.0000 */ tmp = add( st_fx->tilt_code_fx, -32768 ); move16(); FOR( i = 0; i < MODE1_L_FIR_FER; i++ ) { hp_filt[i] = msu_r( 0, tmp, h_high_fx[i] ); Loading @@ -708,7 +717,6 @@ void FEC_exc_estim_fx( /* HP filter the random part of the excitation and add the adaptive part */ pt_exc = exc2_buf; move16(); FOR( i = 0; i < L_frame; i++ ) { /* exc2[i] = exc[i] + dotp( &exc2_buf[i], hp_filt, MODE1_L_FIR_FER );*/ Loading Loading @@ -740,7 +748,6 @@ void FEC_exc_estim_fx( { IF( EQ_16( L_frame, L_FRAME ) ) { interp_code_5over2_fx( exc, bwe_exc, L_frame ); } ELSE Loading Loading @@ -775,7 +782,9 @@ void FEC_exc_estim_fx( { gain_dec_bfi_fx( hAmrwb_IO->past_qua_en_fx ); } st_fx->bfi_pitch_fx = pitch_buf[( L_frame / L_SUBFR ) - 1]; /* L_frame / L_SUBFR */ tmp = shr( L_frame, 6 ); st_fx->bfi_pitch_fx = pitch_buf[sub( tmp, 1 )]; move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); Loading lib_dec/er_dec_acelp_fx.c +32 −32 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ void con_acelp_fx( * PLC: [ACELP:Extrapolate Pitch Lag] *------------------------------------------------------------------------*/ IF( EQ_16( st->flagGuidedAcelp, 1 ) ) if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { T0 = st->guidedT0; move16(); Loading @@ -142,13 +142,13 @@ void con_acelp_fx( st->plc_use_future_lag, &extrapolationFailed, st->nb_subfr ); T0 = round_fx( predPitchLag ); IF( NE_16( extrapolationFailed, 0 ) ) IF( extrapolationFailed != 0 ) { /*------------------------------------------------------------------------* * - Construct adaptive codebook from side information * *------------------------------------------------------------------------*/ IF( EQ_16( st->flagGuidedAcelp, 0 ) ) IF( st->flagGuidedAcelp == 0 ) { nSubframes = 0; move16(); Loading @@ -174,7 +174,7 @@ void con_acelp_fx( tmp_tc = st->old_fpitch; move32(); /* take the previous frame last pitch*/ IF( GT_16( nSubframes, 0 ) ) if ( nSubframes > 0 ) { tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ } Loading @@ -183,7 +183,7 @@ void con_acelp_fx( * PLC: calculate damping factor */ alpha = Damping_fact_fx( coder_type, st->nbLostCmpt, st->last_good, stab_fac, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/ st->cummulative_damping = shl( mult( st->cummulative_damping, alpha ), 1 ); /*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ IF( EQ_16( st->nbLostCmpt, 1 ) ) if ( EQ_16( st->nbLostCmpt, 1 ) ) { st->cummulative_damping = 32767 /*1.f Q15*/; /*Q15*/ move16(); Loading Loading @@ -212,20 +212,20 @@ void con_acelp_fx( test(); test(); test(); IF( GT_16( T0, 0 ) && ( NE_16( T0, Tc ) ) && LT_16( tmp, 0 ) && EQ_16( extrapolationFailed, 0 ) ) if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( tmp < 0 ) && extrapolationFailed == 0 ) { fUseExtrapolatedPitch = 1; move16(); } pt_exc = exc; IF( NE_16( st->enableGplc, 0 ) ) if ( st->enableGplc != 0 ) { pt_exc = &exc[imult1616( nSubframes, L_SUBFR )]; } pt1_exc = pt_exc - Tc; IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { /* Required because later pt1_exc[1] used in filtering points to exc[0]. To make it safe also for GPL pt_exc is used instead of exc */ pt_exc[0] = 0; Loading Loading @@ -268,7 +268,7 @@ void con_acelp_fx( } } IF( NE_16( fUseExtrapolatedPitch, 0 ) ) if ( fUseExtrapolatedPitch != 0 ) { pt1_exc = harmonic_exc_buf; } Loading @@ -285,7 +285,7 @@ void con_acelp_fx( * PLC: Resync pulse positions. *-------------------------------------------------------*/ IF( GT_16( nSubframes, 0 ) ) IF( nSubframes > 0 ) { pitch_buf[0] = L_deposit_h( st->guidedT0 ); move32(); Loading @@ -293,7 +293,7 @@ void con_acelp_fx( move32(); } IF( GT_16( nSubframes, 0 ) ) IF( nSubframes > 0 ) { pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ move32(); Loading @@ -307,7 +307,7 @@ void con_acelp_fx( } ELSE { IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, predPitchLag, pitch_buf ); Loading @@ -325,7 +325,7 @@ void con_acelp_fx( *------------------------------------------------------------*/ pt_exc = exc + st->L_frame; pt1_exc = pt_exc - T0; IF( EQ_16( T0, 0 ) ) if ( T0 == 0 ) { pt1_exc = pt_exc - Tc; } Loading @@ -341,11 +341,11 @@ void con_acelp_fx( * PLC: update the floating point pitch for consecutive loss *-------------------------------------------------------*/ IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { st->old_fpitch = predPitchLag; move32(); IF( EQ_16( st->flagGuidedAcelp, 1 ) ) if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { st->old_fpitch = L_deposit_h( T0 ); } Loading Loading @@ -531,7 +531,7 @@ void con_acelp_fx( /*gainCNG=st->cngTDLevel/gainSynthDeemph;*/ BASOP_Util_Divide_MantExp( st->cngTDLevel, st->cngTDLevel_e, gainSynthDeemph, gainSynthDeemph_e, &gainCNG, &gainCNG_e ); gainCNG_e = sub( gainCNG_e, 15 - 5 ); /*Q15->Q5*/ IF( EQ_16( gainCNG, 0 ) ) if ( gainCNG == 0 ) { gainCNG_e = 0; move16(); Loading @@ -554,9 +554,9 @@ void con_acelp_fx( /*in case of overflow:*/ test(); #ifdef BASOP_NOGLOB IF( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) if ( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #else IF( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) if ( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #endif { tmp_16 = 1; Loading @@ -564,7 +564,7 @@ void con_acelp_fx( } BASOP_SATURATE_WARNING_ON_EVS IF( GT_16( tmp_16, 0 ) ) IF( tmp_16 > 0 ) { gainCNG = ftmp /*Q0*/; move16(); Loading Loading @@ -620,7 +620,7 @@ void con_acelp_fx( s_32 = sub( s_32, 7 ); /*tmp_32 is Q31 * 2^s_32 */ /*assure doing Isqrt not for 0*/ IF( NE_32( tmp_32, 0 ) ) IF( tmp_32 != 0 ) { s_gain_inov = s_32; move16(); Loading @@ -646,7 +646,7 @@ void con_acelp_fx( step_32 = L_shr( step_32, 7 ); /* 15Q16 */ test(); IF( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ if ( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ { gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); /*Q15 * 2^s_gain_inov*/ } Loading Loading @@ -859,15 +859,15 @@ void con_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M ); p_A = p_A + add( M, 1 ); p_A += ( M + 1 ); } Copy( mem_syn, mem_syn2, M ); /* synthesize ola*/ E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); } test(); IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn, exc and synthesis*/ Scale_sig( mem_syn, M, negate( s_16 ) ); Loading Loading @@ -950,7 +950,7 @@ void con_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc_unv[i_subfr], &syn_unv[i_subfr], L_SUBFR, mem_syn_unv, 1, M ); p_A = p_A + add( M, 1 ); p_A += ( M + 1 ); } Copy( mem_syn_unv, st->mem_syn_unv_back, M ); Loading @@ -958,11 +958,11 @@ void con_acelp_fx( { Copy( mem_syn_unv, mem_syn, M ); /* unvoiced for ola */ E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); } test(); IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig( mem_syn_unv, M, negate( s_16 ) ); Loading Loading @@ -1067,10 +1067,10 @@ void con_acelp_fx( /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); Copy( syn + sub( st->L_frame, add( M, 1 ) ), st->syn, add( 1, M ) ); Copy( syn + sub(st->L_frame, M + 1), st->syn, 1 + M ); /* update old_Aq */ Copy( p_A - add( M, 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); Loading Loading @@ -1186,7 +1186,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc BASOP_SATURATE_WARNING_ON_EVS } /*if there is energy in scale_syn, then increase precision*/ IF( GT_16( abs_s( tmp ), 0 ) ) IF( abs_s( tmp ) > 0 ) { sf_mem_syn = getScaleFactor16( mem_syn, M ); /*sf_exc = getScaleFactor16(exc, add(shr(len,1),len));*/ /*this returns 0 if signal is 0*/ Loading @@ -1196,7 +1196,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc max = s_max( max, abs_s( exc[k] ) ); } sf_exc = norm_s( max ); IF( EQ_16( max, 0 ) ) if ( max == 0 ) { sf_exc = 16; move16(); Loading Loading
lib_com/cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -1818,7 +1818,9 @@ typedef enum _DCTTYPE #define CNA_INIT_NBANDS 6 #define GAIN_Q_OFFSET_EVS 60.f #define GAIN_Q_OFFSET_EVS_FX_Q0 60 #define GAIN_Q_OFFSET_IVAS 45.f #define GAIN_Q_OFFSET_IVAS_FX_Q0 45 /*----------------------------------------------------------------------------------* * Bass post-filter constants Loading
lib_dec/FEC_adapt_codebook_fx.c +16 −15 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ Word16 FEC_SinOnset_fx( P0 = PIT_MAX; move16(); /* Should never be the case, however... */ } ELSE if ( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) ELSE IF( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) { P0 = PIT16k_MAX; move16(); /* Should never be the case, however... */ Loading Loading @@ -134,13 +134,11 @@ Word16 FEC_SinOnset_fx( { L_tmp = L_mult( gain, H_low[i] ); /* Q_exc*Q15 -> Q_exc */ H_low_s[i] = round_fx( L_shl( L_tmp, exp2 ) ); move16(); } /*------------------------------------------------------------------------------------------* * Construct the harmonic part as a train of low-pass filtered pulses *------------------------------------------------------------------------------------------*/ move16(); move16(); move16(); pt_exc = exc_tmp + sub( L_frame, add( add( 1, MODE1_L_FIR_FER / 2 ), P0 ) ); /* beginning of the 1st pulse */ pt_end = exc_tmp + onset_len; len = (Word16) ( pt_exc - pt_end ); Loading @@ -165,7 +163,7 @@ Word16 FEC_SinOnset_fx( move16(); } } Copy( &exc_tmp[L_frame - L_EXC_MEM], exc, L_EXC_MEM ); Copy( &exc_tmp[sub( L_frame, L_EXC_MEM )], exc, L_EXC_MEM ); return Q_exc; } Loading @@ -191,7 +189,7 @@ Word16 FEC_enhACB_fx( Copy( exc_io, exc + L_FRAME16k - L_EXC_MEM, L_EXC_MEM ); Tc = shr( bfi_pitch, 6 ); Copy( exc + L_FRAME16k - Tc, exc + L_FRAME16k, L_SUBFR ); Copy( exc + sub( L_FRAME16k, Tc ), exc + L_FRAME16k, L_SUBFR ); /*------------------------------------------------------------ * Decode phase information transmitted in the bitstream Loading Loading @@ -229,6 +227,7 @@ Word16 FEC_enhACB_fx( move16(); Tlist[0] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), pit_search, DEC, &sign ); move16(); /*Terr = (short) abs(pit_search-Tlist[0]-P0);*/ Terr = abs_s( sub( pit_search, add( Tlist[0], P0 ) ) ); Loading @@ -236,6 +235,7 @@ Word16 FEC_enhACB_fx( dist_Plast = sub( Tc, Tlist[0] ); Tlist[1] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), add( pit_search, L_SUBFR ), DEC, &sign ); move16(); /*if(Terr > abs(Tlist[1]-Tc + P0))*/ Loading @@ -256,7 +256,6 @@ Word16 FEC_enhACB_fx( { /* performe excitation resynchronization here */ Do_WI = FEC_synchro_exc_fx( L_frame, exc, P0, dist_Plast, Tc ); move16(); Copy( exc + L_FRAME16k - L_EXC_MEM, exc_io, L_EXC_MEM ); } ELSE Loading Loading @@ -350,15 +349,16 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag * --------------------------------------------------------------------*/ L_min_energy = L_add( MAX_32, 0 ); L_tmp = L_mult( pt_exc[start_search], pt_exc[start_search] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 1], pt_exc[start_search + 1] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 2], pt_exc[start_search + 2] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 3], pt_exc[start_search + 3] ); L_tmp = L_mac( L_tmp, pt_exc[start_search + 4], pt_exc[start_search + 4] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 1 )], pt_exc[add( start_search, 1 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 2 )], pt_exc[add( start_search, 2 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 3 )], pt_exc[add( start_search, 3 )] ); L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 4 )], pt_exc[add( start_search, 4 )] ); IF( LT_32( L_tmp, L_min_energy ) ) { L_min_energy = L_add( L_tmp, 0 ); min_pos[0] = add( add( pos, start_search ), 2 ); move16(); } FOR( i = start_search; i < -5; i++ ) Loading @@ -371,6 +371,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag L_min_energy = L_tmp; /* sets to 'L_tmp' in 1 clock */ move32(); min_pos[0] = add( add( pos, i ), 2 ); move16(); } } Loading Loading @@ -407,13 +408,15 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag nb_min = 1; move16(); points_by_pos[0] = abs_s( point_to_remove ); move16(); } ELSE { /* First position */ /* fact = (float)fabs(point_to_remove) / sqi[nb_min-2]; (nb_min*nb_min) */ fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[nb_min - 2] ); /*Q7 */ fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[sub( nb_min, 2 )] ); /*Q7 */ points_by_pos[0] = mult_r( fact, 256 ); /*Q7 */ move16(); total_point = points_by_pos[0]; move16(); Loading Loading @@ -475,9 +478,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag Copy( pt_exc1, pt_exc, tmp_len ); remaining_len = sub( remaining_len, tmp_len ); pt_exc1 += tmp_len; move16(); pt_exc += tmp_len; move16(); /* Find point to add and Add points */ tmp16 = mult_r( *pt_exc1, -1638 ); Loading
lib_dec/FEC_clas_estim_fx.c +21 −12 Original line number Diff line number Diff line Loading @@ -110,9 +110,13 @@ void FEC_clas_estim_fx( move16(); codec_mode = st_fx->codec_mode; move16(); tcxonly = st_fx->tcxonly; /* i : tcxonly flag */ /*B*/ move16(); narrowBand = st_fx->narrowBand; /* i : narrowband flag */ /*B*/ move16(); preemph_fac = st_fx->preemph_fac; /* i : preemphasis factor */ /*B*/ move16(); /*------------------------------------------------------------------------* * Copy synthesized into local buffer *------------------------------------------------------------------------*/ Loading @@ -129,13 +133,14 @@ void FEC_clas_estim_fx( test(); test(); test(); test(); IF( ( EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, ACELP_6k60 ) || EQ_32( last_core_brate, ACELP_8k85 ) || EQ_32( last_core_brate, ACELP_12k65 ) || EQ_32( last_core_brate, ACELP_14k25 ) || EQ_32( last_core_brate, ACELP_15k85 ) || EQ_32( last_core_brate, ACELP_18k25 ) || EQ_32( last_core_brate, ACELP_19k85 ) || EQ_32( last_core_brate, ACELP_23k05 ) || EQ_32( last_core_brate, ACELP_23k85 ) ) && !Opt_AMR_WB && EQ_16( codec_mode, MODE2 ) && GT_16( L_frame, L_FRAME ) ) { Word16 oldLenClasBuff, newLenClasBuff; oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; move16(); lerp( &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); lerp( &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, oldLenClasBuff )], &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, newLenClasBuff )], newLenClasBuff, oldLenClasBuff ); } synth = old_synth + L_SYN_MEM_CLAS_ESTIM; Loading Loading @@ -280,7 +285,7 @@ void FEC_clas_estim_fx( pos = sub( L_frame, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[0] ); #ifdef BASOP_NOGLOB T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); #else Loading @@ -294,14 +299,14 @@ void FEC_clas_estim_fx( j = 16384; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[1] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[1] ); Ltmp = L_add( Ltmp, cor_max[1] ); IF( GT_16( pos, pos_limit ) ) { j = 10923; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[2] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[2] ); Ltmp = L_add( Ltmp, cor_max[2] ); } IF( GT_16( pos, pos_limit ) ) Loading @@ -309,7 +314,7 @@ void FEC_clas_estim_fx( j = 8192; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[3] ); Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[3] ); Ltmp = L_add( Ltmp, cor_max[3] ); } } Loading Loading @@ -473,6 +478,8 @@ void FEC_clas_estim_fx( case ONSET: case SIN_ONSET: case VOICED_TRANSITION: test(); test(); IF( LT_16( fmerit1, 12780 /*0.39f Q15*/ ) ) { result = UNVOICED_CLAS; Loading Loading @@ -543,7 +550,7 @@ void FEC_clas_estim_fx( *decision_hyst = 200; move16(); } ELSE if ( *decision_hyst < 0 ) ELSE IF( *decision_hyst < 0 ) { *decision_hyst = 0; move16(); Loading Loading @@ -783,7 +790,7 @@ static Word16 FEC_dec_class_fx( IF( NE_16( st_fx->coder_type, VOICED ) ) { /* decode the class */ tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_CLS ); tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_CLS ); IF( tmpS == 0 ) { Loading Loading @@ -820,7 +827,7 @@ static Word16 FEC_dec_class_fx( test(); IF( GT_16( st_fx->acelp_cfg.FEC_mode, 1 ) ) { tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_ENR ); tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_ENR ); /* convert from logarithmic to linear domain (the range is 0 : 3.0 : 96 dB) */ tmpS = mult_r( shl( tmpS, 10 ), 24576 ); /* Q10*Q13->Q8 */ L_tmp = L_mult( tmpS, 10885 ); /* 0.332192 in Q15 */ Loading Loading @@ -867,7 +874,9 @@ Word16 FEC_pos_dec_fx( IF( EQ_16( st_fx->coder_type, GENERIC ) && GT_16( st_fx->acelp_cfg.FEC_mode, 2 ) ) { nBits = st_fx->acelp_cfg.pitch_bits[0]; /* The first pitch index is located right after the actual position + the last pulse position index + predicted innovation energy index */ bit_pos_pitch_index = st_fx->next_bit_pos + FEC_BITS_POS + nBits_es_Pred; bit_pos_pitch_index = add( add( st_fx->next_bit_pos, FEC_BITS_POS ), nBits_es_Pred ); test(); test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) ) { /* Harmonic flag is present */ Loading @@ -884,7 +893,7 @@ Word16 FEC_pos_dec_fx( pit16k_Q_dec_fx( pitch_index, 10, 1, &T0, &T0_frac, &T0_min, &T0_max, &st_fx->BER_detect ); /* decode last pulse position */ *last_pulse_pos = (Word16) get_next_indice( st_fx, FEC_BITS_POS ); *last_pulse_pos = (Word16) get_next_indice_fx( st_fx, FEC_BITS_POS ); /* respect the sign */ IF( GE_16( *last_pulse_pos, 128 ) ) Loading
lib_dec/FEC_fx.c +24 −15 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ void FEC_exc_estim_fx( GSC_DEC_HANDLE hGSCDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif hGSCDec = st_fx->hGSCDec; Loading @@ -107,6 +108,7 @@ void FEC_exc_estim_fx( /* nb_subfr = L_frame/L_SUBFR */ nb_subfr = shr( L_frame, 6 ); Diff_len = 0; /* to avoid compilation flags */ move16(); set16_fx( exc_dct_in, 0, L_FRAME16k ); extrapolationFailed = 1; Loading Loading @@ -148,7 +150,9 @@ void FEC_exc_estim_fx( tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1]; tmp_pitmin = PIT16k_MIN_EXTEND; move16(); tmp_pitmax = PIT16k_MAX; move16(); IF( EQ_16( L_frame, L_FRAME ) ) { tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1]; Loading Loading @@ -278,7 +282,7 @@ void FEC_exc_estim_fx( test(); test(); test(); IF( st_fx->last_coder_type == UNVOICED && LE_16( st_fx->nbLostCmpt, 3 ) ) IF( EQ_16( st_fx->last_coder_type, UNVOICED ) && LE_16( st_fx->nbLostCmpt, 3 ) ) { /* last good frame was clearly unvoiced */ alpha = _ALPHA_UU_FX; Loading Loading @@ -412,7 +416,7 @@ void FEC_exc_estim_fx( /* last pitch cycle of the previous frame is repeatedly copied up to an extra subframe */ tmp = (Word16) ( ( exc + L_frame + L_SUBFR ) - pt_exc ); tmp = extract_l( ( exc + add( L_frame, L_SUBFR ) ) - pt_exc ); FOR( i = 0; i < tmp; i++ ) { *pt_exc++ = *pt1_exc++; Loading @@ -430,8 +434,8 @@ void FEC_exc_estim_fx( test(); IF( ( cond1 < 0 ) && ( new_pit > 0 ) && ( cond2 != 0 ) && ( cond3 > 0 ) && extrapolationFailed == 0 ) { Copy( exc, exc - L_frame - L_SUBFR, L_frame + L_SUBFR ); PulseResynchronization_fx( exc - L_frame - L_SUBFR, exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); Copy( exc, exc - add( L_frame, L_SUBFR ), add( L_frame, L_SUBFR ) ); PulseResynchronization_fx( exc - add( L_frame, L_SUBFR ), exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); } } test(); Loading @@ -457,7 +461,8 @@ void FEC_exc_estim_fx( /* end of the frame gain */ test(); test(); test(); IF( !( GE_16( st_fx->last_good, VOICED_CLAS ) && LT_16( st_fx->last_good, INACTIVE_CLAS ) && NE_16( st_fx->last_coder_type, AUDIO ) && GT_16( st_fx->nbLostCmpt, 1 ) ) ) { st_fx->lp_gainp_fx = shr( alpha, 1 ); /* alpha in Q15 */ Loading Loading @@ -504,13 +509,13 @@ void FEC_exc_estim_fx( move16(); /*ptr init*/ FOR( i = 0; i < Len; i++ ) { exc_dct_in[i + Diff_len] = mult_r( exc_dct_in[i + Diff_len], sm_table_fx[i] ); exc_dct_in[add( i, Diff_len )] = mult_r( exc_dct_in[add( i, Diff_len )], sm_table_fx[i] ); move16(); } FOR( ; i < max_len; i++ ) { exc_dct_in[i + Diff_len] = 0; exc_dct_in[add( i, Diff_len )] = 0; move16(); } Diff_len = add( Diff_len, 1 ); Loading @@ -527,14 +532,16 @@ void FEC_exc_estim_fx( { st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag; move16(); /* st_fx->L_frame / L_SUBFR */ tmp = shr( st_fx->L_frame, 6 ); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ if ( st_fx->element_mode == EVS_MONO ) IF( st_fx->element_mode == EVS_MONO ) { gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } else ELSE { gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ /* Transform back to time domain */ Loading Loading @@ -653,6 +660,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); } FOR( i = 0; i < L_frame; i++ ) Loading @@ -665,6 +673,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); /* gain -= step; */ L_tmp2 = L_sub( L_tmp2, L_step ); tmp = round_fx( L_tmp2 ); Loading @@ -679,6 +688,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif move16(); } } Loading @@ -699,7 +709,6 @@ void FEC_exc_estim_fx( /* For voiced and generic signals - prepare a HP filter for the random part of excitation */ /* tmp = -(1-tilt_code) to correctly represent 1.0000 */ tmp = add( st_fx->tilt_code_fx, -32768 ); move16(); FOR( i = 0; i < MODE1_L_FIR_FER; i++ ) { hp_filt[i] = msu_r( 0, tmp, h_high_fx[i] ); Loading @@ -708,7 +717,6 @@ void FEC_exc_estim_fx( /* HP filter the random part of the excitation and add the adaptive part */ pt_exc = exc2_buf; move16(); FOR( i = 0; i < L_frame; i++ ) { /* exc2[i] = exc[i] + dotp( &exc2_buf[i], hp_filt, MODE1_L_FIR_FER );*/ Loading Loading @@ -740,7 +748,6 @@ void FEC_exc_estim_fx( { IF( EQ_16( L_frame, L_FRAME ) ) { interp_code_5over2_fx( exc, bwe_exc, L_frame ); } ELSE Loading Loading @@ -775,7 +782,9 @@ void FEC_exc_estim_fx( { gain_dec_bfi_fx( hAmrwb_IO->past_qua_en_fx ); } st_fx->bfi_pitch_fx = pitch_buf[( L_frame / L_SUBFR ) - 1]; /* L_frame / L_SUBFR */ tmp = shr( L_frame, 6 ); st_fx->bfi_pitch_fx = pitch_buf[sub( tmp, 1 )]; move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); Loading
lib_dec/er_dec_acelp_fx.c +32 −32 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ void con_acelp_fx( * PLC: [ACELP:Extrapolate Pitch Lag] *------------------------------------------------------------------------*/ IF( EQ_16( st->flagGuidedAcelp, 1 ) ) if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { T0 = st->guidedT0; move16(); Loading @@ -142,13 +142,13 @@ void con_acelp_fx( st->plc_use_future_lag, &extrapolationFailed, st->nb_subfr ); T0 = round_fx( predPitchLag ); IF( NE_16( extrapolationFailed, 0 ) ) IF( extrapolationFailed != 0 ) { /*------------------------------------------------------------------------* * - Construct adaptive codebook from side information * *------------------------------------------------------------------------*/ IF( EQ_16( st->flagGuidedAcelp, 0 ) ) IF( st->flagGuidedAcelp == 0 ) { nSubframes = 0; move16(); Loading @@ -174,7 +174,7 @@ void con_acelp_fx( tmp_tc = st->old_fpitch; move32(); /* take the previous frame last pitch*/ IF( GT_16( nSubframes, 0 ) ) if ( nSubframes > 0 ) { tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ } Loading @@ -183,7 +183,7 @@ void con_acelp_fx( * PLC: calculate damping factor */ alpha = Damping_fact_fx( coder_type, st->nbLostCmpt, st->last_good, stab_fac, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/ st->cummulative_damping = shl( mult( st->cummulative_damping, alpha ), 1 ); /*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ IF( EQ_16( st->nbLostCmpt, 1 ) ) if ( EQ_16( st->nbLostCmpt, 1 ) ) { st->cummulative_damping = 32767 /*1.f Q15*/; /*Q15*/ move16(); Loading Loading @@ -212,20 +212,20 @@ void con_acelp_fx( test(); test(); test(); IF( GT_16( T0, 0 ) && ( NE_16( T0, Tc ) ) && LT_16( tmp, 0 ) && EQ_16( extrapolationFailed, 0 ) ) if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( tmp < 0 ) && extrapolationFailed == 0 ) { fUseExtrapolatedPitch = 1; move16(); } pt_exc = exc; IF( NE_16( st->enableGplc, 0 ) ) if ( st->enableGplc != 0 ) { pt_exc = &exc[imult1616( nSubframes, L_SUBFR )]; } pt1_exc = pt_exc - Tc; IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { /* Required because later pt1_exc[1] used in filtering points to exc[0]. To make it safe also for GPL pt_exc is used instead of exc */ pt_exc[0] = 0; Loading Loading @@ -268,7 +268,7 @@ void con_acelp_fx( } } IF( NE_16( fUseExtrapolatedPitch, 0 ) ) if ( fUseExtrapolatedPitch != 0 ) { pt1_exc = harmonic_exc_buf; } Loading @@ -285,7 +285,7 @@ void con_acelp_fx( * PLC: Resync pulse positions. *-------------------------------------------------------*/ IF( GT_16( nSubframes, 0 ) ) IF( nSubframes > 0 ) { pitch_buf[0] = L_deposit_h( st->guidedT0 ); move32(); Loading @@ -293,7 +293,7 @@ void con_acelp_fx( move32(); } IF( GT_16( nSubframes, 0 ) ) IF( nSubframes > 0 ) { pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ move32(); Loading @@ -307,7 +307,7 @@ void con_acelp_fx( } ELSE { IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, predPitchLag, pitch_buf ); Loading @@ -325,7 +325,7 @@ void con_acelp_fx( *------------------------------------------------------------*/ pt_exc = exc + st->L_frame; pt1_exc = pt_exc - T0; IF( EQ_16( T0, 0 ) ) if ( T0 == 0 ) { pt1_exc = pt_exc - Tc; } Loading @@ -341,11 +341,11 @@ void con_acelp_fx( * PLC: update the floating point pitch for consecutive loss *-------------------------------------------------------*/ IF( NE_16( fUseExtrapolatedPitch, 0 ) ) IF( fUseExtrapolatedPitch != 0 ) { st->old_fpitch = predPitchLag; move32(); IF( EQ_16( st->flagGuidedAcelp, 1 ) ) if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { st->old_fpitch = L_deposit_h( T0 ); } Loading Loading @@ -531,7 +531,7 @@ void con_acelp_fx( /*gainCNG=st->cngTDLevel/gainSynthDeemph;*/ BASOP_Util_Divide_MantExp( st->cngTDLevel, st->cngTDLevel_e, gainSynthDeemph, gainSynthDeemph_e, &gainCNG, &gainCNG_e ); gainCNG_e = sub( gainCNG_e, 15 - 5 ); /*Q15->Q5*/ IF( EQ_16( gainCNG, 0 ) ) if ( gainCNG == 0 ) { gainCNG_e = 0; move16(); Loading @@ -554,9 +554,9 @@ void con_acelp_fx( /*in case of overflow:*/ test(); #ifdef BASOP_NOGLOB IF( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) if ( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #else IF( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) if ( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #endif { tmp_16 = 1; Loading @@ -564,7 +564,7 @@ void con_acelp_fx( } BASOP_SATURATE_WARNING_ON_EVS IF( GT_16( tmp_16, 0 ) ) IF( tmp_16 > 0 ) { gainCNG = ftmp /*Q0*/; move16(); Loading Loading @@ -620,7 +620,7 @@ void con_acelp_fx( s_32 = sub( s_32, 7 ); /*tmp_32 is Q31 * 2^s_32 */ /*assure doing Isqrt not for 0*/ IF( NE_32( tmp_32, 0 ) ) IF( tmp_32 != 0 ) { s_gain_inov = s_32; move16(); Loading @@ -646,7 +646,7 @@ void con_acelp_fx( step_32 = L_shr( step_32, 7 ); /* 15Q16 */ test(); IF( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ if ( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ { gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); /*Q15 * 2^s_gain_inov*/ } Loading Loading @@ -859,15 +859,15 @@ void con_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M ); p_A = p_A + add( M, 1 ); p_A += ( M + 1 ); } Copy( mem_syn, mem_syn2, M ); /* synthesize ola*/ E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); } test(); IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn, exc and synthesis*/ Scale_sig( mem_syn, M, negate( s_16 ) ); Loading Loading @@ -950,7 +950,7 @@ void con_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc_unv[i_subfr], &syn_unv[i_subfr], L_SUBFR, mem_syn_unv, 1, M ); p_A = p_A + add( M, 1 ); p_A += ( M + 1 ); } Copy( mem_syn_unv, st->mem_syn_unv_back, M ); Loading @@ -958,11 +958,11 @@ void con_acelp_fx( { Copy( mem_syn_unv, mem_syn, M ); /* unvoiced for ola */ E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); } test(); IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig( mem_syn_unv, M, negate( s_16 ) ); Loading Loading @@ -1067,10 +1067,10 @@ void con_acelp_fx( /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); Copy( syn + sub( st->L_frame, add( M, 1 ) ), st->syn, add( 1, M ) ); Copy( syn + sub(st->L_frame, M + 1), st->syn, 1 + M ); /* update old_Aq */ Copy( p_A - add( M, 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); Loading Loading @@ -1186,7 +1186,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc BASOP_SATURATE_WARNING_ON_EVS } /*if there is energy in scale_syn, then increase precision*/ IF( GT_16( abs_s( tmp ), 0 ) ) IF( abs_s( tmp ) > 0 ) { sf_mem_syn = getScaleFactor16( mem_syn, M ); /*sf_exc = getScaleFactor16(exc, add(shr(len,1),len));*/ /*this returns 0 if signal is 0*/ Loading @@ -1196,7 +1196,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc max = s_max( max, abs_s( exc[k] ) ); } sf_exc = norm_s( max ); IF( EQ_16( max, 0 ) ) if ( max == 0 ) { sf_exc = 16; move16(); Loading