diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c00dd2b1203eee6c8e9801c05d3a0aadb..96713a497836a33df35b5704aaa0b528bffaccc7 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -58,7 +58,11 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val Word16 i, a; Word16 y; +#ifdef NONBE_FIX_ISSUE_2206 + if ( L_x <= 1 ) +#else if ( L_x <= 0 ) +#endif L_x = L_deposit_h( 0x4000 ); L_x = L_shr( L_x, 9 ); diff --git a/lib_com/options.h b/lib_com/options.h index 0f23d808276c5d29a53d9809219a2a43c0a73d18..1c46f73bed914fd97bd505c2de5ac32d59669c68 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,9 @@ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ #define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ #define FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA /* FhG: Resolve overflow by swapping the order of addition and multiplication */ + +#define NONBE_FIX_ISSUE_2206 + #define FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC /* FhG: Adjust Q_real to prevent overflow in st->cldfbSyn->cldfb_state_fx scaling */ #define FIX_2211_ASSERT_IN_REND_CREND_CONVOLER /* FhG: Add headroom to p_output_fx to prevent overflow in ivas_rend_crendProcessSubframe_fx() */ 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 96bbca887782fdb1e711c4ff9ae0b289ab940d66..1f4536cb72083d35e13d37666c4443b7b46a529e 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -53,12 +53,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*/ @@ -626,6 +630,7 @@ ivas_error ivas_core_enc_fx( { st = sts[n]; +#ifndef NONBE_FIX_ISSUE_2206 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) @@ -635,6 +640,7 @@ ivas_error ivas_core_enc_fx( st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 ); move16(); } +#endif Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame ); Copy( st->input_fx, tmp_input_fx, input_frame ); @@ -665,7 +671,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_NO + wb_pre_proc_ivas_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx, sub( *Q_new, 1 ) ); +#else wb_pre_proc_ivas_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx ); +#endif } test(); @@ -678,7 +688,11 @@ ivas_error ivas_core_enc_fx( 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_NO + wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n], sub( *Q_new, 1 ) ); +#else wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n] ); +#endif } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index efa5e9a0a419e79b66f3b2f9e6e702b8ee166533..9ffbcf2aecf7a3df60aa60abe11c4f58173a1238 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -505,7 +505,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*/ @@ -544,14 +548,17 @@ ivas_error pre_proc_front_ivas_fx( 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(); + +#ifndef NONBE_FIX_ISSUE_2206_NO 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 ) ) { @@ -595,7 +602,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(); @@ -714,12 +721,19 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = add( *Q_new, Q_inp_const ); move16(); +#ifndef NONBE_FIX_ISSUE_2206 #ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) ); /* Q_new */ #else Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( add( *Q_new, 1 ), st->q_inp ) ); /* Q_new */ #endif Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */ +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) + 1 ); /* Q_new */ + Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, sub( st->q_inp, -1 ) ) + 1 ); /* Q_new */ + + // Scale_sig( old_inp_16k_fx, L_INP, sub( *Q_new, st->q_inp ) ); +#endif cldfbScale.hb_scale = cldfbScale.lb_scale; move16(); @@ -856,7 +870,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 ); } @@ -1512,6 +1530,10 @@ ivas_error pre_proc_front_ivas_fx( move16(); IF( flag_16k_smc ) { +#ifdef NONBE_FIX_ISSUE_2206 + Word16 Q_old_inp_16k = add( *Q_new, 1 ); + move16(); +#else Word16 Q_old_inp_16k = -1; move16(); @@ -1540,6 +1562,7 @@ ivas_error pre_proc_front_ivas_fx( 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(); +#endif Word16 Q_old_inp_12k8 = *Q_new; move16(); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 8401658240afd1f45338976ee99e05d81b50a4bd..7c05c35005ded263d4a60a0fd76c170db5b392a6 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -49,13 +49,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-1 */ +#else + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q-1 in, Q_new-1 out */ +#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*/ @@ -532,7 +536,11 @@ ivas_error pre_proc_ivas_fx( inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; +#ifdef NONBE_FIX_ISSUE_2206_NO + Word16 Q_old_inp_16k = sub( *Q_new, 1 ); +#else Word16 Q_old_inp_16k = -1; +#endif move16(); Word16 Q_r[2] = { 0 }; move16(); @@ -543,7 +551,12 @@ ivas_error pre_proc_ivas_fx( 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(); - +#if 0 + 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(); +#endif +#ifndef NONBE_FIX_ISSUE_2206 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(); @@ -570,6 +583,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; @@ -690,9 +704,14 @@ 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 */ +#ifdef NONBE_FIX_ISSUE_2206 + 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 input Q_old_inp_16k, output *Q_new-1*/ +#else + 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*/ +#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*/ @@ -732,8 +751,13 @@ 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 + 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 ) ); +#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 ) ); +#endif signal_in_fx = &input_buf_fx[input_frame]; /* st->q_inp */ @@ -783,15 +807,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 } /*---------------------------------------------------------------* @@ -806,12 +842,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 */ @@ -819,6 +864,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 ) ) @@ -829,12 +877,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*/ ) { @@ -852,6 +909,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 */ @@ -866,7 +926,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 } /*------------------------------------------------* @@ -886,11 +950,21 @@ 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 ); + Word16 wtda_q = 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 ) ) @@ -901,11 +975,21 @@ 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 ); + Word16 wtda_q = 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 ) @@ -935,7 +1019,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(); } @@ -957,21 +1046,37 @@ 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)); 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) */ @@ -982,11 +1087,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 ); @@ -995,7 +1110,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 */ @@ -1013,12 +1132,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 ) @@ -1035,10 +1162,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; @@ -1071,23 +1206,36 @@ ivas_error ivas_compute_core_buffers_fx( } st->Q_max_16k[i] = shift; move16(); +#ifndef NONBE_FIX_ISSUE_2206 #ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); #else Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); #endif 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 ) ); +#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 ) ) { +#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 ) ) @@ -1097,10 +1245,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(); } @@ -1114,8 +1270,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 @@ -1126,7 +1293,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 } @@ -1153,6 +1328,14 @@ ivas_error ivas_compute_core_buffers_fx( * Compute Weighted Input *---------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISSUE_2206 + 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 ); } @@ -1179,9 +1362,11 @@ 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 ); +#ifndef NONBE_FIX_ISSUE_2206_NO 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 8bd84e03184059752c75835d302784e9900d1202..cecfcdbd9d0b3377fa07c46fcc9c0f0a4dff1ddf 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 ) { @@ -826,6 +833,40 @@ ivas_error ivas_cpe_enc_fx( move16(); 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_NO + /* 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 #ifdef NONBE_FIX_2205_SATURATE_ALTERNATIVE 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 @@ -851,15 +892,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_NO + 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(); @@ -869,7 +919,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_NO + Copy_Scale_sig_32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, sub( sts[0]->q_inp, Q15 ) ); // Q15->st->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(); @@ -1201,7 +1255,11 @@ ivas_error ivas_cpe_enc_fx( FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { +#ifdef NONBE_FIX_ISSUE_2206_NO + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, sub( Q15, sub( Q_new[i], 1 ) ) ); // *Q_new-1 -> Q15 +#else 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 ); } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 0b27de0f6c36a2829116df22dcdd62a00ed85018..0c269f7f0e83b1c505727bca7bbd9412d4f5aa4a 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -682,10 +682,14 @@ 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 + 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 #ifdef NONBE_FIX_2206_SATURATE_ALTERNATIVE 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 #else hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( 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 #endif move32(); } @@ -723,10 +727,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 + 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 + 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 @@ -738,6 +750,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 9d7de9eeb9dad7116aab710365b94565958e5bfe..f4a4822d0deb7a61470884f3cef51b1193579a2c 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_NO + 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_NO + 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( diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 6e4e8b391b18c386157accd005f101464f2bfe68..e873e2360a1f53f0bca3783ff5be8d85a721c909 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 */ - const Word16 *new_wb_speech_fx /* i : original input signal at 16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_FIX_ISSUE_2206_NO + 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 ) { Word16 mode = 0; @@ -226,17 +231,26 @@ void wb_bwe_enc_ivas_fx( move16(); new_input_fx = old_input_fx + Sample_Delay_WB_BWE; +#ifdef NONBE_FIX_ISSUE_2206_NO + 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 */ /* MDCT of the core synthesis signal */ /*---------------------------------------------------------------------*/ +#ifdef NONBE_FIX_ISSUE_2206_NO + 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 d6095f0e3dd6991f5efc094403d8221a111cd551..4517ec9d34275d4c1bbabffade4312e445b4c150 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_NO + 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,9 +286,13 @@ 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_NO + Q_wb_sp = add( Q_wb_sp, add( new_inp_resamp16k_q, 1 ) ); +#endif + /* temp_buf, and the memory states are in Q_wb_sp-1 */ + 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 */ test(); test(); @@ -318,18 +328,31 @@ void wb_pre_proc_ivas_fx( move16(); } +#ifdef NONBE_FIX_ISSUE_2206_NO + /*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 - 1, 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, -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_NO + 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 - 1 ) ); +#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,13 +377,21 @@ void wb_pre_proc_ivas_fx( move16(); } +#ifdef NONBE_FIX_ISSUE_2206_NO + /*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 - 1, 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, -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, -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_NO + 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 - 1 ) ); +#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_NO + Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, sub( Q_wb_sp - 1, 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_NO + 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*/ @@ -460,7 +504,11 @@ void wb_pre_proc_ivas_fx( IF( NE_16( st_fx->extl, SWB_BWE ) && NE_16( st_fx->extl, FB_BWE ) ) { Copy( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k ); +#ifdef NONBE_FIX_ISSUE_2206_NO + st_fx->Q_old_wtda = sub( Q_wb_sp, 1 ); +#else st_fx->Q_old_wtda = -1; +#endif move16(); } } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e2e66dd5f0d1fa10fcc1f91600433f240696412d..dba6c2c08e44123045e2c1f8c38cef30160a7aec 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1235,8 +1235,12 @@ 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_new-1 */ +#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 */ @@ -1293,7 +1297,11 @@ void wb_tbe_enc_ivas_fx( hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY; Copy( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 ); +#ifdef NONBE_FIX_ISSUE_2206_NO + Copy_Scale_sig( hb_speech, hb_new_speech, LFRAME16K_OVER_4, sub( -1, Q_new ) ); +#else Copy( hb_speech, hb_new_speech, LFRAME16K_OVER_4 ); +#endif Copy( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16 ); test();