Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ #define REUSE_EVS_ACELP #define REUSE_EVS_ACELP_SHIFT #define REUSE_EVS_ACELP_TC #define USE_UC_EVS #if 0 // To be activated when everything is completed #define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added Loading lib_enc/acelp_core_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -1365,7 +1365,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ #ifndef USE_UC_EVS encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); #else encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); #endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { Loading lib_enc/enc_gen_voic_fx.c +25 −6 Original line number Diff line number Diff line Loading @@ -228,10 +228,17 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ #ifdef REUSE_EVS_ACELP //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); } ELSE #endif { //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); } /*-----------------------------------------------------------------* * Find adaptive exitation Loading Loading @@ -389,10 +396,22 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); } ELSE #endif { prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters Loading lib_enc/enc_tran_fx.c +14 −4 Original line number Diff line number Diff line Loading @@ -326,10 +326,20 @@ Word16 encod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr/ L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); } ELSE #endif { prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters Loading lib_enc/enc_uv_fx.c +32 −5 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ #ifndef USE_UC_EVS /*fixed point implementation of unvoiced_encoder*/ void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ Loading Loading @@ -239,6 +240,9 @@ void encod_unvoiced_fx( } void encod_unvoiced_ivas_fx( #else void encod_unvoiced_fx( #endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ Loading Loading @@ -316,7 +320,7 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------*/ i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ #ifndef USE_UC_EVS find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); Loading @@ -326,14 +330,31 @@ void encod_unvoiced_ivas_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift #else find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); #endif /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ IF( !uc_two_stage_flag ) { #ifndef USE_UC_EVS *pt_pitch_fx = gaus_encode_ivas_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #else *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #endif move16(); } ELSE Loading @@ -341,7 +362,6 @@ void encod_unvoiced_ivas_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ // PMT("The code below needs validation, never been tested") /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); Loading @@ -356,11 +376,15 @@ void encod_unvoiced_ivas_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ // E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode ); #ifdef USE_UC_EVS inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); #endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 ); /* -18 (y2*y2: Q9*Q9) */ Loading @@ -373,8 +397,11 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); #ifdef USE_UC_EVS gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); #else gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); #endif /*----------------------------------------------------------* * - Compute the fixed codebook gain * * - quantize fixed codebook gain * Loading Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ #define REUSE_EVS_ACELP #define REUSE_EVS_ACELP_SHIFT #define REUSE_EVS_ACELP_TC #define USE_UC_EVS #if 0 // To be activated when everything is completed #define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added Loading
lib_enc/acelp_core_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -1365,7 +1365,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ #ifndef USE_UC_EVS encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); #else encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); #endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { Loading
lib_enc/enc_gen_voic_fx.c +25 −6 Original line number Diff line number Diff line Loading @@ -228,10 +228,17 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ #ifdef REUSE_EVS_ACELP //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); } ELSE #endif { //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); } /*-----------------------------------------------------------------* * Find adaptive exitation Loading Loading @@ -389,10 +396,22 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); } ELSE #endif { prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters Loading
lib_enc/enc_tran_fx.c +14 −4 Original line number Diff line number Diff line Loading @@ -326,10 +326,20 @@ Word16 encod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ #ifndef REUSE_EVS_TBE_CELP_EXC IF( st_fx->element_mode > EVS_MONO ) { prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr/ L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); } ELSE #endif { prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters Loading
lib_enc/enc_uv_fx.c +32 −5 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ #ifndef USE_UC_EVS /*fixed point implementation of unvoiced_encoder*/ void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ Loading Loading @@ -239,6 +240,9 @@ void encod_unvoiced_fx( } void encod_unvoiced_ivas_fx( #else void encod_unvoiced_fx( #endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ Loading Loading @@ -316,7 +320,7 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------*/ i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ #ifndef USE_UC_EVS find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); Loading @@ -326,14 +330,31 @@ void encod_unvoiced_ivas_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift #else find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); #endif /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ IF( !uc_two_stage_flag ) { #ifndef USE_UC_EVS *pt_pitch_fx = gaus_encode_ivas_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #else *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #endif move16(); } ELSE Loading @@ -341,7 +362,6 @@ void encod_unvoiced_ivas_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ // PMT("The code below needs validation, never been tested") /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); Loading @@ -356,11 +376,15 @@ void encod_unvoiced_ivas_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ // E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode ); #ifdef USE_UC_EVS inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); #endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 ); /* -18 (y2*y2: Q9*Q9) */ Loading @@ -373,8 +397,11 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); #ifdef USE_UC_EVS gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); #else gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); #endif /*----------------------------------------------------------* * - Compute the fixed codebook gain * * - quantize fixed codebook gain * Loading