Skip to content
......@@ -537,16 +537,8 @@ void decoder_acelp_fx(
gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 );
#else
prep_tbe_exc_fx( st->L_frame,
#ifdef ADD_IVAS_TBE_CODE
L_SUBFR,
#endif
i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate
#ifdef ADD_IVAS_TBE_CODE
,
st->element_mode, st->idchan, st->hBWE_TD != NULL, 0
#endif
);
gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate );
#endif
}
......
......@@ -208,11 +208,7 @@ static void decode_frame_type_fx( Decoder_State *st )
move16();
/* Reconf Core */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode );
#else
mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, frame_size_index );
#endif
/* Reconf CLDFB */
IF( NE_16( i_mult( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
{
......
......@@ -893,9 +893,6 @@ void decoder_tcx_fx(
TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
noiseTiltFactor, f,
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
concealment_noise,
#endif
infoIGFStartLine );
}
}
......
......@@ -126,10 +126,6 @@ void con_tcx_fx(
const Word16 coh, /* i : coherence of stereo signal Q14*/
Word16 *noise_seed, /* i/o: noise seed for stereo Q0*/
const Word16 only_left /* i : TD-PLC only in left channel Q0*/
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
,
const float *A_cng /* i : CNG LP filter coefficients Q14*/
#endif
#endif
)
......@@ -489,19 +485,7 @@ void con_tcx_fx(
move16();
/* PLC: calculate damping factor */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
alpha = 1.0f;
if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
else if ( st->element_mode != IVAS_CPE_MDCT )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
#endif
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
st->cummulative_damping = 32767 /*1.f Q15*/;
......@@ -568,19 +552,7 @@ void con_tcx_fx(
}
set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
/* PLC: calculate damping factor */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
alpha = 1.0f;
if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
else if ( st->element_mode != IVAS_CPE_MDCT )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
#endif
}
/*-----------------------------------------------------------------*
......@@ -707,20 +679,9 @@ void con_tcx_fx(
}
/* PLC: [TCX: Fade-out] retrieve background level */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( A_cng != NULL )
{
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp ), A_cng, L_frame / 4, st->preemph_fac, 1 ) / 4.f;
}
else
{
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp ), A_local, L_frame / 4, st->preemph_fac, 1 );
}
#else
tmp16 = 32767;
move16();
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q5*/
#endif
IF( st->tcxonly != 0 )
{
/* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */
......@@ -728,19 +689,6 @@ void con_tcx_fx(
hTcxDec->conCngLevelBackgroundTrace_e,
gainSynthDeemph, gainSynthDeemph_e,
&gainCNG, &gainCNG_e );
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( st->element_mode == IVAS_CPE_MDCT && A_cng != NULL )
{
if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME + MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN )
{
gainCNG = 0.f;
}
else if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME )
{
gainCNG *= 1.f - (float) ( st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN;
}
}
#endif
}
ELSE
{
......@@ -907,34 +855,6 @@ void con_tcx_fx(
/*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/
/*buf[0;M] Q0: mem_syn*/
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( A_cng != NULL )
{
float alpha_delayed;
alpha_delayed = 1.0f;
if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE )
{
alpha_delayed = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac, &( st->lp_gainp ), ACELP_CORE );
}
if ( st->plcBackgroundNoiseUpdated && alpha_delayed != 1.0f )
{
float lsp_local[M], lsp_fade[M], alpha_inv;
alpha_inv = 1.0f - alpha_delayed;
a2lsp_stab( A_local, lsp_local, lsp_local );
for ( i = 0; i < M; i++ )
{
lsp_fade[i] = alpha_delayed * lsp_local[i] + alpha_inv * st->lspold_cng[i];
}
lsp2a_stab( lsp_fade, A_local, M );
}
}
#endif
E_UTIL_synthesis(
sub( Q_exc, Q_syn ),
A_local,
......@@ -1434,19 +1354,7 @@ void con_tcx_ivas_fx(
move16();
/* PLC: calculate damping factor */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
alpha = 1.0f;
if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
else if ( st->element_mode != IVAS_CPE_MDCT )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
#endif
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
st->cummulative_damping = 32767 /*1.f Q15*/;
......@@ -1513,19 +1421,7 @@ void con_tcx_ivas_fx(
}
set32_fx( pitch_buf, L_deposit_h( L_SUBFR ), st->nb_subfr ); /*Q16*/
/* PLC: calculate damping factor */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
alpha = 1.0f;
if ( st->element_mode == IVAS_CPE_MDCT && st->nbLostCmpt >= MDCT_ST_PLC_FADEOUT_START_FRAME )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_START_FRAME, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
else if ( st->element_mode != IVAS_CPE_MDCT )
{
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac, &( st->lp_gainp ), 0 );
}
#else
alpha = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/
#endif
}
/*-----------------------------------------------------------------*
......@@ -1666,7 +1562,6 @@ void con_tcx_ivas_fx(
}
/* PLC: [TCX: Fade-out] retrieve background level */
#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
tmp16 = 32767;
move16();
IF( A_cng != NULL )
......@@ -1677,11 +1572,6 @@ void con_tcx_ivas_fx(
{
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); /*Q13*/
}
#else
tmp16 = 32767;
move16();
gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e );
#endif
IF( st->tcxonly != 0 )
{
/* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */
......@@ -1689,7 +1579,6 @@ void con_tcx_ivas_fx(
hTcxDec->conCngLevelBackgroundTrace_e,
gainSynthDeemph, gainSynthDeemph_e,
&gainCNG, &gainCNG_e );
#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
test();
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && A_cng != NULL )
{
......@@ -1705,7 +1594,6 @@ void con_tcx_ivas_fx(
gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/
}
}
#endif
}
ELSE
{
......@@ -1882,7 +1770,6 @@ void con_tcx_ivas_fx(
/*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/
/*buf[0;M] Q0: mem_syn*/
#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
IF( A_cng != NULL )
{
Word16 alpha_delayed;
......@@ -1914,7 +1801,6 @@ void con_tcx_ivas_fx(
E_LPC_f_lsp_a_conversion( lsp_fade, A_local, M );
}
}
#endif
E_UTIL_synthesis(
sub( Q_exc, Q_syn ),
......
......@@ -957,14 +957,10 @@ ivas_error evs_dec_fx(
}
st_fx->lp_noise = hFdCngDec->lp_noise; /*Q9.23*/
move32();
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
ApplyFdCng_fx( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 );
#else
#ifdef REMOVE_EVS_DUPLICATES
ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
#else
ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
#endif
#endif
/* Generate additional comfort noise to mask potential coding artefacts */
test();
......
......@@ -559,9 +559,6 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec )
Word16 ApplyFdCng_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
Word16 Q,
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
Word16 *powerSpectrum,
#endif
Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer cldfbBufferScale*/
Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer cldfbBufferScale*/
Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
......@@ -588,16 +585,6 @@ Word16 ApplyFdCng_fx(
move16();
move16();
#endif
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
int16_t L_frame, last_L_frame;
int32_t sr_core;
PMT( "Fix point code missing for IVAS_CODE_CNG_FIX185_PLC_FADEOUT" )
/* limit L_frame and core fs values for MDCT-Stereo modes which can have higher core sampling than 16kHz, but use a downsampled buffer */
L_frame = min( st->L_frame, L_FRAME16k );
last_L_frame = min( st->last_L_frame, L_FRAME16k );
sr_core = min( st->sr_core, INT_FS_16k );
#endif
hFdCngDec = st->hFdCngDec;
hFdCngCom = hFdCngDec->hFdCngCom;
......@@ -636,27 +623,6 @@ Word16 ApplyFdCng_fx(
/* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */
/* set noise estimation inactive during concealment, no update with noise generated by concealment should be performed. */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
test();
test();
test();
test();
test();
test();
test();
test();
test();
test();
if ( concealWholeFrame == 0 &&
( timeDomainInput == NULL ||
( *timeDomainInput<FLT_MAX && * timeDomainInput>( -FLT_MAX ) &&
*( timeDomainInput + hFdCngCom->frameSize - 1 ) < FLT_MAX &&
*( timeDomainInput + hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) &&
( ( ( ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT && hFdCngDec->flag_dtx_mode ) || !st->VAD ) &&
!( st->cng_type == LP_CNG && hFdCngDec->flag_dtx_mode ) && ( is_music == 0 ) ) ||
( st->element_mode == IVAS_CPE_TD ) ) &&
( !st->BER_detect ) )
#else
test();
test();
test();
......@@ -671,14 +637,9 @@ Word16 ApplyFdCng_fx(
IF(
( concealWholeFrame == 0 ) &&
( LT_16( *timeDomainInput, MAXVAL_WORD16 ) ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && ( LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) ) && GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) )
#endif
{
/* Perform noise estimation at the decoder */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
#else
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
#endif
/* Update the shaping parameters */
test();
......@@ -790,16 +751,6 @@ Word16 ApplyFdCng_fx(
move16();
}
}
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( st->element_mode == IVAS_CPE_MDCT && timeDomainInput == NULL )
{
st->hTcxDec->CngLevelBackgroundTrace_bfi = sqrtf( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / NORM_MDCT_FACTOR );
}
else
{
st->hTcxDec->CngLevelBackgroundTrace_bfi = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame );
}
#endif
/*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
L_tmp = L_deposit_h( 0 );
......@@ -840,11 +791,7 @@ Word16 ApplyFdCng_fx(
IF( hFdCngCom->active_frame_counter > 0 )
{
/* Perform noise estimation in active frames in the decoder for downward updates */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
#else
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
#endif
}
}
test();
......@@ -860,58 +807,11 @@ Word16 ApplyFdCng_fx(
IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) )
{
/* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/
#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 );
E_LPC_a_lsp_conversion( hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M );
Copy( lsp_cng, st->lspold_cng, M ); /*Q15*/
lsp2lsf_fx( lsp_cng, st->lsf_cng, M, st->sr_core );
#else
if ( st->element_mode == IVAS_CPE_MDCT && st->core != ACELP_CORE )
{
float scf[SNS_NPTS];
float scf_int[FDNS_NPTS];
float whitenend_noise_shape[L_FRAME16k];
int16_t inc, start_idx, stop_idx;
float *noiseLevelPtr;
inc = ( st->core > TCX_20 ) ? 2 : 1;
start_idx = hFdCngCom->startBand / inc;
stop_idx = L_frame / inc;
noiseLevelPtr = cngNoiseLevel;
set_zero( whitenend_noise_shape, start_idx );
for ( j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc )
{
whitenend_noise_shape[j] = *noiseLevelPtr;
}
if ( st->core == TCX_20_CORE )
{
st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX20;
}
else
{
st->hTonalMDCTConc->psychParams = &st->hTonalMDCTConc->psychParamsTCX10;
}
sns_compute_scf( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, L_frame, scf );
sns_interpolate_scalefactors( scf_int, scf, ENC );
sns_interpolate_scalefactors( st->hTonalMDCTConc->scaleFactorsBackground_flt, scf, DEC );
sns_shape_spectrum( whitenend_noise_shape, st->hTonalMDCTConc->psychParams, scf_int, L_frame );
mvr2r( whitenend_noise_shape + start_idx, cngNoiseLevel, stop_idx - start_idx );
wmops_sub_end();
}
else if ( st->element_mode != IVAS_CPE_MDCT )
{
lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0.f );
a2lsp_stab( hFdCngCom->A_cng, lsp_cng, st->lspold_cng );
mvr2r( lsp_cng, st->lspold_cng, M );
lsp2lsf( lsp_cng, st->lsf_cng, M, sr_core );
}
#endif
st->plcBackgroundNoiseUpdated = 1;
move16();
}
......@@ -929,11 +829,7 @@ Word16 ApplyFdCng_fx(
IF( st != NULL && st->cng_type == LP_CNG )
{
/* Perform noise estimation on inactive phase at the decoder */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
perform_noise_estimation_dec_fx( timeDomainInput, powerSpectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
#else
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
#endif
/* Update the shaping parameters */
test();
......@@ -947,9 +843,6 @@ Word16 ApplyFdCng_fx(
Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it Q31 - hFdCngDec->bandNoiseShape_exp*/
*cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
move16();
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
st->cngTDLevel = (float) sqrt( ( sum_f( cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 * hFdCngCom->fftlen ) / L_frame );
#else
/*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
L_tmp = L_deposit_h( 0 );
......@@ -985,7 +878,6 @@ Word16 ApplyFdCng_fx(
move16();
st->cngTDLevel_e = L_tmp_exp;
move16();
#endif
BREAK;
}
hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 );
......@@ -1903,9 +1795,6 @@ Word16 ApplyFdCng_ivas_fx(
void perform_noise_estimation_dec_fx(
const Word16 *timeDomainInput, /* i: pointer to time domain input Q*/
const Word16 Q,
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
float *power_spectrum,
#endif
HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */
)
{
......@@ -1936,53 +1825,11 @@ void perform_noise_estimation_dec_fx(
move16();
/* Perform STFT analysis */
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
IF( !( EQ_16( element_mode, IVAS_CPE_MDCT ) && power_spectrum != NULL ) )
{
/* Perform STFT analysis */
AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom );
}
#else
/* Perform STFT analysis */
AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom );
#endif
fftBuffer_exp = add( fftBuffer_exp, WORD16_BITS - 1 );
{
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL )
{
/* use power spectrum calculated in the MDCT-domain instead of calculating new power spectrum */
periodog = power_spectrum;
}
else
{
/* Compute the squared magnitude in each FFT bin */
if ( startBand == 0 )
{
( *ptr_per ) = fftBuffer[0] * fftBuffer[0]; /* DC component */
ptr_per++;
ptr_r = fftBuffer + 2;
}
else
{
ptr_r = fftBuffer + 2 * startBand;
}
ptr_i = ptr_r + 1;
for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ )
{
( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i );
ptr_r += 2;
ptr_i += 2;
}
/* Nyquist frequency is discarded */
/* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/
v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand );
}
#else
assert( startBand != 0 );
len = sub( stopFFTbin, startBand );
......@@ -2062,7 +1909,6 @@ void perform_noise_estimation_dec_fx(
}
hFdCngDec->hFdCngCom->periodog_exp = add( hFdCngDec->hFdCngCom->periodog_exp, sub( 2, s ) );
move16();
#endif
/* Adjust to the desired frequency resolution by averaging over spectral partitions for SID transmission */
bandcombinepow( periodog, hFdCngDec->hFdCngCom->periodog_exp, sub( stopFFTbin, startBand ), part, npart, psize_inv, hFdCngDec->msPeriodog, &hFdCngDec->msPeriodog_exp );
......
......@@ -24,9 +24,6 @@
#define NORMALIZE_SPECS_Q_OUT 6
#define ENER_FX_Q_GUARD 1
#ifdef ADD_IVAS_GS_DEC_IMPR
#define CONTR_LIMIT 3012 to be verified for fixed point /* Threshold to allow an increase in the contribution length */
#endif
/*-------------------------------------------------------------------*
* Local functions
*-------------------------------------------------------------------*/
......@@ -34,12 +31,7 @@ static void NoiseFill_fx( Word16 *exc_diffQ_fx, Word16 *seed_tcx, const Word16 M
static void Ener_per_band_fx( const Word16 exc_diff_fx[], const Word16 exc_diff_exp, Word32 y_gain4_fx[] );
static void Apply_gain_fx( Word16 exc_diffQ_fx[], Word32 L_Ener_per_bd_iQ[], Word32 L_Ener_per_bd_yQ[], const Word16 Q_out );
static void normalize_spec_fx( Word16 fac_up_fx, Word16 fy_norm_fx[], const Word16 L_frame, const Word16 Q_out );
static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Word16 dct_in_fx[], const Word16 Q_dct_in, Word16 dct_out_fx[], Word16 Q_dct_out, const Word16 pitch_fx[], const Word16 voice_fac, const Word16 clas, const Word16 coder_type
#ifdef ADD_IVAS_GS_DEC_IMPR
,
const Word16 VeryLowRateSTflag
#endif
);
static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Word16 dct_in_fx[], const Word16 Q_dct_in, Word16 dct_out_fx[], Word16 Q_dct_out, const Word16 pitch_fx[], const Word16 voice_fac, const Word16 clas, const Word16 coder_type );
/*-------------------------------------------------------------------*
* NoiseFill_fx()
......@@ -223,10 +215,6 @@ static void gs_dec_amr_wb_fx(
const Word16 voice_fac, /* i : gain pitch Q15*/
const Word16 clas, /* i : signal frame class Q0*/
const Word16 coder_type /* i : coder type Q0*/
#ifdef ADD_IVAS_GS_DEC_IMPR
,
const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
#endif
)
{
Word16 i, mDiff_len;
......@@ -280,13 +268,7 @@ static void gs_dec_amr_wb_fx(
temp = Invert16( temp, &exp ); /* Q15 */
L_temp = L_mult( temp, 12800 ); /* Q15 */
L_temp = L_shl( L_temp, sub( 3, exp ) ); /* *8.0f */ /* Q15 */
#ifdef ADD_IVAS_GS_DEC_IMPR
test();
test();
IF( L_temp <= CONTR_LIMIT && ( VeryLowRateSTflag || GE_32( core_brate, ACELP_12k65 ) ) )
#else
if ( GE_32( core_brate, ACELP_12k65 ) )
#endif
{
L_temp = L_shl( L_temp, 1 ); /* Q16 */
}
......@@ -311,16 +293,6 @@ static void gs_dec_amr_wb_fx(
mDiff_len = s_max( round_fx( L_temp ), BIN_1k2 ); /* Q0 */
#ifdef ADD_IVAS_GS_DEC_IMPR
IF( ( VeryLowRateSTflag && ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, AUDIO_CLAS ) ) ) ) /* Do not apply normalization on VOICED signal in case of stereo */
{
Copy( dct_in_fx, exc_diffQ, L_FRAME );
/* normalization of the spectrum and noise fill */
normalize_spec_fx( 1 * 256, exc_diffQ + mDiff_len, sub( L_FRAME, mDiff_len ), NORMALIZE_SPECS_Q_OUT );
}
ELSE
#endif
{
Copy( dct_in_fx, exc_diffQ_fx, mDiff_len ); /* Q_dct_in */
set16_fx( exc_diffQ_fx + mDiff_len, 0, sub( L_FRAME, mDiff_len ) );
......@@ -387,10 +359,6 @@ void improv_amr_wb_gs_fx(
const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/
const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/
const Word16 last_coder_type /* i : Last coder_type Q0*/
#ifdef ADD_IVAS_GS_DEC_IMPR
,
const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */
#endif
)
{
Word16 i, exp_a, exp_b, exp_diff, j;
......@@ -413,18 +381,10 @@ void improv_amr_wb_gs_fx(
test();
test();
test();
#ifdef ADD_IVAS_GS_DEC_IMPR
IF( VeryLowRateSTflag ||
( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
( EQ_16( clas, UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
EQ_16( coder_type, INACTIVE ) ) ) )
#else
IF( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
( ( clas == UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
( EQ_16( coder_type, INACTIVE ) ) ) )
#endif
{
/*------------------------------------------------------------*
* two differents paths:
......@@ -494,12 +454,7 @@ void improv_amr_wb_gs_fx(
* Go back to time domain -> Overwrite exctiation
*------------------------------------------------------------*/
edct_16fx( exc2_fx, dct_exc_in_fx, L_FRAME, 6, EVS_MONO );
gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type
#ifdef ADD_IVAS_GS_DEC_IMPR
,
VeryLowRateSTflag
#endif
);
gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type );
edct_16fx( dct_exc_out_fx, exc2_fx, L_FRAME, 6, EVS_MONO );
/*------------------------------------------------------------*
......
......@@ -99,17 +99,11 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
max_brate = HQ_48k; /* Q0 */
move32();
}
#ifndef SOLVED_COMP_ENC_DEC
test();
test();
test();
test();
IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_FRAME48k ) ) && LE_32( core_brate, max_brate ) )
#else
/*_DIFF_FLOAT_FIX_ -> could this modification break the interoperability with EVS ?? */
test();
IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_SPEC48k ) ) && LE_32( core_brate, max_brate ) )
#endif
{
*hqswb_clas = get_next_indice( st_fx, 2 ); /* Q0 */
move16();
......@@ -147,11 +141,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
*hqswb_clas = HQ_GEN_SWB; /* Q0 */
move16();
}
#ifndef SOLVED_COMP_ENC_DEC
ELSE IF( EQ_16( length, L_FRAME48k ) )
#else
ELSE IF( EQ_16( length, L_SPEC48k ) )
#endif
{
*hqswb_clas = HQ_GEN_FB; /* Q0 */
move16();
......
......@@ -78,22 +78,10 @@ void hq_core_dec_fx(
/*num_bits = (short)(st->total_brate / 50); */
Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
num_bits = extract_l( L_shr( L_tmp, 3 ) ); /*Q0 */
#ifdef ADD_IVAS_HQ_CODE_L_SPEC
/* Set default spectrum length */
L_spec = l_spec_tbl[st_fx->bwidth];
#endif
IF( !st_fx->bfi )
{
IF( EQ_16( core_switching_flag, 1 ) )
{
#ifdef ADD_IVAS_HQ_CODE_L_SPEC
IF( NE_16( st_fx->element_mode, EVS_MONO ) )
{
L_spec = l_spec_ext_tbl[st_fx->bwidth];
}
ELSE
#endif
{
core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame );
......@@ -105,12 +93,6 @@ void hq_core_dec_fx(
}
}
}
#ifdef ADD_IVAS_HQ_CODE
IF( hq_recovery_flag )
{
acelp_plc_mdct_transition( st );
}
#endif
/* subtract signalling bits */
num_bits = sub( num_bits, st_fx->next_bit_pos ); /* Q0 */
......@@ -145,9 +127,7 @@ void hq_core_dec_fx(
/* set inner frame (== coded bandwidth) length */
inner_frame = inner_frame_tbl[st_fx->bwidth]; /* Q0 */
move16();
#ifndef ADD_IVAS_HQ_CODE_L_SPEC
L_spec = inner_frame; /* Q0 */
#endif
move16();
IF( st_fx->bfi == 0 )
......@@ -233,12 +213,6 @@ void hq_core_dec_fx(
move16();
}
#ifdef ADD_IVAS_HQ_CODE
test();
test();
test();
IF( EQ_16( st_fx->element_mode, EVS_MONO ) || ( !core_switching_flag && !hq_recovery_flag ) )
#endif
{
/* scaling (coefficients are in nominal level) */
IF( NE_16( output_frame, NORM_MDCT_FACTOR ) )
......@@ -322,59 +296,6 @@ void hq_core_dec_fx(
* Overlap-add
* Pre-echo reduction
*--------------------------------------------------------------------------*/
#ifdef ADD_IVAS_HQ_CODE
if ( st->element_mode > EVS_MONO && ( core_switching_flag || hq_recovery_flag ) )
{
/* Initializations for TCX MDCT framework, to be used for switching frame */
tcx_cfg = st->hTcxCfg;
L_frameTCX_glob = hTcxDec->L_frameTCX;
L_frame_glob = st->L_frame;
L_spec = hTcxDec->L_frameTCX;
st->fscale = sr2fscale( st->sr_core );
fscaleFB = sr2fscale( st->output_Fs );
encoderLookahead = ( L_LOOK_12k8 * st->fscale ) / FSCALE_DENOM;
encoderLookaheadFB = ( L_LOOK_12k8 * fscaleFB ) / FSCALE_DENOM;
mdctWindowLength = getMdctWindowLength( st->fscale );
mdctWindowLengthFB = (int16_t) ( mdctWindowLength * st->output_Fs / st->sr_core );
if ( core_switching_flag )
{
tcx_cfg->tcx_last_overlap_mode = TRANSITION_OVERLAP;
tcx_cfg->tcx_curr_overlap_mode = FULL_OVERLAP;
}
else
{
tcx_cfg->tcx_last_overlap_mode = ALDO_WINDOW;
tcx_cfg->tcx_curr_overlap_mode = ALDO_WINDOW;
st->last_core = HQ_CORE; /* Needed to decode non-transition frame */
}
init_tcx_window_cfg( tcx_cfg, st->sr_core, st->output_Fs, st->L_frame, hTcxDec->L_frameTCX, encoderLookahead, encoderLookaheadFB, mdctWindowLength, mdctWindowLengthFB, st->element_mode );
init_tcx_info( st, L_frame_glob, L_frameTCX_glob, 0, st->bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
overlap = tcx_cfg->tcx_mdct_window_length;
overlapFB = tcx_cfg->tcx_mdct_window_lengthFB;
index = tcx_cfg->tcx_last_overlap_mode;
/* LB synthesis */
IMDCT_fx( t_audio_q, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, wtda_audio, tcx_cfg->tcx_aldo_window_1_trunc, tcx_cfg->tcx_aldo_window_2, tcx_cfg->tcx_mdct_window_half, tcx_cfg->tcx_mdct_window_minimum, tcx_cfg->tcx_mdct_window_trans, tcx_cfg->tcx_mdct_window_half_length, tcx_cfg->tcx_mdct_window_min_length, index,
MDCT_IV, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, 0, st->bfi, hHQ_core->old_outLB, 0, st, 0, acelp_zir );
mvr2r( wtda_audio + ( overlap >> 1 ) - tcx_offset, output, L_frame_glob );
/* FB synthesis */
IMDCT_fx( t_audio_q, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, wtda_audio, tcx_cfg->tcx_aldo_window_1_FB_trunc, tcx_cfg->tcx_aldo_window_2_FB, tcx_cfg->tcx_mdct_window_halfFB, tcx_cfg->tcx_mdct_window_minimumFB, tcx_cfg->tcx_mdct_window_transFB, tcx_cfg->tcx_mdct_window_half_lengthFB, tcx_cfg->tcx_mdct_window_min_lengthFB, index,
MDCT_IV, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, 0, st->bfi, hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir );
mvr2r( wtda_audio + ( overlapFB >> 1 ) - tcx_offsetFB, synth, L_frameTCX_glob );
if ( !core_switching_flag )
{
st->last_core = ACELP_CORE; /* Restore last core */
}
}
else
#endif
{
test();
IF( EQ_16( output_frame, L_FRAME8k ) || st_fx->bfi == 0 )
......@@ -392,24 +313,6 @@ void hq_core_dec_fx(
move16();
}
}
#ifdef ADD_IVAS_HQ_CODE
if ( st->element_mode > EVS_MONO )
{
if ( st->bfi )
{
/* Rough resampling, but reduces energy loss in case of switch to ACELP in first good frame */
lerp( t_audio_q, wtda_audio_LB, st->L_frame, inner_frame );
v_multc( t_audio_q, 0.5f, wtda_audio_LB, st->L_frame );
}
else
{
/* LB synthesis for potential switch to ACELP */
ener_match = (float) sqrt( (float) st->L_frame / (float) output_frame );
v_multc( t_audio_q, ener_match, t_audio_q, inner_frame );
inverse_transform( t_audio_q, wtda_audio_LB, is_transient, st->L_frame, inner_frame, st->element_mode );
}
}
#endif
IF( EQ_16( output_frame, L_FRAME8k ) )
{
test();
......@@ -465,13 +368,6 @@ void hq_core_dec_fx(
window_ola_fx( wtda_audio, synth, Q_synth, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, output_frame,
st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx );
}
#ifdef ADD_IVAS_HQ_CODE
if ( st->element_mode > EVS_MONO )
{
/* LB synthesis for potential switch to ACELP */
window_ola( wtda_audio_LB, output, hHQ_core->old_outLB, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, st->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth );
}
#endif
test();
test();
IF( ( st_fx->bfi == 0 && st_fx->prev_bfi == 0 ) || !( GE_16( output_frame, L_FRAME16k ) ) )
......@@ -561,13 +457,6 @@ void hq_core_dec_fx(
Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[nbsubfr + 2], nbsubfr ); /* Q14 */
set16_fx( &st_fx->mem_pitch_gain[2], 0, nbsubfr );
}
#ifdef ADD_IVAS_HQ_CODE
/* Move LB excitation to old_exc memory in case of switch HQ->ACELP */
if ( st->element_mode > EVS_MONO )
{
mvr2r( output, st->old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame );
}
#endif
return;
}
......
......@@ -46,7 +46,6 @@ void ivas_hq_pred_hb_bws_fx(
}
ELSE
{
// EVS_FUNC_MODIFIED
st_fx->prev_ener_shb_fx = 0;
move16();
L_tmp = L_deposit_l( 0 );
......
......@@ -244,7 +244,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in
g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15
g = shl( g, 1 ); // Q16
g = shl_sat( g, 1 ); // Q16
FOR( sb = start; sb < stop; sb++ )
{
......
......@@ -398,7 +398,7 @@ ivas_error ivas_mct_dec_fx(
test();
IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) )
{
Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11
Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], output_frame, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) );
ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 );
Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( sub( 15, e_sig[n] ), Q11 ) ); // Q0
......
......@@ -239,16 +239,6 @@ void ivas_renderer_select(
move16();
}
#if 0 // def DEBUGGING /*temp disabling this as paramMC crashes with CREND*/
IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND )
{
*renderer_type = RENDERER_BINAURAL_MIXER_CONV;
}
ELSE IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV )
{
*renderer_type = RENDERER_BINAURAL_FASTCONV;
}
#endif
test();
IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
......
......@@ -102,6 +102,8 @@ void stereo_dft_unify_dmx_fx(
Word16 num_plocs;
Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX];
set32_fx( DFT_PRED_RES, 0, STEREO_DFT32MS_N_32k );
output_frame = extract_l( Mult_32_16( st0->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */
samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio );
samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) );
......
......@@ -402,6 +402,8 @@ ivas_error stereo_dft_dec_create_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) );
}
set_zero_fx( hStereoDft_loc->hb_nrg_subr_fx, STEREO_DFT_NBDIV ); /*Setting hb_nrg_subr_fx to zero*/
hStereoDft_loc->q_hb_nrg_subr = Q31;
move16();
hStereoDft_loc->hConfig->force_mono_transmission = 0;
move16();
......
/******************************************************************************************************
/******************************************************************************************************
(C) 2022-2025 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.,
......
......@@ -26,11 +26,8 @@ typedef Word32 ( *TLinearPredictionFilter )( Word16 order, Word16 const parCoeff
*
*
*---------------------------------------------------------------------*/
#ifdef IVAS_CODE
void
#else
Word16
#endif
ReadTnsData(
STnsConfig const *pTnsConfig,
Decoder_State *st,
......@@ -47,20 +44,6 @@ ReadTnsData(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
#ifdef IVAS_CODE
IF( pTnsConfig->allowTnsOnWhite )
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, st, &stream, pnSize );
}
ELSE
{
ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, st, &stream, pnSize );
}
}
ELSE
#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
......@@ -81,20 +64,10 @@ ReadTnsData(
move16();
*pnBits = sub( st->next_bit_pos, start_bit_pos );
#ifdef IVAS_CODE
return;
#else
return TNS_NO_ERROR;
#endif
}
#define IVAS_CODE
#ifdef IVAS_CODE
void
#else
Word16
#endif
ReadTnsData_ivas_fx(
void ReadTnsData_ivas_fx(
STnsConfig const *pTnsConfig,
Decoder_State *st,
Word16 *pnBits, /*Q0*/
......@@ -109,7 +82,6 @@ ReadTnsData_ivas_fx(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
#ifdef IVAS_CODE
IF( pTnsConfig->allowTnsOnWhite )
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
......@@ -122,7 +94,6 @@ ReadTnsData_ivas_fx(
}
}
ELSE
#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
......@@ -143,13 +114,9 @@ ReadTnsData_ivas_fx(
move16();
*pnBits = sub( st->next_bit_pos, start_bit_pos );
#ifdef IVAS_CODE
return;
#else
return TNS_NO_ERROR;
#endif
}
#undef IVAS_CODE
/*---------------------------------------------------------------------*
* DecodeTnsData()
*
......@@ -169,21 +136,6 @@ Word16 DecodeTnsData(
IF( GT_16( pTnsConfig->nMaxFilters, 1 ) )
{
#ifdef IVAS_CODE
IF( pTnsConfig->allowTnsOnWhite )
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
SetParameters( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize );
}
ELSE
{
SetParameters( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize );
}
}
ELSE
#endif
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
......
......@@ -103,18 +103,6 @@ ivas_error TonalMDCTConceal_Init(
hTonalMDCTConc->nScaleFactors = nScaleFactors;
move16();
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
PMTE()
set_zero( hTonalMDCTConc->scaleFactorsBackground, FDNS_NPTS );
PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 );
PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 );
hTonalMDCTConc->psychParams = NULL;
hTonalMDCTConc->scf_fadeout = 1.0f;
hTonalMDCTConc->last_block_nrg = 0.0f;
hTonalMDCTConc->curr_noise_nrg = 0.0f;
hTonalMDCTConc->faded_signal_nrg = 0.0f;
#endif
/* Offset the pointer to the end of buffer, so that pTCI is not destroyed when
new time samples are stored in lastPcmOut */
move16();
......@@ -198,9 +186,6 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
hTonalMDCTConc->nScaleFactors = nScaleFactors;
move16();
//#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
// PMTE()
// To be uncommented when field of fixed type is added for scaleFactorsBackground
set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS );
hTonalMDCTConc->scf_fadeout = 16384 /*1.000000 Q14*/;
PsychoacousticParameters_Init_fx( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 );
......@@ -242,12 +227,7 @@ void TonalMDCTConceal_SaveFreqSignal(
Word16 nNewSamplesCore, // Q0
const Word16 *scaleFactors, // Q31-scaleFactors_exp
const Word16 *scaleFactors_exp,
const Word16 gain_tcx_exp
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
,
const int16_t infoIGFStartLine
#endif
)
const Word16 gain_tcx_exp )
{
Word16 *temp;
Word16 nOldSamples, tmp_exp, s, i, max_exp;
......@@ -340,20 +320,6 @@ void TonalMDCTConceal_SaveFreqSignal(
test();
IF( ( nNewSamples > 0 ) && ( LE_16( nNewSamples, 2 * L_FRAME_MAX ) ) )
{
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
int16_t i;
PMTE()
hTonalMDCTConc->last_block_nrg_flt = 0.0f;
for ( i = 0; i < infoIGFStartLine; i++ )
{
hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i];
hTonalMDCTConc->last_block_nrg_flt += mdctSpectrum[i] * mdctSpectrum[i];
}
for ( ; i < nNewSamples; i++ )
{
hTonalMDCTConc->lastBlockData.spectralData[i] = mdctSpectrum[i];
}
#else
/* Store new data */
s = getScaleFactor32( mdctSpectrum, nNewSamples );
......@@ -375,7 +341,6 @@ void TonalMDCTConceal_SaveFreqSignal(
move16();
}
hTonalMDCTConc->lastBlockData.spectralData_exp = sub( mdctSpectrum_exp, s );
#endif
move16();
hTonalMDCTConc->lastBlockData.gain_tcx_exp = gain_tcx_exp;
......@@ -2207,19 +2172,12 @@ void TonalMDCTConceal_InsertNoise(
Word16 *pSeed, /*IN/OUT*/
const Word16 tiltCompFactor, // Q15
Word16 crossfadeGain, // Q15
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
const Word16concealment_noise[L_FRAME48k],
const float cngLevelBackgroundTrace_bfi,
#endif
const Word16 crossOverFreq )
{
Word16 i, ld, fac;
Word16 rnd, exp, exp_last, exp_noise, inv_samples, inv_exp;
Word16 g, tiltFactor, tilt, tmp;
Word32 nrgNoiseInLastFrame, nrgWhiteNoise, L_tmp, L_tmp2;
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
float last_block_nrg_correct;
#endif
g = sub( 32767 /*1.0f Q15*/, crossfadeGain );
......@@ -2230,16 +2188,6 @@ void TonalMDCTConceal_InsertNoise(
rnd = *pSeed;
move16();
}
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
/* based on what is done in tcx_noise_filling() */
/* always initialize these to avoid compiler warnings */
tiltFactor = (float) pow( max( 0.375f, tiltCompFactor ), 1.0f / hTonalMDCTConc->lastBlockData.nSamples );
tilt = 1.0f;
nrgNoiseInLastFrame = 0.0f;
nrgWhiteNoise = 0.0f;
hTonalMDCTConc->faded_signal_nrg_flt = 0.0f;
last_block_nrg_correct = 0.0f;
#endif
IF( hTonalMDCTConc->lastBlockData.blockIsValid == 0 )
{
/* may just become active if the very first frame is lost */
......@@ -2247,199 +2195,8 @@ void TonalMDCTConceal_InsertNoise(
*mdctSpectrum_exp = SPEC_EXP_DEC;
move16();
}
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
else if ( concealment_noise != NULL )
{
if ( !tonalConcealmentActive )
{
/* if fadeout has not started yet, only apply sign scrambling */
if ( crossfadeGain == 1.0f )
{
for ( i = 0; i < crossOverFreq; i++ )
{
if ( concealment_noise[i] > 0 )
{
mdctSpectrum[i] = hTonalMDCTConc->lastBlockData.spectralData[i];
}
else
{
mdctSpectrum[i] = -hTonalMDCTConc->lastBlockData.spectralData[i];
}
}
for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
{
mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
}
}
/* actual fadeout is done in this case */
else
{
g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg_flt );
for ( i = 0; i < crossOverFreq; i++ )
{
x = hTonalMDCTConc->lastBlockData.spectralData[i];
y = concealment_noise[i];
if ( y > 0 )
{
mdctSpectrum[i] = g * y + crossfadeGain * x;
}
else
{
mdctSpectrum[i] = g * y - crossfadeGain * x;
}
hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[i] * mdctSpectrum[i];
}
for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
{
mdctSpectrum[l] = 0.0f;
}
}
}
else
{
assert( hTonalMDCTConc->pTCI->numIndexes > 0 );
/* initialize bins of tonal components with zero: basically not
necessary, but currently the whole spectrum is rescaled in
mdct_noiseShaping() and then there would be a processing of
uninitialized values */
for ( i = 0; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
{
for ( l = hTonalMDCTConc->pTCI->lowerIndex[i]; l <= hTonalMDCTConc->pTCI->upperIndex[i]; l++ )
{
mdctSpectrum[l] = 0;
if ( l < crossOverFreq )
{
last_block_nrg_correct += hTonalMDCTConc->lastBlockData.spectralData[l] * hTonalMDCTConc->lastBlockData.spectralData[l];
hTonalMDCTConc->curr_noise_nrg_flt -= concealment_noise[l] * concealment_noise[l];
}
}
}
/* if fadeout has not started yet, only apply sign scrambling */
if ( crossfadeGain == 1.0f )
{
for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ )
{
if ( concealment_noise[l] > 0 )
{
mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
}
else
{
mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
}
}
for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
{
for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ )
{
if ( concealment_noise[l] > 0 )
{
mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
}
else
{
mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
}
}
}
for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ )
{
if ( concealment_noise[l] > 0 )
{
mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
}
else
{
mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l];
}
}
for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
{
mdctSpectrum[l] = hTonalMDCTConc->lastBlockData.spectralData[l];
}
}
/* actual fadeout is done in this case */
else
{
g *= (float) sqrt( cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg_flt );
for ( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ )
{
x = hTonalMDCTConc->lastBlockData.spectralData[l];
y = concealment_noise[l];
if ( y > 0 )
{
mdctSpectrum[l] = g * y + crossfadeGain * x;
}
else
{
mdctSpectrum[l] = g * y - crossfadeGain * x;
}
hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
}
for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
{
for ( l = hTonalMDCTConc->pTCI->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI->lowerIndex[i]; l++ )
{
x = hTonalMDCTConc->lastBlockData.spectralData[l];
y = concealment_noise[l];
if ( y > 0 )
{
mdctSpectrum[l] = g * y + crossfadeGain * x;
}
else
{
mdctSpectrum[l] = g * y - crossfadeGain * x;
}
hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
}
}
for ( l = hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1; l < crossOverFreq; l++ )
{
x = hTonalMDCTConc->lastBlockData.spectralData[l];
y = concealment_noise[l];
if ( y > 0 )
{
mdctSpectrum[l] = g * y + crossfadeGain * x;
}
else
{
mdctSpectrum[l] = g * y - crossfadeGain * x;
}
hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l];
}
for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
{
mdctSpectrum[l] = 0.0f;
}
}
}
if ( hTonalMDCTConc->faded_signal_nrg_flt > 0.0f && hTonalMDCTConc->curr_noise_nrg_flt > MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG )
{
float nrg_corr_factor;
nrg_corr_factor = sqrtf( ( hTonalMDCTConc->last_block_nrg_flt - last_block_nrg_correct ) / hTonalMDCTConc->faded_signal_nrg_flt );
v_multc( mdctSpectrum, nrg_corr_factor, mdctSpectrum, crossOverFreq );
}
}
#endif
ELSE
{
#ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
L_tmp = 805306368l /*0.375f Q31*/;
move32();
inv_exp = 15;
......@@ -2456,7 +2213,6 @@ void TonalMDCTConceal_InsertNoise(
nrgNoiseInLastFrame = L_deposit_h( 0 );
nrgWhiteNoise = L_deposit_h( 0 );
exp_last = exp_noise = 0;
#endif
move16();
move16();
IF( !tonalConcealmentActive )
......@@ -3576,216 +3332,3 @@ void TonalMdctConceal_whiten_noise_shape_ivas_fx(
pop_wmops();
}
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
void TonalMdctConceal_create_concealment_noise(
float concealment_noise[L_FRAME48k],
CPE_DEC_HANDLE hCPE,
const int16_t L_frameTCX,
const int16_t L_frame,
const int16_t idchan,
const int16_t subframe_idx,
const int16_t core,
const int16_t crossfade_gain,
const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode )
{
STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct;
TonalMDCTConcealPtr hTonalMDCTConc;
Decoder_State *st;
HANDLE_FD_CNG_COM hFdCngCom;
int16_t *rnd_c, *rnd;
int16_t crossOverFreq, i, save_rnd_c, max_noise_line;
float c, c_inv;
float noise_shape_buffer[L_FRAME48k];
int16_t inc, start_idx, stop_idx;
float *cngNoiseLevelPtr;
float last_scf;
wmops_sub_start( "create_conc_noise" );
hStereoMdct = hCPE->hStereoMdct;
st = hCPE->hCoreCoder[idchan];
hTonalMDCTConc = st->hTonalMDCTConc;
hFdCngCom = st->hFdCngDec->hFdCngCom;
rnd = &hStereoMdct->noise_seeds_channels[idchan];
rnd_c = &hStereoMdct->noise_seed_common;
/* determine start bin for IGF */
if ( st->igf == 0 )
{
if ( st->narrowBand == 0 )
{
/* minimum needed for output with sampling rates lower then the
nominal sampling rate */
crossOverFreq = min( L_frameTCX, L_frame );
}
else
{
crossOverFreq = L_frameTCX;
}
}
else
{
crossOverFreq = min( st->hIGFDec->infoIGFStartLine, L_frameTCX );
}
/* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */
max_noise_line = crossOverFreq;
if ( st->tonal_mdct_plc_active )
{
max_noise_line = max( max_noise_line, hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] + 1 );
}
/* first lost frame is handled separately */
if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed )
{
*rnd = 1977 + idchan;
/* will be set twice when looping over two channels, but does not matter */
*rnd_c = 1979;
}
if ( crossfade_gain == 1.0f )
{
/* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */
for ( i = 0; i < max_noise_line; i++ )
{
*rnd = own_random( rnd );
concealment_noise[i] = *rnd;
}
wmops_sub_end();
return;
}
save_rnd_c = *rnd_c;
c = sqrtf( hStereoMdct->lastCoh );
c_inv = sqrtf( 1 - hStereoMdct->lastCoh );
/* pre-compute the noise shape for later weighting of the noise spectra */
cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel_flt[0];
inc = ( st->core > TCX_20_CORE ) ? 2 : 1;
start_idx = hFdCngCom->startBand / inc;
stop_idx = hFdCngCom->stopFFTbin / inc;
for ( i = 0; i < start_idx; i++ )
{
noise_shape_buffer[i] = 0.0f;
}
for ( ; i < stop_idx; i++, cngNoiseLevelPtr += inc )
{
noise_shape_buffer[i] = sqrtf( *( cngNoiseLevelPtr ) );
}
last_scf = sqrtf( *( cngNoiseLevelPtr - inc ) );
for ( ; i < max_noise_line; i++ )
{
noise_shape_buffer[i] = last_scf;
}
/* fill the noise vector */
hTonalMDCTConc->curr_noise_nrg_flt = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG;
if ( noise_gen_mode == EQUAL_CORES || ( ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 1 ) ) )
{
/* current channel is TCX20 -> generate noise for "full-length" spectrum */
for ( i = 0; i < max_noise_line; i++ )
{
*rnd = own_random( rnd );
*rnd_c = own_random( rnd_c );
concealment_noise[i] = ( c_inv * *rnd + c * *rnd_c ) * noise_shape_buffer[i];
hTonalMDCTConc->curr_noise_nrg_flt += concealment_noise[i] * concealment_noise[i];
}
}
else /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */
{
/* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */
for ( i = 0; i < max_noise_line; i++ )
{
*rnd = own_random( rnd );
*rnd_c = own_random( rnd_c );
concealment_noise[i] = ( c_inv * *rnd + c * *rnd_c ) * noise_shape_buffer[i];
hTonalMDCTConc->curr_noise_nrg_flt += concealment_noise[i] * concealment_noise[i];
*rnd_c = own_random( rnd_c );
}
}
if ( st->tonal_mdct_plc_active )
{
for ( i = crossOverFreq; i < max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i )
{
concealment_noise[i] *= 0.0f;
}
}
/* restore common seed
- after finishing the first channel
- after a first subframe if the current channel is TCX10 */
if ( ( idchan == 0 && ( core == TCX_20 || ( core == TCX_10 && subframe_idx == 1 ) ) ) || ( core == TCX_10 && subframe_idx == 0 ) )
{
*rnd_c = save_rnd_c;
}
st->seed_tcx_plc = *rnd;
wmops_sub_end();
return;
}
void TonalMdctConceal_whiten_noise_shape(
Decoder_State *st,
const int16_t L_frame,
const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode )
{
int16_t inc, start_idx, stop_idx;
float *noiseLevelPtr, *scfs_bg, *scfs_for_shaping;
HANDLE_FD_CNG_COM hFdCngCom;
float whitenend_noise_shape[L_FRAME16k];
float scfs_int[FDNS_NPTS];
const PsychoacousticParameters *psychParams;
push_wmops( "apply_sns_on_noise_shape" );
scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_flt[0];
psychParams = st->hTonalMDCTConc->psychParams;
hFdCngCom = st->hFdCngDec->hFdCngCom;
inc = ( ( whitening_mode == ON_FIRST_LOST_FRAME ? st->core : st->last_core ) > TCX_20_CORE ) ? 2 : 1;
start_idx = hFdCngCom->startBand / inc;
stop_idx = L_frame / inc;
noiseLevelPtr = hFdCngCom->cngNoiseLevel_flt;
set_zero( whitenend_noise_shape, start_idx );
for ( int16_t j = start_idx; j < stop_idx; j++, noiseLevelPtr += inc )
{
whitenend_noise_shape[j] = *noiseLevelPtr;
}
if ( whitening_mode == ON_FIRST_LOST_FRAME )
{
float scf[SNS_NPTS];
sns_compute_scf( whitenend_noise_shape, psychParams, L_frame, scf );
sns_interpolate_scalefactors( scfs_int, scf, ENC );
sns_interpolate_scalefactors( scfs_bg, scf, DEC );
scfs_for_shaping = &scfs_int[0];
}
else /* whitening_mode == ON_FIRST_GOOD_FRAME */
{
scfs_for_shaping = &scfs_bg[0];
}
if ( sum_f( scfs_for_shaping, FDNS_NPTS ) > 0.0f )
{
sns_shape_spectrum( whitenend_noise_shape, psychParams, scfs_for_shaping, L_frame );
mvr2r( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel_flt, stop_idx - start_idx );
}
else
{
set_zero( hFdCngCom->cngNoiseLevel_flt, stop_idx - start_idx );
}
pop_wmops();
}
#endif
......@@ -576,23 +576,6 @@ void updt_dec_common_fx(
test();
test();
test();
#ifdef IVAS_CODE
/* Store long-term estimates of stab_fac and log energy diff to estimate env_stab in case of core switch ACELP/TCX->HQ */
if ( st->element_mode != EVS_MONO )
{
output_frame = NS2SA( st->output_Fs, FRAME_SIZE_NS );
log_energy = log2f( ( sum2_f( synth, output_frame ) / output_frame ) + 1.0f );
log_energy_diff = fabsf( st->log_energy_old - log_energy );
st->log_energy_old = log_energy;
st->log_energy_diff_lt = ENV_SMOOTH_FAC * log_energy_diff + ( 1.0f - ENV_SMOOTH_FAC ) * st->log_energy_diff_lt;
if ( st->core == HQ_CORE )
{
st->stab_fac = min( 1, ( STAB_FAC_EST1 + ( STAB_FAC_EST2 * st->hHQ_core->mem_env_delta ) + ( STAB_FAC_EST3 * st->log_energy_diff_lt ) ) );
st->stab_fac = max( 0, st->stab_fac );
}
st->stab_fac_smooth_lt = ENV_SMOOTH_FAC * st->stab_fac + ( 1.0f - ENV_SMOOTH_FAC ) * st->stab_fac_smooth_lt;
}
#endif
IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) )
{
......@@ -964,23 +947,6 @@ void ivas_updt_dec_common_fx(
test();
test();
test();
#ifdef IVAS_CODE
/* Store long-term estimates of stab_fac and log energy diff to estimate env_stab in case of core switch ACELP/TCX->HQ */
if ( st->element_mode != EVS_MONO )
{
output_frame = NS2SA( st->output_Fs, FRAME_SIZE_NS );
log_energy = log2f( ( sum2_f( synth, output_frame ) / output_frame ) + 1.0f );
log_energy_diff = fabsf( st->log_energy_old - log_energy );
st->log_energy_old = log_energy;
st->log_energy_diff_lt = ENV_SMOOTH_FAC * log_energy_diff + ( 1.0f - ENV_SMOOTH_FAC ) * st->log_energy_diff_lt;
if ( st->core == HQ_CORE )
{
st->stab_fac = min( 1, ( STAB_FAC_EST1 + ( STAB_FAC_EST2 * st->hHQ_core->mem_env_delta ) + ( STAB_FAC_EST3 * st->log_energy_diff_lt ) ) );
st->stab_fac = max( 0, st->stab_fac );
}
st->stab_fac_smooth_lt = ENV_SMOOTH_FAC * st->stab_fac + ( 1.0f - ENV_SMOOTH_FAC ) * st->stab_fac_smooth_lt;
}
#else
IF( st_fx->element_mode != EVS_MONO )
{
Word16 q_div = sub( Q31, shl( Qpostd, 1 ) );
......@@ -1003,7 +969,6 @@ void ivas_updt_dec_common_fx(
st_fx->stab_fac_smooth_lt_fx = extract_h( L_add( L_mult( ENV_SMOOTH_FAC_FX, st_fx->stab_fac_fx ),
L_mult( sub( MAX_16, ENV_SMOOTH_FAC_FX ), st_fx->stab_fac_smooth_lt_fx ) ) ); // Q15
}
#endif
test();
test();
......
......@@ -180,9 +180,9 @@ void E_ACELP_conv(
}
void E_ACELP_conv_ivas_fx(
const Word16 xn2[], /* i Qx*/
const Word16 xn2[], /* i Qnew - 1*/
const Word16 h2[], /* i Q12*/
Word16 cn2[] /* o Q0*/
Word16 cn2[] /* o Qnew*/
)
{
Word16 i, k;
......@@ -194,14 +194,14 @@ void E_ACELP_conv_ivas_fx(
{
/*cn2[k] = xn2[k]; */
Word64 L_tmp_64;
L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* 4Q11 */
L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* Qnew -1 + 12 */
FOR( i = 0; i < k; i++ )
{
/*cn2[k]-=cn2[i]*h2[k-i];*/
L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/
}
L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/
L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */
cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/
move16();
}
}
......