diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b10d2624ab6bd18289af66c0ca77c0f4f..5fb8d64d4f561ceddc4889f510bad5f04d786aa9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6023,7 +6023,12 @@ ivas_error pre_proc_ivas_fx( Word16 *epsP_fx_q, /* i : LP prediction errors */ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE q_new_inp_resamp16k_fx*/ + Word16 *q_new_inp_resamp16k_fx, /* o : Q value of new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ +#else Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ +#endif Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ Word16 e_old_wsp, diff --git a/lib_com/options.h b/lib_com/options.h index d7daa9187c03ea40bad2c1e563e1bf03edf30ff8..3a8fae8ee5a442e3b252708d26add56e0fbcc649 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ +#define NONBE_FIX_ISSUE_2206 #define FIX_2252_SCALING_SAVE_HB_SYNTH /* VA: issue 2252: fix use-of-uninit-value in save_hb_synth_fx[] scaling in FOA decoding with bitstream that starts with an SID */ #define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ #define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index d6db81232ee9376c593bcaf04828c7e3bc90d869..696bdc26f75e4aa6746e1b41a4b0db3f26158875 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -366,9 +366,17 @@ void FEC_encode_ivas_fx( /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */ /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/ Word32 synth32[L_FRAME16k]; +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, s_min( 0, Q_synth ) ); /* Qsynth */ +#else Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */ +#endif fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame ); +#ifdef NONBE_FIX_ISSUE_2206 + exp_enrq = sub( 31, shl( s_max( 0, Q_synth ), 1 ) ); +#else exp_enrq = sub( 31, shl( Q_synth, 1 ) ); +#endif test(); test(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2ee800325cef8975c0e7de509bf72419d0120ab9..d818f09d1c7cdf72f1e51e9b440f488ca86494f3 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -49,12 +49,16 @@ *-------------------------------------------------------------------*/ ivas_error ivas_core_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ - Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ + Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ +#else + Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q-1*/ +#endif Word16 Q_new[], /* i : Q factor of speech buffers */ Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ @@ -94,6 +98,9 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch; Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX]; Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 q_new_inp_resamp16k_fx[CPE_CHANNELS]; +#endif Word16 *hb_speech_fx; Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; /* 2 * Q_new */ Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ @@ -227,20 +234,34 @@ ivas_error ivas_core_enc_fx( } IF( EQ_32( ivas_format, SBA_FORMAT ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i/o: Q_new - 1 */, old_inp_16k_fx[n] /* i/o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &q_new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), IVAS_ERR_OK ) ) +#endif { return error; } } ELSE { +#ifdef NONBE_FIX_ISSUE_2206 + IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i/o: Q_new - 1 */, old_inp_16k_fx[n] /* i/o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &q_new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -317,7 +338,11 @@ ivas_error ivas_core_enc_fx( IF( st->core == ACELP_CORE ) { /* ACELP core encoder */ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_old_syn_12k8_16k = sub( Q_new[n], 1 ); +#else Word16 Q_old_syn_12k8_16k = 0; +#endif move16(); IF( NE_32( ( error = acelp_core_enc_ivas_fx( st, inp_fx[n], /*ener[n],*/ A_fx[n], Aw_fx[n], epsP_fx[n], lsp_new_fx[n], lsp_mid_fx[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], &Q_old_syn_12k8_16k, pitch_buf_fx[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh_fx, Q_new[n] ) ), IVAS_ERR_OK ) ) { @@ -622,6 +647,28 @@ ivas_error ivas_core_enc_fx( { st = sts[n]; +#ifdef NONBE_FIX_ISSUE_2206 + Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); + Copy( st->input_fx, tmp_input_fx, input_frame ); + q_inp[0] = st->q_old_inp; + q_inp[1] = st->q_inp; + + st->q_inp = s_min( s_min( st->Q_old_wtda, st->q_inp ), sub( Q15, st->exp_old_inp_12k8 ) ); + st->q_inp = s_min( st->q_inp, sub( Q15, st->exp_old_inp_16k ) ); + st->q_old_inp = st->q_inp; + + IF( st->hBWE_FD != NULL ) + { + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // s_min( st->Q_old_wtda, st->q_inp ); + st->Q_old_wtda = st->q_inp; + move16(); + // Scale_sig( st->hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( sub( Q_new[n], 1 ), st->hBWE_FD->prev_Q_input_lp ) ); /* Q_new[n] - 1 */ + // st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 ); + // move16(); + } + + Scale_sig( st->input_fx - input_frame, 2 * input_frame, sub( st->q_inp, q_inp[0] ) ); +#else IF( st->hBWE_FD != NULL ) { Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( negate( 1 ), st->Q_old_wtda ) ); // Q(-1) @@ -642,6 +689,7 @@ ivas_error ivas_core_enc_fx( move16(); st->q_old_inp = -1; move16(); +#endif /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching @@ -661,7 +709,11 @@ ivas_error ivas_core_enc_fx( IF( GE_32( input_Fs, 16000 ) && LT_16( st->bwidth, SWB ) && st->hBWE_TD != NULL ) { /* Common pre-processing for WB TBE and WB BWE */ +#ifdef NONBE_FIX_ISSUE_2206 + wb_pre_proc_ivas_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx, q_new_inp_resamp16k_fx[n] ); +#else wb_pre_proc_ivas_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx ); +#endif } test(); @@ -669,12 +721,20 @@ ivas_error ivas_core_enc_fx( IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE encoder */ +#ifdef NONBE_FIX_ISSUE_2206 + wb_tbe_enc_ivas_fx( st, hb_speech_fx, q_new_inp_resamp16k_fx[n], bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] ); +#else wb_tbe_enc_ivas_fx( st, hb_speech_fx, bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] ); +#endif } ELSE IF( EQ_16( st->extl, WB_BWE ) && n == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { /* WB BWE encoder */ +#ifdef NONBE_FIX_ISSUE_2206 + wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n], q_new_inp_resamp16k_fx[n] ); +#else wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n] ); +#endif } /*---------------------------------------------------------------------* @@ -769,7 +829,6 @@ ivas_error ivas_core_enc_fx( } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 - /*---------------------------------------------------------------------* * SWB DTX/CNG encoding *---------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f6aa5e904c6fdf12012cee93b4f2f7688a1681a0..0defbf30de98184647c96d236ab0d0502db38815 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -71,14 +71,18 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len ) } ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ - Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 n, /* i : channel number Q0*/ + Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/ +#else + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ +#endif Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ Word16 *relE_fx, /* o : frame relative energy Q8*/ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ @@ -218,6 +222,10 @@ ivas_error pre_proc_front_ivas_fx( Word32 *in_buff_temp; Word16 in_q_temp; #endif +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_old_in = st->q_inp; + move16(); +#endif mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); @@ -225,7 +233,11 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) +#ifdef NONBE_FIX_ISSUE_2206 + Q_min = s_min( Q_min, sub( add( L_norm_arr( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); +#else Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); +#endif Q_min = s_max( -2, Q_min ); Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min st->q_inp = Q_min; @@ -233,6 +245,11 @@ ivas_error pre_proc_front_ivas_fx( st->q_old_inp = Q_min; move16(); +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( st->q_inp, Q_old_in ) ); + Scale_sig( old_inp_16k_fx, L_INP, sub( st->q_inp, Q_old_in ) ); +#endif + #ifdef DEBUG_MODE_INFO IF( hSCE != NULL ) { @@ -499,7 +516,11 @@ ivas_error pre_proc_front_ivas_fx( Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ st->mem_q = st->q_inp; move16(); - Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* q_inp */ +#else + Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ +#endif set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ @@ -535,17 +556,26 @@ ivas_error pre_proc_front_ivas_fx( ELSE /* DFT stereo */ { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ +#ifdef NONBE_FIX_ISSUE_2206_NO + Copy_Scale_sig( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx_q_inp, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), sub( -Q1, st->q_inp ) ); /* st->q_inp */ + st->mem_q = -Q1; + move16(); +#else Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx_q_inp, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ st->mem_q = st->q_inp; move16(); +#endif + +#ifndef NONBE_FIX_ISSUE_2206 scale_sig( old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, sub( Q_inp_const, st->q_inp ) ); scale_sig( st->input_fx - input_frame, input_frame_full, sub( Q_inp_const, st->q_inp ) ); Copy_Scale_sig( st->mem_decim_fx_q_inp, st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */ - // Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */ + // Scale_sig( st->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp_const, st->q_inp ) ); /* Q(-1) */ st->q_inp = Q_inp_const; move16(); st->q_old_inp = Q_inp_const; move16(); +#endif } IF( NE_16( Q_inp_const, st->q_inp ) ) { @@ -589,7 +619,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/ + Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/ st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */ move16(); @@ -710,6 +740,9 @@ ivas_error pre_proc_front_ivas_fx( move16(); Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( add( *Q_new, 1 ), st->q_inp ) ); /* Q_new */ Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */ +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( old_inp_16k_fx, L_INP, sub( *Q_new, st->q_inp ) ); /* Q_new */ +#endif cldfbScale.hb_scale = cldfbScale.lb_scale; move16(); @@ -846,7 +879,11 @@ ivas_error pre_proc_front_ivas_fx( IF( st->idchan == 0 && NE_16( element_mode, IVAS_CPE_MDCT ) ) { Word16 input_fx_tmp[480]; +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->input_fx, input_fx_tmp, shr( input_frame, 1 ), negate( st->q_inp ) ); /*scaling from st->q_inp to q0*/ +#else Copy_Scale_sig( st->input_fx, input_fx_tmp, shr( input_frame, 1 ), negate( st->q_inp ) ); /*scaling from Q_inp_const to q0*/ +#endif bw_detect_fx( st, input_fx_tmp, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0, 0 ); } @@ -1502,6 +1539,12 @@ ivas_error pre_proc_front_ivas_fx( move16(); IF( flag_16k_smc ) { +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_old_inp_16k = sub( *Q_new, 1 ); + move16(); + Word16 Q_old_inp_12k8 = sub( *Q_new, 1 ); + move16(); +#else Word16 Q_old_inp_16k = -1; move16(); @@ -1533,6 +1576,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_old_inp_12k8 = *Q_new; move16(); +#endif /* Compute core-coder buffers at internal sampling rate */ error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, @@ -1550,7 +1594,11 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = add( *Q_new, Q_inp_const ); // actual Q_new move16(); +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( sub( *Q_new, 1 ), Q_old_inp_12k8 ) ); /* Q_new-1 */ +#else Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) ); /* Q_new */ +#endif Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */ st->exp_buf_speech_enc = Q15; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 7ba122dbd3cc9a5332a60166bf29f17f8d9f54d7..964f29320faaad4c26b3d2103e96c55e90af99db 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -46,13 +46,17 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ ivas_error pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word32 last_element_brate, /* i : last element bitrate Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new */ +#else + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ +#endif Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ @@ -61,9 +65,14 @@ ivas_error pre_proc_ivas_fx( Word16 *epsP_fx_q, /* i : LP prediction errors */ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE q_new_inp_resamp16k_fx*/ + Word16 *q_new_inp_resamp16k_fx, /* o : Q value of new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ +#else + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ +#endif + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ + Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ Word16 e_old_wsp, const Word16 loc_harm, /* i : harmonicity flag Q0*/ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ @@ -529,18 +538,38 @@ ivas_error pre_proc_ivas_fx( inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_old_inp_16k = sub( *Q_new, 1 ); +#else Word16 Q_old_inp_16k = -1; +#endif move16(); Word16 Q_r[2] = { 0 }; move16(); move16(); inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; +#ifdef NONBE_FIX_ISSUE_2206 + Word16 shift = norm_arr( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */ + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); + shift = norm_arr( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */ + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + IF( st->hBWE_FD != NULL ) + { + shift = norm_arr( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); /* exp(st->exp_old_inp_12k8 - shift) */ + st->Q_old_wtda = add( st->Q_old_wtda, shift ); + move16(); + } +#else Word16 shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); /* exp(st->exp_old_inp_12k8 - shift) */ st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q15 - st->exp_old_inp_16k */ st->exp_old_inp_16k = sub( Q15, Q_old_inp_16k ); move16(); @@ -567,6 +596,7 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); +#endif Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k = *Q_new; @@ -588,7 +618,12 @@ ivas_error pre_proc_ivas_fx( *Q_new = Q_inp_16k; } move16(); - +#ifdef NONBE_FIX_ISSUE_2206 + shift = norm_arr( new_inp_resamp16k_fx, L_FRAME16k ); + Scale_sig( new_inp_resamp16k_fx, L_FRAME16k, shift ); + *q_new_inp_resamp16k_fx = add( Q_old_inp_16k, shift ); + move16(); +#endif IF( error != IVAS_ERR_OK ) { return error; @@ -625,12 +660,22 @@ ivas_error pre_proc_ivas_fx( IF( st->tcxonly == 0 ) { Copy( wsp_fx, st->wspeech_enc, L_FRAME + L_LOOK_12k8 ); +#ifdef NONBE_FIX_ISSUE_2206 + st->exp_buf_wspeech_enc = e_old_wsp; + move16(); +#endif } } IF( flag_16k_smc ) { +#ifdef NONBE_FIX_ISSUE_2206 + *q_new_inp_resamp16k_fx = sub( Q15, st->exp_buf_speech_enc ); + move16(); + Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* q_new_inp_resamp16k_fx */ +#else Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */ +#endif } /*-----------------------------------------------------------------* @@ -687,9 +732,13 @@ ivas_error pre_proc_ivas_fx( * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ ivas_error ivas_compute_core_buffers_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ - Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ +#ifdef NONBE_FIX_ISSUE_2206 + Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz in Q_old_inp_16k = Q_new, out Q_new-1 */ +#else + Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ +#endif Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_old_inp_16k*/ const Word16 input_frame, /* i : frame length Q0*/ const Word16 last_element_mode, /* i : last element mode Q0*/ @@ -717,7 +766,11 @@ ivas_error ivas_compute_core_buffers_fx( Word16 epsP_h[M + 1]; Word16 epsP_l[M + 1]; +#ifdef NONBE_FIX_ISSUE_2206 + Word16 headroom = sub( 1, Q_old_inp_16k ), preemp_len = 0, inp_max = 0; +#else Word16 headroom = 1, preemp_len = 0, inp_max = 0; +#endif move16(); move16(); move16(); @@ -729,10 +782,18 @@ ivas_error ivas_compute_core_buffers_fx( set16_fx( epsP_l, 0, M + 1 ); set16_fx( input_buf_fx, 0, L_FRAME48k * 2 ); +#ifdef NONBE_FIX_ISSUE_2206 + assert( Q_old_inp_16k == ( *Q_new - 1 ) ); + Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( Q_old_inp_16k, st->q_old_inp ) ); + Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( Q_old_inp_16k, st->q_inp ) ); + + signal_in_fx = &input_buf_fx[input_frame]; /* Q_old_inp_16k */ +#else Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); - signal_in_fx = &input_buf_fx[input_frame]; /* st->q_inp */ + signal_in_fx = &input_buf_fx[input_frame]; /* st->q_inp */ +#endif input_Fs = st->input_Fs; /* Q0 */ move32(); @@ -780,15 +841,27 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k ); /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */ +#else + Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k ); /* Q_new - 1 */ +#endif } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */ +#else Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k ); /* Q_new - 1 */ +#endif } ELSE { - Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k ); /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */ +#else + Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k ); /* Q_new - 1 */ +#endif } /*---------------------------------------------------------------* @@ -803,12 +876,21 @@ ivas_error ivas_compute_core_buffers_fx( /* no resampling needed, only delay adjustment to account for the FIR resampling delay */ delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay, sub( Q_old_inp_16k, -1 ) ); /* Q_old_inp_16k */ + Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* Q_old_inp_16k */ + Copy_Scale_sig( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ), sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#else Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay ); - Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* st->q_inp */ - Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */ + Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* st->q_inp */ + Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */ +#endif } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, -1 ) ); /* Q_old_inp_16k */ +#endif size_modified = modify_Fs_ivas_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ @@ -816,6 +898,9 @@ ivas_error ivas_compute_core_buffers_fx( set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#endif } } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) @@ -826,12 +911,21 @@ ivas_error ivas_compute_core_buffers_fx( /* no resampling needed, only delay adjustment to account for the FIR resampling delay */ delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); - Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay ); /* Q(-1) */ - Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - sub( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */ - Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay, sub( Q_old_inp_16k, -1 ) ); /* Q_old_inp_16k */ + Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - sub( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* Q_old_inp_16k */ + Copy_Scale_sig( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ), sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#else + Copy( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay ); /* Q(-1) */ + Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - sub( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* st->q_inp */ + Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) ); /* st->q_inp */ +#endif } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, -1 ) ); /* Q_old_inp_16k */ +#endif /* reconstruct past segment of input signal when switching from MDCT stereo */ IF( EQ_16( last_element_mode, IVAS_CPE_MDCT ) /*|| st->idchan == 1*/ ) { @@ -849,6 +943,9 @@ ivas_error ivas_compute_core_buffers_fx( Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#endif IF( lMemRecalc > 0 ) { size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ @@ -863,7 +960,11 @@ ivas_error ivas_compute_core_buffers_fx( ELSE IF( st->idchan == 0 ) { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( signal_in_fx + input_frame - NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#else Copy( signal_in_fx + input_frame - NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ +#endif } /*------------------------------------------------* @@ -883,11 +984,20 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->bwidth, WB ) ) { - Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */ - scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( Q_old_inp_16k, st->Q_old_wtda ) ); // st->Q_old_wtda->Q_old_inp_16k +#ifdef NONBE_FIX_ISSUE_2206 + Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k ); + Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, sub( -1, Q_old_inp_16k ) ); /* Scaling to Q(-1) */ + scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( wtda_q, st->Q_old_wtda ) ); /* st->Q_old_wtda->wtda_q */ + Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, sub( STEREO_DFT_OVL_16k, delay ), sub( wtda_q, Q_old_inp_16k ) ); + st->Q_old_wtda = wtda_q; + move16(); +#else + Copy_Scale_sig( new_inp_16k_fx - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */ + scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( Q_old_inp_16k, st->Q_old_wtda ) ); // st->Q_old_wtda->Q_old_inp_16k Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k + delay, sub( STEREO_DFT_OVL_16k, delay ) ); st->Q_old_wtda = Q_old_inp_16k; move16(); +#endif } } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) @@ -898,11 +1008,20 @@ ivas_error ivas_compute_core_buffers_fx( test(); IF( EQ_16( st->bwidth, WB ) && st->hBWE_FD != NULL ) { +#ifdef NONBE_FIX_ISSUE_2206 + Word16 wtda_q = s_min( st->Q_old_wtda, Q_old_inp_16k ); + Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, sub( -1, Q_old_inp_16k ) ); /* Scaling to Q(-1) */ + scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( wtda_q, st->Q_old_wtda ) ); /* st->Q_old_wtda->wtda_q */ + Copy_Scale_sig( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, sub( L_MEM_RECALC_16K + L_FILT16k, delay ), sub( wtda_q, Q_old_inp_16k ) ); + st->Q_old_wtda = wtda_q; + move16(); +#else Copy_Scale_sig( new_inp_16k_fx + L_FILT16k - delay, st->hBWE_FD->old_input_wb_fx, delay, negate( add( Q_old_inp_16k, 1 ) ) ); /* Scaling to Q(-1) */ scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( Q_old_inp_16k, st->Q_old_wtda ) ); // st->Q_old_wtda->Q_old_inp_16k Copy( new_inp_16k_fx - L_MEM_RECALC_16K, st->hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k + delay, sub( L_MEM_RECALC_16K + L_FILT16k, delay ) ); st->Q_old_wtda = Q_old_inp_16k; move16(); +#endif } } ELSE IF( element_mode == IVAS_SCE ) @@ -932,7 +1051,12 @@ ivas_error ivas_compute_core_buffers_fx( test(); if ( st->tcxonly == 0 && !( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) ) { - st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1]; /* Q(-1) */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1]; /* Q_old_inp_16k */ + st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k ); +#else + st->mem_preemph_enc = new_inp_16k_fx[L_frame_tmp - 1]; /* Q(-1) */ +#endif move16(); } @@ -954,21 +1078,41 @@ ivas_error ivas_compute_core_buffers_fx( { IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, sub( -1, Q_old_inp_16k ) ); /* update for TD/DFT stereo switching Q(-1) */ +#else Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */ +#endif st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; /* Q(-1) */ move16(); - st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_DFT_fx = shl( old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1], sub( -1, Q_old_inp_16k ) ); /* Q_old_inp_16k -> Q(-1) */ +#else + st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */ +#endif move16(); IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k, sub( sub( Q15, st->exp_buf_speech_enc ), Q_old_inp_16k ) ); /* Q(-1) */ +#else + Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */ +#endif } // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_fx, sub( Q_old_inp_16k, -1 ) ); + move16(); +#endif PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( tmp_fx, sub( -1, Q_old_inp_16k ) ); + move16(); +#endif // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx); PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */ @@ -979,11 +1123,21 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_fx, sub( Q_old_inp_16k, -1 ) ); + move16(); +#endif IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_DFT_fx, sub( Q_old_inp_16k, -1 ) ); + move16(); + Copy_Scale_sig( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, sub( Q_old_inp_16k, -1 ) ); /* Q(-1) */ +#else st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; move16(); Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */ +#endif // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx); PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); @@ -992,7 +1146,11 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } - st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_DFT_fx = shl( old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1], sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ +#else + st->mem_preemph16k_DFT_fx = old_inp_16k_fx[L_INP_MEM - STEREO_DFT_OVL_16k + L_FRAME16k - 1]; /* Q_new - 1 */ +#endif move16(); /* preemphasise past segment of input signal when switching from MDCT stereo */ @@ -1010,12 +1168,20 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ), sub( sub( Q15, st->exp_buf_speech_enc ), Q_old_inp_16k ) ); /* Q_new - 1 */ +#else + Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */ +#endif } // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_fx, sub( -1, Q_old_inp_16k ) ); + move16(); +#endif // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx); PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */ IF( preemp_start_idx && preemp_len ) @@ -1032,10 +1198,18 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE IF( EQ_16( element_mode, IVAS_SCE ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_fx, sub( Q_old_inp_16k, -1 ) ); + move16(); +#endif // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( st->mem_preemph16k_fx, sub( -1, Q_old_inp_16k ) ); + move16(); +#endif // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx); PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx; @@ -1068,19 +1242,32 @@ ivas_error ivas_compute_core_buffers_fx( } st->Q_max_16k[i] = shift; move16(); +#ifndef NONBE_FIX_ISSUE_2206 Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, Q_old_inp_16k ) ); + Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), sub( sub( *Q_new, 1 ), Q_old_inp_16k ) ); /* *Q_new-1 */ +#endif } ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ { IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1], sub( -1, Q_old_inp_16k ) ); /* Q(-1)) */ +#else + st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ +#endif move16(); } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1], sub( -1, Q_old_inp_16k ) ); /* Q(-1)) */ +#else + st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ +#endif move16(); } ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) @@ -1090,10 +1277,18 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE /* SCE */ { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1]; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_fx = shl( new_inp_16k_fx[L_frame_tmp - 1], sub( -1, Q_old_inp_16k ) ); /* Q(-1)) */ +#else + st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - 1]; /* Q_new - 1 */ +#endif move16(); } - st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx; /* Q_new - 1 */ +#ifdef NONBE_FIX_ISSUE_2206 + st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx; /* Q(-1)) */ +#else + st->mem_preemph16k_DFT_fx = st->mem_preemph16k_fx; /* Q_new - 1 */ +#endif move16(); } @@ -1107,8 +1302,19 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; +#ifdef NONBE_FIX_ISSUE_2206 + shift = sub( Q_old_inp_16k, sub( *Q_new, 1 ) ); +#else shift = negate( *Q_new ); +#endif + move16(); + +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */ + st->exp_buf_speech_enc_pe = sub( Q15, Q_old_inp_16k ); move16(); +#endif + IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { Copy_Scale_sig( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k, shift ); // Q-1 @@ -1119,7 +1325,15 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE { +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->exp_buf_speech_enc = sub( Q15, Q_old_inp_16k ); + move16(); + + Copy_Scale_sig( new_inp_resamp16k_fx, st->buf_speech_enc + L_FRAME16k, L_FRAME16k, sub( sub( Q15, st->exp_buf_speech_enc ), Q_old_inp_16k ) ); +#else Copy( new_inp_resamp16k_fx, st->buf_speech_enc + L_FRAME16k, L_FRAME16k ); +#endif Copy_Scale_sig( new_inp_16k_fx, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k, shift ); // Q-1 } @@ -1146,6 +1360,14 @@ ivas_error ivas_compute_core_buffers_fx( * Compute Weighted Input *---------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISSUE_2206_NO + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k + move16(); + st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); + move16(); +#endif + ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); } @@ -1172,9 +1394,14 @@ ivas_error ivas_compute_core_buffers_fx( ELSE IF( GT_32( input_Fs, 8000 ) ) { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); +#ifdef NONBE_FIX_ISSUE_2206 + st->exp_old_inp_16k = st->exp_old_inp_12k8; + move16(); +#else Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); st->exp_old_inp_16k = Q16; // Q-1 move16(); +#endif } IF( inp16k_out_fx != NULL ) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index a610d0dfce90d3badb8540dbb3b50a3e8cf3efd9..c79115b1d4da8a2f370d0faf6fa072bc761f2a1c 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -458,13 +458,20 @@ ivas_error ivas_cpe_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy32( sts[n]->input32_fx, orig_input_fx32[n], input_frame ); /* sts->q_inp32 */ - Copy( sts[n]->input_fx, orig_input_fx[n], input_frame ); /* sts->q_inp */ + Copy32( sts[n]->input32_fx, orig_input_fx32[n], input_frame ); /* sts->q_inp32 */ + Copy( sts[n]->input_fx, orig_input_fx[n], input_frame ); /* sts->q_inp */ +#ifdef NONBE_FIX_ISSUE_2206 + Q_orig_inp[n] = sts[n]->q_inp; + Q_orig_inp32[n] = sts[n]->q_inp32; + move16(); + move16(); +#else Scale_sig( orig_input_fx[n], input_frame, sub( -1, sts[n]->q_inp ) ); // Q(-1) Q_orig_inp[n] = -1; Q_orig_inp32[n] = sts[n]->q_inp32; move16(); move16(); +#endif IF( hCPE->hStereoICBWE != NULL ) { @@ -827,6 +834,40 @@ ivas_error ivas_cpe_enc_fx( stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); +#ifdef NONBE_FIX_ISSUE_2206 + /* Normalise sts[0]->input32_fx */ + Word16 Qs0, Qs1, Qs2, Qs3, Qold2, Qnew2; + assert( out_start_ind <= 0 && out_end_ind >= 0 ); + Qs0 = L_norm_arr( sts[0]->input32_fx - input_frame, add( input_frame, out_start_ind ) ); + Qs1 = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( 0, out_start_ind ) ); + Qs2 = L_norm_arr( sts[0]->input32_fx, out_end_ind ); + Qs3 = L_norm_arr( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ) ); + Qold2 = s_min( add( sts[0]->q_old_inp32, Qs0 ), add( Q15, Qs1 ) ); + Qnew2 = s_min( add( Q15, Qs2 ), add( sts[0]->q_inp32, Qs3 ) ); +#if 1 + /* Somewhere else (i.e. sts[]->encoderLookahead_FB) sts[0]->q_old_inp32 needs to be the same as sts[0]->q_inp32 */ + Qnew2 = s_min( Qnew2, Qold2 ); + Qold2 = Qnew2; + move16(); +#endif + scale_sig32( sts[0]->input32_fx - input_frame, add( input_frame, out_start_ind ), sub( Qold2, sts[0]->q_old_inp32 ) ); + scale_sig32( sts[0]->input32_fx + out_start_ind, sub( 0, out_start_ind ), sub( Qold2, Q15 ) ); + scale_sig32( sts[0]->input32_fx, out_end_ind, sub( Qnew2, Q15 ) ); + scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Qnew2, sts[0]->q_inp32 ) ); + sts[0]->q_old_inp32 = Qold2; + sts[0]->q_inp32 = Qnew2; + move16(); + move16(); + + // Copy the old input, input and FIR delay section of input buffer to 16 bit + Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), 0 ); + + // Update the Q-factors + sts[0]->q_inp = sub( sts[0]->q_inp32, Q16 ); + move16(); + sts[0]->q_old_inp = sub( sts[0]->q_old_inp32, Q16 ); + move16(); +#else Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer Scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer sts[0]->q_inp32 = Q15; @@ -847,15 +888,24 @@ ivas_error ivas_cpe_enc_fx( move16(); sts[0]->q_old_inp = q_inp; move16(); +#endif /* iDFT & resampling to 12.8kHz internal sampling rate */ stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &out_12k8_start_ind[0], &out_12k8_end_ind[0], 0, input_Fs, INT_FS_12k8, 0, NULL ); - Copy_Scale_sig_32_16( old_inp_12k8_fx[0], old_inp_12k8_16fx[0], L_INP_12k8, -Q16 ); // Q-1 +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig_32_16( old_inp_12k8_fx[0], old_inp_12k8_16fx[0], L_INP_12k8, sub( sts[0]->q_inp, Q15 ) ); // Q15->sts[0]->q_inp +#else + Copy_Scale_sig_32_16( old_inp_12k8_fx[0], old_inp_12k8_16fx[0], L_INP_12k8, -Q16 ); // Q-1 +#endif /* iDFT & resampling to 16kHz internal sampling rate for M channel */ IF( EQ_32( input_Fs, internal_Fs ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, add( input_frame, STEREO_DFT_OVL_16k ), sub( Q15, sts[0]->q_inp32 ) ); /* Q15 */ +#else Copy32( sts[0]->input32_fx - STEREO_DFT_OVL_16k, old_inp_16k_fx[0] + L_INP_MEM - STEREO_DFT_OVL_16k, add( input_frame, STEREO_DFT_OVL_16k ) ); /* sts[0]->q_inp32 */ +#endif out_16k_start_ind = -STEREO_DFT_OVL_16k; out_16k_end_ind = add( out_16k_start_ind, add( input_frame, STEREO_DFT_OVL_16k ) ); move16(); @@ -865,7 +915,11 @@ ivas_error ivas_cpe_enc_fx( { stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL ); } - Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1 +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig_32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, sub( sts[0]->q_inp, Q15 ) ); // Q15 -> sts[0]->q_inp +#else + Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1 +#endif /* DFT Stereo: iDFT of residual signal at 8kHz sampling rate */ test(); @@ -1190,13 +1244,20 @@ ivas_error ivas_cpe_enc_fx( } } +#ifdef NONBE_FIX_ISSUE_2206 +#if ( CPE_CHANNELS != 2 ) +#error +#endif + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[0], old_inp_12k8_fx[0], L_INP_12k8, sub( Q15 + 1, Q_new[0] ) ); // Q_new[0]-1 -> Q15 + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[1], old_inp_12k8_fx[1], L_INP_12k8, Q15 + 1 ); // Q(-1) -> Q15 +#else FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } +#endif stereo_dft_enc_res_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM - STEREO_DFT_OVL_8k, hCPE->hMetaData, &nb_bits, max_bits ); } - IF( sts[0]->core_brate == FRAME_NO_DATA || EQ_32( sts[0]->core_brate, SID_2k40 ) ) { assert( ( nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS ) ) && "Stereo DFT CNG: bit budget is violated" ); @@ -1226,13 +1287,14 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Core Encoder *----------------------------------------------------------------*/ - +#ifndef NONBE_FIX_ISSUE_2206 FOR( n = 0; n < n_CoreChannels; n++ ) { Scale_sig( old_wsp_fx[n], L_WSP, sub( e_old_wsp[n], Q16 ) ); /* exp(16) */ e_old_wsp[n] = 16; move16(); } +#endif IF( NE_32( ( error = ivas_core_enc_fx( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 107fb9681e09f49eea06b087308350d856ef8d6d..15e0f0657fa03db83a03b22eedc40e598a53724a 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -681,7 +681,11 @@ void stereo_switching_enc_fx( /* window DFT synthesis overlap memory @input_Fs, primary channel */ FOR( i = 0; i < dft_ovl; i++ ) { +#ifdef NONBE_FIX_ISSUE_2206_NO + hCPE->hStereoDft->output_mem_dmx_fx[i] = Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ); // q_inp +#else hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl_sat( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15 +#endif move32(); } /* reset 48kHz BWE overlap memory */ @@ -718,10 +722,18 @@ void stereo_switching_enc_fx( hCPE->hStereoDft->output_mem_dmx_12k8_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_12k8_fx[STEREO_DFT_OVL_12k8 - 1 - i], sts[0]->buf_speech_enc[L_FRAME32k + L_FRAME - STEREO_DFT_OVL_12k8 + i] ), sub( 16, sts[0]->exp_buf_speech_enc ) ); /* Q15 */ move32(); } +#ifdef NONBE_FIX_ISSUE_2206_NO + Word16 q_dmx = q_inp; +#else Word16 q_dmx = Q15; +#endif move16(); /* update DFT synthesis overlap memory @16kHz, primary channel only */ L_lerp_fx( hCPE->hStereoDft->output_mem_dmx_fx, hCPE->hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k, dft_ovl, &q_dmx ); +#ifdef NONBE_FIX_ISSUE_2206_NO + scale_sig32( hCPE->hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k, sub( q_inp, q_dmx ) ); + scale_sig32( hCPE->hStereoDft->output_mem_dmx_fx, STEREO_DFT_OVL_MAX, sub( q_inp, q_dmx ) ); +#else FOR( i = 0; i < STEREO_DFT_OVL_16k; i++ ) { hCPE->hStereoDft->output_mem_dmx_16k_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_16k_fx[i], sub( Q15, q_dmx ) ); // Q15 @@ -733,6 +745,7 @@ void stereo_switching_enc_fx( hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( hCPE->hStereoDft->output_mem_dmx_fx[i], sub( Q15, q_dmx ) ); // Q15 move32(); } +#endif /* reset DFT synthesis overlap memory @8kHz, secondary channel */ set32_fx( hCPE->hStereoDft->output_mem_res_8k_fx, 0, STEREO_DFT_OVL_8k ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b0f9c1040975955ac25ed82b0afdb10b..a55bb2b70ffa0608f743d05d0943ebe07dca3ecf 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -726,8 +726,13 @@ void wb_bwe_enc_fx( ); void wb_bwe_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_wb_speech_fx /* i : original i signal at 16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *new_wb_speech_fx, /* i : original i signal at 16kHz */ + const Word16 new_wb_speech_q /* i : Q of new_wb_speech_fx */ +#else + const Word16 *new_wb_speech_fx /* i : original i signal at 16kHz */ +#endif ); void wb_pre_proc_fx( @@ -737,10 +742,16 @@ void wb_pre_proc_fx( ); void wb_pre_proc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *new_inp_resamp16k, /* i : original input signal in new_inp_resamp16k_q */ + Word16 *hb_speech, /* o : HB target signal (6-8kHz) at 16kHz in Q-1 */ + const Word16 new_inp_resamp16k_q /* i : Q of new_inp_resamp16k */ +#else const Word16 *new_inp_resamp16k, /* i : original input signal in Q-1 */ Word16 *hb_speech /* o : HB target signal (6-8kHz) at 16kHz in Q-1 */ +#endif ); void wb_tbe_enc_fx( @@ -755,8 +766,13 @@ void wb_tbe_enc_fx( ); void wb_tbe_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz q_hb_speech */ + const Word16 q_hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q0 */ +#else + const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ +#endif const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */ const Word16 Q_new, /* i : input HB speech Q factor */ const Word16 voice_factors[], /* i : voicing factors Q15 */ @@ -862,7 +878,7 @@ void gsc_enc_fx( #ifndef FIX_1904_HARM_GSC_ENC Word16 *lsf_new, /* i : ISFs at the end of the frame */ #else - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ + const Word16 *lsf_new, /* i : ISFs at the end of the frame */ #endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise, /* o : noise energy */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 6e4e8b391b18c386157accd005f101464f2bfe68..538001fce4943a4fc1dbb446b1d8f2756aa9ffdb 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -201,8 +201,13 @@ void wb_bwe_enc_fx( *-------------------------------------------------------------------*/ void wb_bwe_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *new_wb_speech_fx, /* i : original i signal at 16kHz */ + const Word16 new_wb_speech_q /* i : Q of new_wb_speech_fx */ +#else const Word16 *new_wb_speech_fx /* i : original input signal at 16kHz */ +#endif ) { Word16 mode = 0; @@ -226,9 +231,15 @@ void wb_bwe_enc_ivas_fx( move16(); new_input_fx = old_input_fx + Sample_Delay_WB_BWE; +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input_fx, Sample_Delay_WB_BWE, sub( new_wb_speech_q, -1 ) ); + Copy( new_wb_speech_fx, new_input_fx, L_FRAME16k ); + Copy_Scale_sig( old_input_fx + L_FRAME16k, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE, sub( -1, new_wb_speech_q ) ); +#else Copy( hBWE_FD->old_input_wb_fx, old_input_fx, Sample_Delay_WB_BWE ); Copy( new_wb_speech_fx, new_input_fx, L_FRAME16k ); Copy( old_input_fx + L_FRAME16k, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE ); +#endif /*---------------------------------------------------------------------*/ /* WB BWE encoding */ @@ -236,7 +247,11 @@ void wb_bwe_enc_ivas_fx( /* MDCT of the core synthesis signal */ /*---------------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISSUE_2206 + new_input_fx_exp = new_wb_speech_q; +#else new_input_fx_exp = -1; +#endif move16(); wtda_fx( old_input_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index ffdb1d454df4797d99cf2995e24cfa0ad814d1bd..a19ac04db66e898c0d907853db87bb00ab308ff4 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -193,10 +193,16 @@ void wb_pre_proc_fx( /*========================================================================*/ void wb_pre_proc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *new_inp_resamp16k, /* i : original input signal in new_inp_resamp16k_q */ + Word16 *hb_speech, /* o : HB target signal (6-8kHz) at 16kHz in Q-1 */ + const Word16 new_inp_resamp16k_q /* i : Q of new_inp_resamp16k */ +#else const Word16 *new_inp_resamp16k, /* i : original input signal in Q-1 */ Word16 *hb_speech /* o : HB target signal (6-8kHz) at 16kHz in Q-1 */ +#endif ) { Word16 Sample_Delay_WB_BWE; @@ -280,6 +286,9 @@ void wb_pre_proc_ivas_fx( Q_wb_sp = sub( Q_wb_sp, 3 ); /* leave 3 bit headroom */ } Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, Q_wb_sp ); +#ifdef NONBE_FIX_ISSUE_2206 + Q_wb_sp = add( Q_wb_sp, new_inp_resamp16k_q ); +#endif Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp ); Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp ); /* temp_buf, and the memory states are in Q_wb_sp */ @@ -318,18 +327,31 @@ void wb_pre_proc_ivas_fx( move16(); } +#ifdef NONBE_FIX_ISSUE_2206 + /*Get past signal*/ + Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k, old_input, STEREO_DFT_OVL_16k, sub( Q_wb_sp, st_fx->Q_old_wtda ) ); + Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + STEREO_DFT_OVL_16k, Sample_Delay_WB_BWE, sub( Q_wb_sp, -1 ) ); + + /*Get new signal*/ + Copy( temp_buf, &old_input[Sample_Delay_WB_BWE + STEREO_DFT_OVL_16k], L_FRAME16k ); +#else /*Get past signal*/ Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - STEREO_DFT_OVL_16k, old_input, STEREO_DFT_OVL_16k, Q_wb_sp ); Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + STEREO_DFT_OVL_16k, Sample_Delay_WB_BWE, Q_wb_sp ); /*Get new signal*/ Copy( temp_buf, &old_input[Sample_Delay_WB_BWE + STEREO_DFT_OVL_16k], L_FRAME16k ); +#endif /*compute hb_speech on delayed input*/ flip_spectrum_and_decimby4_fx( old_input + Sample_Delay_WB_BWE, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); /*Update memory*/ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( L_SUBFR * 5 / 16 ), STEREO_DFT_OVL_16k / 4, sub( -1, Q_wb_sp ) ); +#else Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( L_SUBFR * 5 / 16 ), STEREO_DFT_OVL_16k / 4, -Q_wb_sp ); +#endif Copy( hb_speech + STEREO_DFT_OVL_16k / 4, hb_speech, ( L_FRAME16k - STEREO_DFT_OVL_16k ) / 4 ); /*rest without memory update*/ @@ -354,12 +376,21 @@ void wb_pre_proc_ivas_fx( move16(); } +#ifdef NONBE_FIX_ISSUE_2206 + /*Get past signal*/ + Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, sub( Q_wb_sp, st_fx->Q_old_wtda ) ); + Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + l_recalc_16k, Sample_Delay_WB_BWE, sub( Q_wb_sp, -1 ) ); + + /* Saturation added to prevent the crash. Needs further review */ + old_input[Sample_Delay_WB_BWE] = shl_sat( hBWE_FD->mem_old_wtda_swb_fx, sub( Q_wb_sp, -1 ) ); +#else /*Get past signal*/ Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, Q_wb_sp ); Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + l_recalc_16k, Sample_Delay_WB_BWE, Q_wb_sp ); /* Saturation added to prevent the crash. Needs further review */ old_input[Sample_Delay_WB_BWE] = shl_sat( hBWE_FD->mem_old_wtda_swb_fx, Q_wb_sp ); +#endif /*Get new signal*/ Copy( temp_buf, old_input + Sample_Delay_WB_BWE + l_recalc_16k, L_FRAME16k ); @@ -368,7 +399,11 @@ void wb_pre_proc_ivas_fx( flip_spectrum_and_decimby4_fx( old_input + Sample_Delay_WB_BWE, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); /*Update memory*/ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ) - l_recalc_4k, l_recalc_4k, sub( -1, Q_wb_sp ) ); +#else Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ) - l_recalc_4k, l_recalc_4k, -Q_wb_sp ); +#endif Copy( hb_speech + l_recalc_4k, hb_speech, ( L_FRAME16k / 4 ) - l_recalc_4k ); /*rest without memory update*/ @@ -391,8 +426,13 @@ void wb_pre_proc_ivas_fx( Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); /*Get past signal*/ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, sub( Q_wb_sp, st_fx->Q_old_wtda ) ); + Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + l_recalc_16k, Sample_Delay_WB_BWE, sub( Q_wb_sp, -1 ) ); +#else Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, Q_wb_sp ); Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input + l_recalc_16k, Sample_Delay_WB_BWE, Q_wb_sp ); +#endif /*Get new signal*/ Copy( temp_buf, old_input + Sample_Delay_WB_BWE + l_recalc_16k, L_FRAME16k ); @@ -401,7 +441,11 @@ void wb_pre_proc_ivas_fx( flip_spectrum_and_decimby4_fx( old_input + Sample_Delay_WB_BWE, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); /* update hBWE_TD->old_speech_wb memory */ +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ) - l_recalc_4k, l_recalc_4k, sub( -1, Q_wb_sp ) ); +#else Copy_Scale_sig( hb_speech, hBWE_TD->old_speech_wb_fx + ( ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ) - l_recalc_4k, l_recalc_4k, -Q_wb_sp ); +#endif Copy( hb_speech + l_recalc_4k, hb_speech, ( L_FRAME16k / 4 ) - l_recalc_4k ); /*rest without memory update*/ @@ -417,7 +461,11 @@ void wb_pre_proc_ivas_fx( } /* rescale the hb_speech and memories back to Q-1 to keep the downstream BWE coding unaffected */ +#ifdef NONBE_FIX_ISSUE_2206 + Scale_sig( hb_speech, L_FRAME16k / 4, sub( new_inp_resamp16k_q, Q_wb_sp ) ); +#else Scale_sig( hb_speech, L_FRAME16k / 4, -Q_wb_sp ); +#endif Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), -Q_wb_sp ); Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), -Q_wb_sp ); @@ -427,8 +475,13 @@ void wb_pre_proc_ivas_fx( Sample_Delay_WB_BWE = ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16; highband_new_speech = highband_old_speech + Sample_Delay_WB_BWE; +#ifdef NONBE_FIX_ISSUE_2206 + Copy( hb_speech, highband_new_speech, L_FRAME16k / 4 ); + Copy_Scale_sig( highband_old_speech + L_FRAME16k / 4, hBWE_TD->old_speech_wb_fx, Sample_Delay_WB_BWE, sub( -1, Q_wb_sp ) ); +#else Copy( hb_speech, highband_new_speech, L_FRAME16k / 4 ); Copy( highband_old_speech + L_FRAME16k / 4, hBWE_TD->old_speech_wb_fx, Sample_Delay_WB_BWE ); +#endif } } } @@ -441,7 +494,11 @@ void wb_pre_proc_ivas_fx( if ( hBWE_FD != NULL ) { +#ifdef NONBE_FIX_ISSUE_2206 + hBWE_FD->mem_old_wtda_swb_fx = shl( new_inp_resamp16k[L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k - 1], sub( -1, new_inp_resamp16k_q ) ); +#else hBWE_FD->mem_old_wtda_swb_fx = new_inp_resamp16k[L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k - 1]; +#endif move16(); } @@ -453,14 +510,26 @@ void wb_pre_proc_ivas_fx( { Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k, sub( Q_wb_sp, new_inp_resamp16k_q ) ); + Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE, sub( -1, Q_wb_sp ) ); + Copy_Scale_sig( new_inp_resamp16k + L_FRAME16k - Sample_Delay_WB_BWE, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE, sub( -1, new_inp_resamp16k_q ) ); +#else Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); Copy( new_inp_resamp16k + L_FRAME16k - Sample_Delay_WB_BWE, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE ); +#endif test(); IF( NE_16( st_fx->extl, SWB_BWE ) && NE_16( st_fx->extl, FB_BWE ) ) { +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k, sub( st_fx->Q_old_wtda, Q_wb_sp ) ); + // Copy( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k ); + // st_fx->Q_old_wtda = Q_wb_sp; +#else Copy( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k ); st_fx->Q_old_wtda = -1; +#endif move16(); } } @@ -842,9 +911,11 @@ void swb_pre_proc_ivas_fx( test(); test(); +#ifndef NONBE_FIX_ISSUE_2206 scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp st->Q_old_wtda = st->q_inp; move16(); +#endif IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) ) { Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6df7696bf172352d36d0903fb4ffa78635774d64..0b357a87cd758005f97c7fd5c5c524b3e652818e 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1235,8 +1235,13 @@ void wb_tbe_enc_fx( /*==========================================================================*/ void wb_tbe_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_FIX_ISSUE_2206 + const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz q_hb_speech */ + const Word16 q_hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q0 */ +#else + const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */ +#endif const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */ const Word16 Q_new, /* i : input HB speech Q factor */ const Word16 voice_factors[], /* i : voicing factors Q15 */ @@ -1271,8 +1276,12 @@ void wb_tbe_enc_ivas_fx( Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_cur_pow, Q_prev_pow; /* Q_hb_frame; */ Word32 L_tmp, Lmax; Word16 tmp, exp, Q_out, sc; +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_ns = q_hb_speech; +#else Word16 Q_ns = -1; move16(); +#endif Word16 pitBufAvg_fx, voicingBufAvg_fx; Word16 vf_modified_fx[NB_SUBFR16k]; @@ -1292,9 +1301,17 @@ void wb_tbe_enc_ivas_fx( hb_new_speech = hb_old_speech + WBTBE_LOOK_LSUFBR_5_OVER_16; hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY; +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16, sub( Q_ns, -1 ) ); +#else Copy( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 ); +#endif Copy( hb_speech, hb_new_speech, LFRAME16K_OVER_4 ); +#ifdef NONBE_FIX_ISSUE_2206 + Copy_Scale_sig( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16, sub( -1, Q_ns ) ); +#else Copy( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16 ); +#endif test(); test();