Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,7 @@ #define NONBE_FIX_1069_SVD_TUNING /* FhG: issue 1069: tune SVD constants */ #define FIX_778_STEREO_BRATE_SWITCHING #define FIX_774_ENERGY_BURST /* Fix 0 bit BWE */ #define FIX_729_MISSING_RESCALING /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading lib_com/swb_tbe_com_fx.c +15 −0 Original line number Diff line number Diff line Loading @@ -727,6 +727,9 @@ static void filt_mu_fx( Word16 mu, ga, temp; const Word16 *ptrs; Word16 tmp, exp; #ifdef FIX_729_MISSING_RESCALING Flag Overflow = 0; #endif IF( EQ_16( SubFrameLength, L_SUBFR ) ) Loading Loading @@ -767,7 +770,19 @@ static void filt_mu_fx( { temp = mult_r( mu, ( *ptrs++ ) ); temp = add( temp, *ptrs ); /*Q12 */ #ifdef FIX_729_MISSING_RESCALING sig_out[n] = shl_o( mult_r( ga, temp ), 1, &Overflow ); #ifdef DEBUGGING if ( Overflow ) { fprintf( stderr, "Saturation in filt_mu_fx for ga = %d, temp = %d, result = %.2f at frame %d\n\n", ga, temp, (float) ga * temp * 4.0 / 65536.0, frame ); Overflow = 0; } #endif #else sig_out[n] = shl( mult_r( ga, temp ), 1 ); #endif move16(); /*Q12 */ } Loading lib_com/tcx_utils_fx.c +2 −2 Original line number Diff line number Diff line Loading @@ -1787,7 +1787,7 @@ void tcx_noise_filling( win = add( win, 1 ); } seed = own_random2_fx( seed ); Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); move32(); Loading Loading @@ -1952,7 +1952,7 @@ void tcx_noise_filling_with_shift( Word16 nrm = 31; seed = own_random2_fx( seed ); Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); IF( Q[i] ) { Loading lib_dec/FEC_HQ_phase_ecu_fx.c +6 −6 Original line number Diff line number Diff line Loading @@ -2383,7 +2383,7 @@ static void ivas_subst_spec_fx( IF( NE_16( ph_dith, 0 ) ) { Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ *seed = own_random2_fx( *seed ); /* in Q0 */ Random( seed ); /* in Q0 */ acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ Loading Loading @@ -2783,7 +2783,7 @@ static void subst_spec_fx( IF( ph_dith != 0 ) { Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ *seed = own_random2_fx( *seed ); /* in Q0 */ Random( seed ); /* in Q0 */ acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ Loading lib_dec/core_switching_dec.c +107 −7 Original line number Diff line number Diff line Loading @@ -81,8 +81,12 @@ ivas_error core_switching_pre_dec_ivas_fx( Word16 exp = 25; error = IVAS_ERR_OK; move32(); /* Codec mode switching */ test(); test(); test(); IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { #ifndef FIX_770_DISCONTINUITIES_SW_TCX2ACELP Loading Loading @@ -119,6 +123,7 @@ ivas_error core_switching_pre_dec_ivas_fx( { st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ st->hBPF->pst_mem_deemp_err_fx = 0; move16(); } #endif st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); Loading @@ -136,6 +141,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); test(); IF( st->hBWE_TD != NULL && NE_16( st->last_core, ACELP_CORE ) ) { #ifdef MSAN_FIX Loading @@ -155,6 +161,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->igf = 0; move16(); test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading Loading @@ -196,6 +203,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } test(); IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) { IF( EQ_16( st->element_mode, EVS_MONO ) ) Loading Loading @@ -238,6 +246,8 @@ ivas_error core_switching_pre_dec_ivas_fx( delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); /*TODO To be tested:control not entering the block*/ test(); test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ Loading Loading @@ -281,6 +291,8 @@ ivas_error core_switching_pre_dec_ivas_fx( Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); } test(); test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, output_frame / 2, st->last_L_frame / 2 ); Loading @@ -298,6 +310,7 @@ ivas_error core_switching_pre_dec_ivas_fx( /*FEC*/ IF( LE_16( st->L_frame, L_FRAME16k ) ) { test(); IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) { IF( NE_16( st->L_frame, st->last_L_frame ) ) Loading Loading @@ -325,6 +338,8 @@ ivas_error core_switching_pre_dec_ivas_fx( /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || NE_16( st->last_codec_mode, MODE2 ) ) ) { st->last_ppp_mode_dec = 0; Loading @@ -334,6 +349,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Handle state reset of stat_noise_uv_mod memory */ test(); test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) { st->act_count = 3; Loading @@ -342,9 +360,21 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); } test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); IF( ( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) { test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { st->hPFstat->reset = 1; Loading @@ -368,6 +398,12 @@ ivas_error core_switching_pre_dec_ivas_fx( lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); } test(); test(); test(); test(); test(); test(); IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ Loading Loading @@ -430,6 +466,8 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_reset_memory_fx( st->cldfbSyn ); /* reset TBE memories */ test(); test(); IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); Loading @@ -445,6 +483,7 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading @@ -459,6 +498,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } } test(); test(); test(); IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) { IF( st->hBWE_TD != NULL ) Loading Loading @@ -491,6 +533,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); move16(); test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading @@ -504,6 +547,9 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } test(); test(); test(); IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) { /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ Loading @@ -514,14 +560,19 @@ ivas_error core_switching_pre_dec_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); } Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, Q10 - Q_old_synthFB ); Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; move16(); IF( old_synthFB_fx ) free( old_synthFB_fx ); } } test(); test(); test(); test(); IF( EQ_16( st->core, HQ_CORE ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( NE_16( st->element_mode, EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) { set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); Loading @@ -545,7 +596,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { /* Estimate mem_env_delta to reinit env_stab */ tmp_fx = L_max( 0, ENV_STAB_EST1_FX + Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ) + Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ); /*Q12*/ tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ Loading Loading @@ -609,6 +660,12 @@ ivas_error core_switching_pre_dec_ivas_fx( /*switch on CNA on active frames*/ IF( EQ_16( st->element_mode, EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ { test(); test(); test(); test(); test(); test(); IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) { st->flag_cna = 1; Loading @@ -628,6 +685,10 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Reconfigure CNG */ test(); test(); test(); test(); IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || EQ_16( st->ini_frame, 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) { /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ Loading @@ -645,24 +706,29 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } } test(); test(); IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) { test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth2 ); L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth ); L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); move32(); } } ELSE Loading @@ -670,6 +736,7 @@ ivas_error core_switching_pre_dec_ivas_fx( FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); move32(); } } } Loading Loading @@ -1682,6 +1749,8 @@ void bandwidth_switching_detect_ivas_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ) { test(); test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ Loading @@ -1698,6 +1767,7 @@ void bandwidth_switching_detect_ivas_fx( test(); test(); test(); test(); IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) { st_fx->bws_cnt1 = 0; Loading Loading @@ -1932,6 +2002,9 @@ void ivas_bw_switching_pre_proc_fx( return; } test(); test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) { /*----------------------------------------------------------------------* Loading @@ -1958,9 +2031,10 @@ void ivas_bw_switching_pre_proc_fx( tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; st->enerLL_fx_Q = ( Q + shift - 32 ) / 2; st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); W_tmp = 0; move64(); FOR( ; i < L_FRAME; i++ ) { W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); Loading @@ -1971,7 +2045,8 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( tmp, 7 ); // divide by 128 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; st->enerLH_fx_Q = ( Q + shift - 32 ) / 2; move32(); st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); } ELSE { Loading @@ -1985,9 +2060,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); L_tmp = 0; move32(); FOR( ; i < 64; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -1996,12 +2074,15 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; move32(); st->enerLH_fx_Q = Q_audio; move16(); } ELSE { Word32 tmp, L_tmp = 0; L_tmp = 0; move32(); FOR( i = 0; i < L_FRAME / 2; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -2009,9 +2090,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); L_tmp = 0; move32(); FOR( ; i < L_FRAME; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -2019,15 +2103,25 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); } } test(); test(); test(); test(); test(); test(); test(); IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) { // st->prev_ener_shb = 0.0f; st->prev_ener_shb_fx = 0; move16(); IF( st->hBWE_FD != NULL ) { // set_f( st->hBWE_FD->prev_SWB_fenv, 0, SWB_FENV ); Loading @@ -2037,12 +2131,18 @@ void ivas_bw_switching_pre_proc_fx( ELSE IF( ( ( EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) { st->attenu_fx = 3277; move16(); } test(); test(); test(); test(); test(); IF( EQ_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) { st->prev_fractive = 0; st->prev_fractive = 0; move16(); } return; Loading Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,7 @@ #define NONBE_FIX_1069_SVD_TUNING /* FhG: issue 1069: tune SVD constants */ #define FIX_778_STEREO_BRATE_SWITCHING #define FIX_774_ENERGY_BURST /* Fix 0 bit BWE */ #define FIX_729_MISSING_RESCALING /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading
lib_com/swb_tbe_com_fx.c +15 −0 Original line number Diff line number Diff line Loading @@ -727,6 +727,9 @@ static void filt_mu_fx( Word16 mu, ga, temp; const Word16 *ptrs; Word16 tmp, exp; #ifdef FIX_729_MISSING_RESCALING Flag Overflow = 0; #endif IF( EQ_16( SubFrameLength, L_SUBFR ) ) Loading Loading @@ -767,7 +770,19 @@ static void filt_mu_fx( { temp = mult_r( mu, ( *ptrs++ ) ); temp = add( temp, *ptrs ); /*Q12 */ #ifdef FIX_729_MISSING_RESCALING sig_out[n] = shl_o( mult_r( ga, temp ), 1, &Overflow ); #ifdef DEBUGGING if ( Overflow ) { fprintf( stderr, "Saturation in filt_mu_fx for ga = %d, temp = %d, result = %.2f at frame %d\n\n", ga, temp, (float) ga * temp * 4.0 / 65536.0, frame ); Overflow = 0; } #endif #else sig_out[n] = shl( mult_r( ga, temp ), 1 ); #endif move16(); /*Q12 */ } Loading
lib_com/tcx_utils_fx.c +2 −2 Original line number Diff line number Diff line Loading @@ -1787,7 +1787,7 @@ void tcx_noise_filling( win = add( win, 1 ); } seed = own_random2_fx( seed ); Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); move32(); Loading Loading @@ -1952,7 +1952,7 @@ void tcx_noise_filling_with_shift( Word16 nrm = 31; seed = own_random2_fx( seed ); Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); IF( Q[i] ) { Loading
lib_dec/FEC_HQ_phase_ecu_fx.c +6 −6 Original line number Diff line number Diff line Loading @@ -2383,7 +2383,7 @@ static void ivas_subst_spec_fx( IF( NE_16( ph_dith, 0 ) ) { Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ *seed = own_random2_fx( *seed ); /* in Q0 */ Random( seed ); /* in Q0 */ acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ Loading Loading @@ -2783,7 +2783,7 @@ static void subst_spec_fx( IF( ph_dith != 0 ) { Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ *seed = own_random2_fx( *seed ); /* in Q0 */ Random( seed ); /* in Q0 */ acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ Loading
lib_dec/core_switching_dec.c +107 −7 Original line number Diff line number Diff line Loading @@ -81,8 +81,12 @@ ivas_error core_switching_pre_dec_ivas_fx( Word16 exp = 25; error = IVAS_ERR_OK; move32(); /* Codec mode switching */ test(); test(); test(); IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { #ifndef FIX_770_DISCONTINUITIES_SW_TCX2ACELP Loading Loading @@ -119,6 +123,7 @@ ivas_error core_switching_pre_dec_ivas_fx( { st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ st->hBPF->pst_mem_deemp_err_fx = 0; move16(); } #endif st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); Loading @@ -136,6 +141,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); test(); IF( st->hBWE_TD != NULL && NE_16( st->last_core, ACELP_CORE ) ) { #ifdef MSAN_FIX Loading @@ -155,6 +161,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->igf = 0; move16(); test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading Loading @@ -196,6 +203,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } test(); IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) { IF( EQ_16( st->element_mode, EVS_MONO ) ) Loading Loading @@ -238,6 +246,8 @@ ivas_error core_switching_pre_dec_ivas_fx( delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); /*TODO To be tested:control not entering the block*/ test(); test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ Loading Loading @@ -281,6 +291,8 @@ ivas_error core_switching_pre_dec_ivas_fx( Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); } test(); test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, output_frame / 2, st->last_L_frame / 2 ); Loading @@ -298,6 +310,7 @@ ivas_error core_switching_pre_dec_ivas_fx( /*FEC*/ IF( LE_16( st->L_frame, L_FRAME16k ) ) { test(); IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) { IF( NE_16( st->L_frame, st->last_L_frame ) ) Loading Loading @@ -325,6 +338,8 @@ ivas_error core_switching_pre_dec_ivas_fx( /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || NE_16( st->last_codec_mode, MODE2 ) ) ) { st->last_ppp_mode_dec = 0; Loading @@ -334,6 +349,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Handle state reset of stat_noise_uv_mod memory */ test(); test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) { st->act_count = 3; Loading @@ -342,9 +360,21 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); } test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); IF( ( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) { test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { st->hPFstat->reset = 1; Loading @@ -368,6 +398,12 @@ ivas_error core_switching_pre_dec_ivas_fx( lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); } test(); test(); test(); test(); test(); test(); IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ Loading Loading @@ -430,6 +466,8 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_reset_memory_fx( st->cldfbSyn ); /* reset TBE memories */ test(); test(); IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); Loading @@ -445,6 +483,7 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading @@ -459,6 +498,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } } test(); test(); test(); IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) { IF( st->hBWE_TD != NULL ) Loading Loading @@ -491,6 +533,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); move16(); test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); Loading @@ -504,6 +547,9 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } test(); test(); test(); IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) { /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ Loading @@ -514,14 +560,19 @@ ivas_error core_switching_pre_dec_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); } Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, Q10 - Q_old_synthFB ); Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; move16(); IF( old_synthFB_fx ) free( old_synthFB_fx ); } } test(); test(); test(); test(); IF( EQ_16( st->core, HQ_CORE ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( NE_16( st->element_mode, EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) { set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); Loading @@ -545,7 +596,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { /* Estimate mem_env_delta to reinit env_stab */ tmp_fx = L_max( 0, ENV_STAB_EST1_FX + Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ) + Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ); /*Q12*/ tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ Loading Loading @@ -609,6 +660,12 @@ ivas_error core_switching_pre_dec_ivas_fx( /*switch on CNA on active frames*/ IF( EQ_16( st->element_mode, EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ { test(); test(); test(); test(); test(); test(); IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) { st->flag_cna = 1; Loading @@ -628,6 +685,10 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Reconfigure CNG */ test(); test(); test(); test(); IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || EQ_16( st->ini_frame, 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) { /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ Loading @@ -645,24 +706,29 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } } test(); test(); IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) { test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth2 ); L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth ); L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); move32(); } } ELSE Loading @@ -670,6 +736,7 @@ ivas_error core_switching_pre_dec_ivas_fx( FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); move32(); } } } Loading Loading @@ -1682,6 +1749,8 @@ void bandwidth_switching_detect_ivas_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ) { test(); test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ Loading @@ -1698,6 +1767,7 @@ void bandwidth_switching_detect_ivas_fx( test(); test(); test(); test(); IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) { st_fx->bws_cnt1 = 0; Loading Loading @@ -1932,6 +2002,9 @@ void ivas_bw_switching_pre_proc_fx( return; } test(); test(); test(); IF( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) { /*----------------------------------------------------------------------* Loading @@ -1958,9 +2031,10 @@ void ivas_bw_switching_pre_proc_fx( tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; st->enerLL_fx_Q = ( Q + shift - 32 ) / 2; st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); W_tmp = 0; move64(); FOR( ; i < L_FRAME; i++ ) { W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); Loading @@ -1971,7 +2045,8 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( tmp, 7 ); // divide by 128 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; st->enerLH_fx_Q = ( Q + shift - 32 ) / 2; move32(); st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); } ELSE { Loading @@ -1985,9 +2060,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); L_tmp = 0; move32(); FOR( ; i < 64; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -1996,12 +2074,15 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; move32(); st->enerLH_fx_Q = Q_audio; move16(); } ELSE { Word32 tmp, L_tmp = 0; L_tmp = 0; move32(); FOR( i = 0; i < L_FRAME / 2; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -2009,9 +2090,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); L_tmp = 0; move32(); FOR( ; i < L_FRAME; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); Loading @@ -2019,15 +2103,25 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; move32(); st->enerLL_fx_Q = Q_audio; move16(); } } test(); test(); test(); test(); test(); test(); test(); IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) { // st->prev_ener_shb = 0.0f; st->prev_ener_shb_fx = 0; move16(); IF( st->hBWE_FD != NULL ) { // set_f( st->hBWE_FD->prev_SWB_fenv, 0, SWB_FENV ); Loading @@ -2037,12 +2131,18 @@ void ivas_bw_switching_pre_proc_fx( ELSE IF( ( ( EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) { st->attenu_fx = 3277; move16(); } test(); test(); test(); test(); test(); IF( EQ_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) { st->prev_fractive = 0; st->prev_fractive = 0; move16(); } return; Loading