Loading lib_com/ivas_prot_fx.h +5 −0 Original line number Diff line number Diff line Loading @@ -1179,7 +1179,12 @@ void stereo_dft_dec_fx( Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef NONBE_FIX_ISSUE_2206 Word32 *output_fx, /* i/o : output synthesis q_output */ Word16 *q_output, /* i/o : output synthesis Q0 */ #else Word32 *output_fx, /* o : output synthesis Q16 */ #endif Word16 *output_start_index, Word16 *output_end_index, const Word16 chan, /* i : channel number */ Loading lib_enc/ivas_core_pre_proc_front_fx.c +5 −0 Original line number Diff line number Diff line Loading @@ -1581,8 +1581,13 @@ ivas_error pre_proc_front_ivas_fx( *epsP_fx_q = add( Q_r[0], 1 ); move16(); #ifdef NONBE_FIX_ISSUE_2206_NO //st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, st->mem_wsp_q ) ); // Q0 //move16(); #else st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q0 move16(); #endif *Q_new = add( *Q_new, Q_inp_const ); // actual Q_new move16(); Loading lib_enc/ivas_cpe_enc_fx.c +39 −9 Original line number Diff line number Diff line Loading @@ -859,9 +859,13 @@ ivas_error ivas_cpe_enc_fx( move16(); 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 Word16 q_inp32 = sts[0]->q_old_inp32; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &q_inp32, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); /* Normalise sts[0]->input32_fx */ Word16 Qs0, Qs1, Qs2, Qs3, Qold2, Qnew2; assert( out_start_ind <= 0 && out_end_ind >= 0 ); Loading @@ -869,8 +873,8 @@ ivas_error ivas_cpe_enc_fx( 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 ) ); Qold2 = s_min( add( sts[0]->q_old_inp32, Qs0 ), add( q_inp32, Qs1 ) ); Qnew2 = s_min( add( q_inp32, 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 ); Loading @@ -878,8 +882,8 @@ ivas_error ivas_cpe_enc_fx( 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_start_ind, sub( 0, out_start_ind ), sub( Qold2, q_inp32 ) ); scale_sig32( sts[0]->input32_fx, out_end_ind, sub( Qnew2, q_inp32 ) ); 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; Loading @@ -895,6 +899,8 @@ ivas_error ivas_cpe_enc_fx( sts[0]->q_old_inp = sub( sts[0]->q_old_inp32, Q16 ); move16(); #else stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); 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; Loading Loading @@ -926,10 +932,13 @@ ivas_error ivas_cpe_enc_fx( #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 ); #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 q_inp32 = Q31; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &q_inp32, &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, sub( sts[0]->q_inp, q_inp32 ) ); // q_inp32->sts[0]->q_inp #else 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 #endif Loading @@ -937,7 +946,10 @@ ivas_error ivas_cpe_enc_fx( 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 */ //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 */ 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 */ q_inp32 = sts[0]->q_inp32; move16(); #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 Loading @@ -948,10 +960,16 @@ ivas_error ivas_cpe_enc_fx( } ELSE { #ifdef NONBE_FIX_ISSUE_2206 q_inp32 = Q31; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &q_inp32, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL ); #else 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 ); #endif } #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 Copy_Scale_sig_32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, sub( sts[0]->q_inp, q_inp32 ) ); // q_inp32 -> 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 Loading @@ -961,6 +979,17 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) { Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 15 - 0 ); // Q15 #ifdef NONBE_FIX_ISSUE_2206 q_inp32 = Q15; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &q_inp32, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL ); /* update old input signal buffer */ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0 sts[1]->exp_old_inp_12k8 = Q15; move16(); Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1 #else stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL ); /* update old input signal buffer */ Loading @@ -968,6 +997,7 @@ ivas_error ivas_cpe_enc_fx( sts[1]->exp_old_inp_12k8 = Q15; move16(); Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1 #endif } /* no iDFT at input sampling rate for Side channel -> reset the buffer */ Loading lib_enc/ivas_stat_enc.h +18 −0 Original line number Diff line number Diff line Loading @@ -276,7 +276,12 @@ typedef struct stereo_dft_enc_data_struct const Word16 *dft_trigo_16k_fx; const Word16 *dft_trigo_32k_fx; #ifdef NONBE_FIX_ISSUE_2206 Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // output_mem_res_8k_q Word16 output_mem_res_8k_q; // Q15 #else Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q15 #endif Word32 res_cod_NRG_M_fx[STEREO_DFT_BAND_MAX]; // Q(31 - res_cod_NRG_M_fx_e[]) Word16 res_cod_NRG_M_fx_e[STEREO_DFT_BAND_MAX]; Loading @@ -293,11 +298,24 @@ typedef struct stereo_dft_enc_data_struct Word16 past_dot_prod_real_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; Word32 past_dot_prod_imag_fx[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; // Q(31 - past_dot_prod_imag_fx_e[]) Word16 past_dot_prod_imag_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; #ifdef NONBE_FIX_ISSUE_2206 Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // output_mem_dmx_q Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // output_mem_dmx_12k8_q Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // output_mem_dmx_16k_q Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // output_mem_dmx_32k_q Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // output_mem_dmx_16k_shb_q Word16 output_mem_dmx_q; // Q0 Word16 output_mem_dmx_12k8_q; // Q0 Word16 output_mem_dmx_16k_q; /*can hold 16, 12.8 or 32kHz signals*/ // Q0 Word16 output_mem_dmx_32k_q; /*can hold 16, 12.8 or 32kHz signals*/ // Q0 Word16 output_mem_dmx_16k_shb_q; // Q0 #else Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q15 Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q15 Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15 Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15 Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q15 #endif Word16 input_mem_itd_fx[CPE_CHANNELS][STEREO_DFT_OVL_MAX]; Word16 q_input_mem_itd[CPE_CHANNELS]; Word32 gipd_fx[STEREO_DFT_ENC_DFT_NB]; // Q13 Loading lib_enc/ivas_stereo_dft_enc_fx.c +97 −2 Original line number Diff line number Diff line Loading @@ -444,6 +444,10 @@ static void stereo_dft_enc_open_fx( move16(); set32_fx( hStereoDft->output_mem_dmx_32k_fx, 0, STEREO_DFT_OVL_32k ); #ifdef NONBE_FIX_ISSUE_2206 hStereoDft->output_mem_dmx_32k_q = Q31; move16(); #endif hStereoDft->dft_zp = extract_l( Mpy_32_32( input_Fs, 12079596 /* STEREO_DFT_ZP_MAX_ENC / 48000 in Q31 */ ) ); move16(); Loading Loading @@ -497,6 +501,18 @@ static void stereo_dft_enc_open_fx( set_zero_fx( hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k ); set_zero_fx( hStereoDft->output_mem_dmx_16k_shb_fx, STEREO_DFT_OVL_16k ); set_zero_fx( hStereoDft->output_mem_res_8k_fx, STEREO_DFT_OVL_8k ); #ifdef NONBE_FIX_ISSUE_2206 hStereoDft->output_mem_dmx_q = Q31; move16(); hStereoDft->output_mem_dmx_12k8_q = Q31; move16(); hStereoDft->output_mem_dmx_16k_q = Q31; move16(); hStereoDft->output_mem_dmx_16k_shb_q = Q31; move16(); hStereoDft->output_mem_res_8k_q = Q31; move16(); #endif /*Bands: find the number of bands, Nyquist freq. is not taken into account*/ /* NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[max_bwidth] / L_FRAME48k; */ Loading Loading @@ -1110,7 +1126,12 @@ void stereo_dft_enc_analyze_fx( Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef NONBE_FIX_ISSUE_2206 Word32 *output_fx, /* i/o : output synthesis q_output */ Word16 *q_output, /* i/o : output synthesis Q */ #else Word32 *output_fx, /* o : output synthesis Q15 */ #endif Word16 *output_start_index, Word16 *output_end_index, const Word16 chan, /* i : channel number */ Loading @@ -1126,6 +1147,9 @@ Word32 stereo_dft_enc_synthesize_fx( Word16 temp_exp; Word32 fac_fx; Word32 *mem_fx; #ifdef NONBE_FIX_ISSUE_2206 Word16 *mem_q; #endif const Word16 *trigo_fx; const Word32 *win_fx; const Word16 *win_ana_fx; Loading Loading @@ -1192,10 +1216,16 @@ Word32 stereo_dft_enc_synthesize_fx( IF( L_frame > 0 ) { mem_fx = hStereoDft->output_mem_dmx_16k_shb_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_shb_q; #endif } ELSE { mem_fx = hStereoDft->output_mem_dmx_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_q; #endif } win_fx = hStereoDft->win_fx; win_ana_fx = hStereoDft->win_ana_fx; Loading @@ -1221,6 +1251,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP; move16(); mem_fx = hStereoDft->output_mem_dmx_12k8_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_12k8_q; #endif win_fx = hStereoDft->win_12k8_fx; win_ana_fx = hStereoDft->win_ana_12k8_fx; Loading @@ -1247,13 +1280,17 @@ Word32 stereo_dft_enc_synthesize_fx( IF( L_frame > 0 ) { mem_fx = hStereoDft->output_mem_dmx_16k_shb_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_shb_q; #endif push_wmops( "DFT_synth_16k_shb" ); } ELSE { mem_fx = hStereoDft->output_mem_dmx_16k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_q; #endif push_wmops( "DFT_synth_16k" ); } win_fx = hStereoDft->win_16k_fx; Loading @@ -1278,6 +1315,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; move16(); mem_fx = hStereoDft->output_mem_dmx_32k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_32k_q; #endif win_fx = hStereoDft->win_32k_fx; win_ana_fx = hStereoDft->win_ana_32k_fx; Loading @@ -1302,6 +1342,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_8k_STEP; move16(); mem_fx = hStereoDft->output_mem_res_8k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_res_8k_q; #endif win_fx = hStereoDft->win_8k_fx; win_ana_fx = hStereoDft->win_ana_8k_fx; Loading @@ -1325,6 +1368,9 @@ Word32 stereo_dft_enc_synthesize_fx( ovl = -1; /* to avoid compilation warning */ move16(); mem_fx = NULL; /* to avoid compilation warning */ #ifdef NONBE_FIX_ISSUE_2206 mem_q = NULL; #endif win_ana_fx = NULL; /* to avoid compilation warning */ } Loading Loading @@ -1465,6 +1511,54 @@ Word32 stereo_dft_enc_synthesize_fx( /*Reconstruct */ /*IFFT*/ #ifdef NONBE_FIX_ISSUE_2206 Word16 mem_shift, tmp_shift, tmp_q; scal_fac = sub( L_norm_arr( tmp_fx, NFFT ), find_guarded_bits_fx( NFFT ) ); scale_sig32( tmp_fx, NFFT, scal_fac ); rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 ); tmp_q = sub( Q31, sub( DFT_in_fx_e, scal_fac ) ); *q_output = s_min( *q_output, s_min( tmp_q, *mem_q ) ); move16(); mem_shift = sub( *q_output, *mem_q ); tmp_shift = sub( *q_output, tmp_q ); *mem_q = tmp_q; move16(); FOR( i = 0; i < ovl; i++ ) { // output[offset + i] = mem[i] + tmp[zp + i] * win[i]; output_fx[offset + i] = L_add( L_shl( mem_fx[i], mem_shift ), L_shl( Mpy_32_32( tmp_fx[zp + i], win_fx[i] ), tmp_shift ) ); move32(); // mem[i] = tmp[zp + N + i] * win[ovl - 1 - i]; mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] ); move32(); } /*Middle->Copy*/ FOR( i = 0; i < N - ovl; i++ ) { // output_fx[offset + ovl + i] = tmp[zp + ovl + i]; output_fx[offset + ovl + i] = L_shl( tmp_fx[zp + ovl + i], tmp_shift ); move32(); } /*-----------------------------------------------------------------* * Lookahead: redress signal *-----------------------------------------------------------------*/ FOR( i = 0; i < ovl; i++ ) { Word32 ifft_deviation = tmp_fx[zp + N + ovl]; // *q_output move32(); // output[offset + N + i] = ( tmp[zp + N + i] - ifft_deviation ) / win_ana[ovl - 1 - i] + ifft_deviation; Word16 L_temp_e; Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e ); L_temp = L_shl_sat( L_temp, L_temp_e ); output_fx[offset + N + i] = L_shl( L_add_sat( L_temp, ifft_deviation ), tmp_shift ); // *q_output move32(); } #else scal_fac = sub( 1, find_guarded_bits_fx( NFFT ) ); scale_sig32( tmp_fx, NFFT, scal_fac ); // Q16 rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 ); Loading Loading @@ -1503,6 +1597,7 @@ Word32 stereo_dft_enc_synthesize_fx( output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q15 move32(); } #endif *output_start_index = offset; move16(); Loading Loading
lib_com/ivas_prot_fx.h +5 −0 Original line number Diff line number Diff line Loading @@ -1179,7 +1179,12 @@ void stereo_dft_dec_fx( Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef NONBE_FIX_ISSUE_2206 Word32 *output_fx, /* i/o : output synthesis q_output */ Word16 *q_output, /* i/o : output synthesis Q0 */ #else Word32 *output_fx, /* o : output synthesis Q16 */ #endif Word16 *output_start_index, Word16 *output_end_index, const Word16 chan, /* i : channel number */ Loading
lib_enc/ivas_core_pre_proc_front_fx.c +5 −0 Original line number Diff line number Diff line Loading @@ -1581,8 +1581,13 @@ ivas_error pre_proc_front_ivas_fx( *epsP_fx_q = add( Q_r[0], 1 ); move16(); #ifdef NONBE_FIX_ISSUE_2206_NO //st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, st->mem_wsp_q ) ); // Q0 //move16(); #else st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q0 move16(); #endif *Q_new = add( *Q_new, Q_inp_const ); // actual Q_new move16(); Loading
lib_enc/ivas_cpe_enc_fx.c +39 −9 Original line number Diff line number Diff line Loading @@ -859,9 +859,13 @@ ivas_error ivas_cpe_enc_fx( move16(); 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 Word16 q_inp32 = sts[0]->q_old_inp32; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &q_inp32, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); /* Normalise sts[0]->input32_fx */ Word16 Qs0, Qs1, Qs2, Qs3, Qold2, Qnew2; assert( out_start_ind <= 0 && out_end_ind >= 0 ); Loading @@ -869,8 +873,8 @@ ivas_error ivas_cpe_enc_fx( 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 ) ); Qold2 = s_min( add( sts[0]->q_old_inp32, Qs0 ), add( q_inp32, Qs1 ) ); Qnew2 = s_min( add( q_inp32, 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 ); Loading @@ -878,8 +882,8 @@ ivas_error ivas_cpe_enc_fx( 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_start_ind, sub( 0, out_start_ind ), sub( Qold2, q_inp32 ) ); scale_sig32( sts[0]->input32_fx, out_end_ind, sub( Qnew2, q_inp32 ) ); 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; Loading @@ -895,6 +899,8 @@ ivas_error ivas_cpe_enc_fx( sts[0]->q_old_inp = sub( sts[0]->q_old_inp32, Q16 ); move16(); #else stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); 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; Loading Loading @@ -926,10 +932,13 @@ ivas_error ivas_cpe_enc_fx( #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 ); #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 q_inp32 = Q31; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &q_inp32, &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, sub( sts[0]->q_inp, q_inp32 ) ); // q_inp32->sts[0]->q_inp #else 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 #endif Loading @@ -937,7 +946,10 @@ ivas_error ivas_cpe_enc_fx( 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 */ //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 */ 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 */ q_inp32 = sts[0]->q_inp32; move16(); #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 Loading @@ -948,10 +960,16 @@ ivas_error ivas_cpe_enc_fx( } ELSE { #ifdef NONBE_FIX_ISSUE_2206 q_inp32 = Q31; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &q_inp32, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL ); #else 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 ); #endif } #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 Copy_Scale_sig_32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, sub( sts[0]->q_inp, q_inp32 ) ); // q_inp32 -> 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 Loading @@ -961,6 +979,17 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) { Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 15 - 0 ); // Q15 #ifdef NONBE_FIX_ISSUE_2206 q_inp32 = Q15; move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &q_inp32, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL ); /* update old input signal buffer */ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0 sts[1]->exp_old_inp_12k8 = Q15; move16(); Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1 #else stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL ); /* update old input signal buffer */ Loading @@ -968,6 +997,7 @@ ivas_error ivas_cpe_enc_fx( sts[1]->exp_old_inp_12k8 = Q15; move16(); Copy_Scale_sig_32_16( old_inp_12k8_fx[1], old_inp_12k8_16fx[1], L_INP_12k8, -Q16 ); // Q-1 #endif } /* no iDFT at input sampling rate for Side channel -> reset the buffer */ Loading
lib_enc/ivas_stat_enc.h +18 −0 Original line number Diff line number Diff line Loading @@ -276,7 +276,12 @@ typedef struct stereo_dft_enc_data_struct const Word16 *dft_trigo_16k_fx; const Word16 *dft_trigo_32k_fx; #ifdef NONBE_FIX_ISSUE_2206 Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // output_mem_res_8k_q Word16 output_mem_res_8k_q; // Q15 #else Word32 output_mem_res_8k_fx[STEREO_DFT_OVL_8k]; // Q15 #endif Word32 res_cod_NRG_M_fx[STEREO_DFT_BAND_MAX]; // Q(31 - res_cod_NRG_M_fx_e[]) Word16 res_cod_NRG_M_fx_e[STEREO_DFT_BAND_MAX]; Loading @@ -293,11 +298,24 @@ typedef struct stereo_dft_enc_data_struct Word16 past_dot_prod_real_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; Word32 past_dot_prod_imag_fx[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; // Q(31 - past_dot_prod_imag_fx_e[]) Word16 past_dot_prod_imag_fx_e[STEREO_DFT_NRG_PAST_LEN * STEREO_DFT_BAND_MAX]; #ifdef NONBE_FIX_ISSUE_2206 Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // output_mem_dmx_q Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // output_mem_dmx_12k8_q Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // output_mem_dmx_16k_q Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // output_mem_dmx_32k_q Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // output_mem_dmx_16k_shb_q Word16 output_mem_dmx_q; // Q0 Word16 output_mem_dmx_12k8_q; // Q0 Word16 output_mem_dmx_16k_q; /*can hold 16, 12.8 or 32kHz signals*/ // Q0 Word16 output_mem_dmx_32k_q; /*can hold 16, 12.8 or 32kHz signals*/ // Q0 Word16 output_mem_dmx_16k_shb_q; // Q0 #else Word32 output_mem_dmx_fx[STEREO_DFT_OVL_MAX]; // Q15 Word32 output_mem_dmx_12k8_fx[STEREO_DFT_OVL_12k8]; // Q15 Word32 output_mem_dmx_16k_fx[STEREO_DFT_OVL_16k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15 Word32 output_mem_dmx_32k_fx[STEREO_DFT_OVL_32k]; /*can hold 16, 12.8 or 32kHz signals*/ // Q15 Word32 output_mem_dmx_16k_shb_fx[STEREO_DFT_OVL_16k]; // Q15 #endif Word16 input_mem_itd_fx[CPE_CHANNELS][STEREO_DFT_OVL_MAX]; Word16 q_input_mem_itd[CPE_CHANNELS]; Word32 gipd_fx[STEREO_DFT_ENC_DFT_NB]; // Q13 Loading
lib_enc/ivas_stereo_dft_enc_fx.c +97 −2 Original line number Diff line number Diff line Loading @@ -444,6 +444,10 @@ static void stereo_dft_enc_open_fx( move16(); set32_fx( hStereoDft->output_mem_dmx_32k_fx, 0, STEREO_DFT_OVL_32k ); #ifdef NONBE_FIX_ISSUE_2206 hStereoDft->output_mem_dmx_32k_q = Q31; move16(); #endif hStereoDft->dft_zp = extract_l( Mpy_32_32( input_Fs, 12079596 /* STEREO_DFT_ZP_MAX_ENC / 48000 in Q31 */ ) ); move16(); Loading Loading @@ -497,6 +501,18 @@ static void stereo_dft_enc_open_fx( set_zero_fx( hStereoDft->output_mem_dmx_16k_fx, STEREO_DFT_OVL_16k ); set_zero_fx( hStereoDft->output_mem_dmx_16k_shb_fx, STEREO_DFT_OVL_16k ); set_zero_fx( hStereoDft->output_mem_res_8k_fx, STEREO_DFT_OVL_8k ); #ifdef NONBE_FIX_ISSUE_2206 hStereoDft->output_mem_dmx_q = Q31; move16(); hStereoDft->output_mem_dmx_12k8_q = Q31; move16(); hStereoDft->output_mem_dmx_16k_q = Q31; move16(); hStereoDft->output_mem_dmx_16k_shb_q = Q31; move16(); hStereoDft->output_mem_res_8k_q = Q31; move16(); #endif /*Bands: find the number of bands, Nyquist freq. is not taken into account*/ /* NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[max_bwidth] / L_FRAME48k; */ Loading Loading @@ -1110,7 +1126,12 @@ void stereo_dft_enc_analyze_fx( Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef NONBE_FIX_ISSUE_2206 Word32 *output_fx, /* i/o : output synthesis q_output */ Word16 *q_output, /* i/o : output synthesis Q */ #else Word32 *output_fx, /* o : output synthesis Q15 */ #endif Word16 *output_start_index, Word16 *output_end_index, const Word16 chan, /* i : channel number */ Loading @@ -1126,6 +1147,9 @@ Word32 stereo_dft_enc_synthesize_fx( Word16 temp_exp; Word32 fac_fx; Word32 *mem_fx; #ifdef NONBE_FIX_ISSUE_2206 Word16 *mem_q; #endif const Word16 *trigo_fx; const Word32 *win_fx; const Word16 *win_ana_fx; Loading Loading @@ -1192,10 +1216,16 @@ Word32 stereo_dft_enc_synthesize_fx( IF( L_frame > 0 ) { mem_fx = hStereoDft->output_mem_dmx_16k_shb_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_shb_q; #endif } ELSE { mem_fx = hStereoDft->output_mem_dmx_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_q; #endif } win_fx = hStereoDft->win_fx; win_ana_fx = hStereoDft->win_ana_fx; Loading @@ -1221,6 +1251,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP; move16(); mem_fx = hStereoDft->output_mem_dmx_12k8_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_12k8_q; #endif win_fx = hStereoDft->win_12k8_fx; win_ana_fx = hStereoDft->win_ana_12k8_fx; Loading @@ -1247,13 +1280,17 @@ Word32 stereo_dft_enc_synthesize_fx( IF( L_frame > 0 ) { mem_fx = hStereoDft->output_mem_dmx_16k_shb_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_shb_q; #endif push_wmops( "DFT_synth_16k_shb" ); } ELSE { mem_fx = hStereoDft->output_mem_dmx_16k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_16k_q; #endif push_wmops( "DFT_synth_16k" ); } win_fx = hStereoDft->win_16k_fx; Loading @@ -1278,6 +1315,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; move16(); mem_fx = hStereoDft->output_mem_dmx_32k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_dmx_32k_q; #endif win_fx = hStereoDft->win_32k_fx; win_ana_fx = hStereoDft->win_ana_32k_fx; Loading @@ -1302,6 +1342,9 @@ Word32 stereo_dft_enc_synthesize_fx( trigo_step = STEREO_DFT_TRIGO_SRATE_8k_STEP; move16(); mem_fx = hStereoDft->output_mem_res_8k_fx; #ifdef NONBE_FIX_ISSUE_2206 mem_q = &hStereoDft->output_mem_res_8k_q; #endif win_fx = hStereoDft->win_8k_fx; win_ana_fx = hStereoDft->win_ana_8k_fx; Loading @@ -1325,6 +1368,9 @@ Word32 stereo_dft_enc_synthesize_fx( ovl = -1; /* to avoid compilation warning */ move16(); mem_fx = NULL; /* to avoid compilation warning */ #ifdef NONBE_FIX_ISSUE_2206 mem_q = NULL; #endif win_ana_fx = NULL; /* to avoid compilation warning */ } Loading Loading @@ -1465,6 +1511,54 @@ Word32 stereo_dft_enc_synthesize_fx( /*Reconstruct */ /*IFFT*/ #ifdef NONBE_FIX_ISSUE_2206 Word16 mem_shift, tmp_shift, tmp_q; scal_fac = sub( L_norm_arr( tmp_fx, NFFT ), find_guarded_bits_fx( NFFT ) ); scale_sig32( tmp_fx, NFFT, scal_fac ); rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 ); tmp_q = sub( Q31, sub( DFT_in_fx_e, scal_fac ) ); *q_output = s_min( *q_output, s_min( tmp_q, *mem_q ) ); move16(); mem_shift = sub( *q_output, *mem_q ); tmp_shift = sub( *q_output, tmp_q ); *mem_q = tmp_q; move16(); FOR( i = 0; i < ovl; i++ ) { // output[offset + i] = mem[i] + tmp[zp + i] * win[i]; output_fx[offset + i] = L_add( L_shl( mem_fx[i], mem_shift ), L_shl( Mpy_32_32( tmp_fx[zp + i], win_fx[i] ), tmp_shift ) ); move32(); // mem[i] = tmp[zp + N + i] * win[ovl - 1 - i]; mem_fx[i] = Mpy_32_32( tmp_fx[zp + N + i], win_fx[ovl - 1 - i] ); move32(); } /*Middle->Copy*/ FOR( i = 0; i < N - ovl; i++ ) { // output_fx[offset + ovl + i] = tmp[zp + ovl + i]; output_fx[offset + ovl + i] = L_shl( tmp_fx[zp + ovl + i], tmp_shift ); move32(); } /*-----------------------------------------------------------------* * Lookahead: redress signal *-----------------------------------------------------------------*/ FOR( i = 0; i < ovl; i++ ) { Word32 ifft_deviation = tmp_fx[zp + N + ovl]; // *q_output move32(); // output[offset + N + i] = ( tmp[zp + N + i] - ifft_deviation ) / win_ana[ovl - 1 - i] + ifft_deviation; Word16 L_temp_e; Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( L_sub_sat( tmp_fx[zp + N + i], ifft_deviation ), L_deposit_h( win_ana_fx[ovl - 1 - i] ), &L_temp_e ); L_temp = L_shl_sat( L_temp, L_temp_e ); output_fx[offset + N + i] = L_shl( L_add_sat( L_temp, ifft_deviation ), tmp_shift ); // *q_output move32(); } #else scal_fac = sub( 1, find_guarded_bits_fx( NFFT ) ); scale_sig32( tmp_fx, NFFT, scal_fac ); // Q16 rfft_fx( tmp_fx, trigo_enc_fx, NFFT, +1 ); Loading Loading @@ -1503,6 +1597,7 @@ Word32 stereo_dft_enc_synthesize_fx( output_fx[offset + N + i] = L_add_sat( L_temp, ifft_deviation ); // Q15 move32(); } #endif *output_start_index = offset; move16(); Loading