From 69e2488291842285710c67440681d342844781f8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 6 May 2025 17:31:17 +0530 Subject: [PATCH] Improvements related to input_fx and input32_fx buffers scalings --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/init_enc_fx.c | 6 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 76 +++++++--- lib_enc/ivas_cpe_enc_fx.c | 181 ++++++++++++----------- lib_enc/ivas_ism_enc_fx.c | 6 +- lib_enc/ivas_mct_enc_fx.c | 3 + lib_enc/ivas_sce_enc_fx.c | 6 +- lib_enc/ivas_stereo_dft_enc_fx.c | 12 +- lib_enc/ivas_stereo_dft_td_itd_fx.c | 38 +---- lib_enc/ivas_stereo_ica_enc_fx.c | 16 +- lib_enc/ivas_stereo_switching_enc_fx.c | 47 ++---- lib_enc/stat_enc.h | 2 + 12 files changed, 198 insertions(+), 197 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 17566e3cb..5816c60b5 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4746,7 +4746,7 @@ ivas_error stereo_memory_enc_fx( void stereo_switching_enc_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - Word16 old_input_signal_pri[], /* i : old input signal of primary channel */ + Word32 old_input_signal_pri[], /* i : old input signal of primary channel */ const Word16 input_frame, /* i : input frame length */ const Word16 q_inp ); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 1513cbe23..97cd57308 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1421,7 +1421,10 @@ ivas_error init_encoder_ivas_fx( set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); st->q_inp32 = Q31; move16(); + st->q_old_inp32 = Q31; + move16(); st->old_input_signal_fx = st->input_buff_fx; + st->old_input_signal32_fx = st->input_buff32_fx; /* st->input_Fs / FRAMES_PER_SEC */ Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); @@ -1432,7 +1435,8 @@ ivas_error init_encoder_ivas_fx( } ELSE { - st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC + // st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC + st->input32_fx = st->input_buff32_fx + frame_length; st->input_fx = st->input_buff_fx + frame_length; } } diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 2e09c42ed..a8698bacc 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -213,24 +213,37 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); } - Word16 q_com_sce = Q15; + Word16 q_com_sce = Q15, q_com_sce32 = Q31; + move16(); + move16(); + Word16 q_com_cpe = Q15, q_com_cpe32 = Q31; move16(); - Word16 q_com_cpe = Q15; move16(); IF( nSCE_old > 0 ) { FOR( k = 0; k < nSCE_old; k++ ) { shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame ), Q1 ); - Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */ + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ); + + shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal32_fx, input_frame ), Q1 ); + scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp + shift */ + st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift ); + move16(); + q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 ); + shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); + scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ + st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift ); + move16(); + q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 ); } } @@ -242,15 +255,26 @@ ivas_error ivas_corecoder_enc_reconfig_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame ), Q1 ); - Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */ + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ); + + shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal32_fx, input_frame ), Q1 ); + scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp + shift */ + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift ); + move16(); + q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 ); + shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); + scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift ); + move16(); + q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 ); } } } @@ -259,14 +283,16 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { FOR( k = 0; k < nSCE_old; k++ ) { - Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */ + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com; move16(); - Scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ + scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com ); + st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com ); + move16(); move16(); } } @@ -277,14 +303,16 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */ + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com; move16(); - Scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ + scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com ); + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com ); + move16(); move16(); } } @@ -301,7 +329,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { set32_fx( input_buff_fx[0], 0, len_inp_memory ); Copy32( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[0], len_inp_memory ); /* st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 */ - q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32; + q_input_buff[0] = st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32; move16(); } @@ -311,7 +339,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( nCPE_old > 0 ) { Copy32( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[n + 1], len_inp_memory ); /* st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 */ - q_input_buff[n + 1] = st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32; + q_input_buff[n + 1] = st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32; move16(); } } @@ -334,7 +362,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( GT_16( n_CoreCoder_existing, sce_id ) ) { Copy32( st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, input_buff_fx[sce_id], len_inp_memory ); /* st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 */ - q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32; + q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_old_inp32; move16(); } destroy_sce_enc_fx( st_ivas->hSCE[sce_id], ( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) && !st_ivas->hEncoderConfig->stereo_dmx_evs ) ); @@ -349,7 +377,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n ) { Copy32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, input_buff_fx[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 */ - q_input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n] = st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32; + q_input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n] = st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32; move16(); } } @@ -398,7 +426,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( GT_16( n_CoreCoder_existing, sce_id ) && NE_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) { Copy32( input_buff_fx[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff[sce_id] */ - st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_inp32 = q_input_buff[sce_id]; + st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_old_inp32 = q_input_buff[sce_id]; move16(); } test(); @@ -475,7 +503,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( GT_16( n_CoreCoder_existing, add( i_mult( cpe_id, CPE_CHANNELS ), n ) ) ) { Copy32( input_buff_fx[n], st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */ - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = q_input_buff[n]; + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = q_input_buff[n]; move16(); } } @@ -560,7 +588,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( st_ivas->nSCE ) { Copy32( input_buff_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, len_inp_memory ); /* q_input_buff */ - st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 = q_input_buff[0]; + // st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 = q_input_buff[0]; + st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 = q_input_buff[0]; + move16(); move16(); } @@ -569,7 +599,9 @@ ivas_error ivas_corecoder_enc_reconfig_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { Copy32( input_buff_fx[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, len_inp_memory ); /* q_input_buff */ - st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1]; + // st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 = q_input_buff[n + 1]; + st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 = q_input_buff[n + 1]; + move16(); move16(); } } @@ -579,7 +611,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { IF( NE_16( input_frame, len_inp_memory ) ) { - Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input) + Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input) st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp = 0; move16(); Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx + sub( len_inp_memory, input_frame ), st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx + sub( len_inp_memory, input_frame ), sub( len_inp_memory, input_frame ), sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input) @@ -588,7 +620,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( } ELSE { - Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input) + Copy_Scale_sig32_16( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff32_fx, st_ivas->hSCE[0]->hCoreCoder[0]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input) st_ivas->hSCE[0]->hCoreCoder[0]->q_old_inp = 0; move16(); } @@ -600,7 +632,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { IF( NE_16( input_frame, len_inp_memory ) ) { - Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input) + Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input) st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp = 0; move16(); @@ -610,7 +642,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( } ELSE { - Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_inp32 ) ); // Q(q_data_fx) -> Q(q_input) + Copy_Scale_sig32_16( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff32_fx, st_ivas->hCPE[0]->hCoreCoder[n]->input_buff_fx, len_inp_memory, sub( add( Q16, 0 ), st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp32 ) ); // Q(q_data_fx) -> Q(q_input) st_ivas->hCPE[0]->hCoreCoder[n]->q_old_inp = 0; move16(); } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index d020b398a..19a850a89 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -113,7 +113,9 @@ ivas_error ivas_cpe_enc_fx( Word32 band_energies_LR_fx[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN (Q_buffer + QSCALE - band_ener_guardbits) */ Word16 Q_buffer[2]; Word16 orig_input_fx[CPE_CHANNELS][L_FRAME48k]; + Word32 orig_input_fx32[CPE_CHANNELS][L_FRAME48k]; Word16 Q_orig_inp[CPE_CHANNELS]; + Word16 Q_orig_inp32[CPE_CHANNELS]; Word16 Etot_last_fx[CPE_CHANNELS]; Word32 tmp, input_Fs; Word16 max_bwidth, ivas_format; @@ -127,7 +129,7 @@ ivas_error ivas_cpe_enc_fx( Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp; move16(); // Q_new move16(); // Q_new - Word16 q_com; + Word16 q_com, shift, q_min, gb; error = IVAS_ERR_OK; move32(); @@ -217,27 +219,32 @@ ivas_error ivas_cpe_enc_fx( #endif } - Word16 Q_min = s_min( q_data_fx, add( sts[0]->q_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) ); - scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_inp32 ) ); + Word16 norm, Q_min = s_min( q_data_fx, add( sts[0]->q_old_inp32, L_norm_arr( sts[0]->input32_fx - input_frame, input_frame ) ) ); + norm = L_norm_arr( data_fx_ch0, input_frame ); + IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/ + { + Q_min = s_min( Q_min, add( sts[1]->q_old_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) ); + norm = s_min( norm, L_norm_arr( data_fx_ch1, input_frame ) ); + } + scale_sig32( sts[0]->input32_fx - input_frame, input_frame, sub( Q_min, sts[0]->q_old_inp32 ) ); + sts[0]->q_old_inp32 = Q_min; + move16(); Copy_Scale_sig32( data_fx_ch0, sts[0]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) sts[0]->q_inp32 = Q_min; move16(); - Word16 norm = L_norm_arr( sts[0]->input32_fx, input_frame ); - Copy_Scale_sig32_16( sts[0]->input32_fx, sts[0]->input_fx, input_frame, norm ); sts[0]->q_inp = add( sub( sts[0]->q_inp32, Q16 ), norm ); move16(); IF( data_fx_ch1 != NULL ) /*this may happen for cases with odd number of channels*/ { - Q_min = s_min( q_data_fx, add( sts[1]->q_inp32, L_norm_arr( sts[1]->input32_fx - input_frame, input_frame ) ) ); - scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_inp32 ) ); + scale_sig32( sts[1]->input32_fx - input_frame, input_frame, sub( Q_min, sts[1]->q_old_inp32 ) ); + sts[1]->q_old_inp32 = Q_min; + move16(); Copy_Scale_sig32( data_fx_ch1, sts[1]->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) sts[1]->q_inp32 = Q_min; move16(); - norm = L_norm_arr( sts[1]->input32_fx, input_frame ); - Copy_Scale_sig32_16( sts[1]->input32_fx, sts[1]->input_fx, input_frame, norm ); sts[1]->q_inp = add( sub( sts[1]->q_inp32, Q16 ), norm ); move16(); @@ -297,8 +304,8 @@ ivas_error ivas_cpe_enc_fx( } FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) ); - Scale_sig( hCPE->hFrontVad[n]->mem_decim_fx, 2 * L_FILT_MAX, sub( scale_inp, hCPE->hFrontVad[n]->q_mem_decim ) ); + scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) ); + scale_sig( hCPE->hFrontVad[n]->mem_decim_fx, 2 * L_FILT_MAX, sub( scale_inp, hCPE->hFrontVad[n]->q_mem_decim ) ); sts[n]->q_inp = scale_inp; move16(); hCPE->hFrontVad[n]->q_mem_decim = scale_inp; @@ -382,53 +389,44 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Resets/updates in case of stereo switching *----------------------------------------------------------------*/ - Word16 shift = norm_arr( sts[1]->old_input_signal_fx, input_frame ); - Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ - sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift ); - move16(); - shift = norm_arr( sts[1]->input_fx, input_frame ); - Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */ - sts[1]->q_inp = add( sts[1]->q_inp, shift ); - move16(); - - shift = norm_arr( sts[0]->old_input_signal_fx, input_frame ); - Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */ - sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift ); - move16(); - shift = norm_arr( sts[0]->input_fx, input_frame ); - Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */ - sts[0]->q_inp = add( sts[0]->q_inp, shift ); - move16(); - - Word16 q_inp = s_min( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), s_min( sts[1]->q_inp, sts[1]->q_old_inp ) ); - - Scale_sig( sts[1]->input_fx, input_frame, sub( q_inp, sts[1]->q_inp ) ); /* q_inp */ - Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_inp, sts[1]->q_old_inp ) ); /* q_inp */ - sts[1]->q_inp = q_inp; - sts[1]->q_old_inp = q_inp; - move16(); - move16(); + test(); + IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) + { + gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); + shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); + shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); + + IF( LT_16( shift, gb ) ) + { + shift = sub( shift, gb ); + scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* q_inp32 + shift */ + scale_sig32( sts[0]->input32_fx, input_frame, shift ); /* q_inp32 + shift */ + scale_sig32( sts[1]->old_input_signal32_fx, input_frame, shift ); /* q_old_inp32 + shift */ + scale_sig32( sts[0]->old_input_signal32_fx, input_frame, shift ); /* q_old_inp32 + shift */ + sts[1]->q_inp32 = add( sts[1]->q_inp32, shift ); + sts[0]->q_inp32 = add( sts[0]->q_inp32, shift ); + sts[1]->q_old_inp32 = add( sts[1]->q_old_inp32, shift ); + sts[0]->q_old_inp32 = add( sts[0]->q_old_inp32, shift ); + move16(); + move16(); + move16(); + move16(); + } + } - Scale_sig( sts[0]->input_fx, input_frame, sub( q_inp, sts[0]->q_inp ) ); /* q_inp */ - Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_inp, sts[0]->q_old_inp ) ); /* q_inp */ - sts[0]->q_inp = q_inp; - move16(); - sts[0]->q_old_inp = q_inp; - move16(); - Scale_sig( sts[0]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( q_inp, sub( Q15, sts[0]->exp_buf_speech_enc ) ) ); // q_inp - sts[0]->exp_buf_speech_enc = sub( Q15, q_inp ); - move16(); - stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal_fx, input_frame, q_inp ); + stereo_switching_enc_fx( hCPE, sts[0]->old_input_signal32_fx, input_frame, sts[0]->q_old_inp32 ); /*----------------------------------------------------------------* * Temporal inter-channel alignment, stereo adjustment *----------------------------------------------------------------*/ - - Copy_Scale_sig_16_32_DEPREC( sts[0]->input_buff_fx, sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ - sts[0]->q_inp32 = add( Q6, sts[0]->q_inp ); + shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); + q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); + scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ + scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ + sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min; + move16(); + move16(); move16(); - Copy_Scale_sig_16_32_DEPREC( sts[1]->input_buff_fx, sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), Q6 ); /* Q6 + sts[0]->q_inp */ - sts[1]->q_inp32 = add( Q6, sts[1]->q_inp ); move16(); stereo_tca_enc_fx( hCPE, input_frame ); @@ -449,9 +447,12 @@ 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 */ 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(); IF( hCPE->hStereoICBWE != NULL ) @@ -633,10 +634,8 @@ ivas_error ivas_cpe_enc_fx( * Stereo processing * Stereo down-mix *----------------------------------------------------------------*/ - // printf("\n%f %f ", hCPE->hStereoClassif->is_speech, hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0]); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - /*flt2fix: dft_synthesize*/ test(); if ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] ) { @@ -657,7 +656,7 @@ ivas_error ivas_cpe_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { q_com = sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 ); - q_com = s_min( q_com, add( norm_arr( sts[n]->old_input_signal_fx, input_frame ), sts[n]->q_old_inp ) ); + q_com = s_min( q_com, sub( add( L_norm_arr( sts[n]->old_input_signal32_fx, input_frame ), sts[n]->q_old_inp32 ), 16 ) ); q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hCPE->hStereoDft->dft_ovl ), hCPE->q_input_mem[n] ) ); if ( EQ_16( q_com, Q15 ) ) @@ -670,7 +669,7 @@ ivas_error ivas_cpe_enc_fx( sts[n]->q_inp = q_com; move16(); - scale_sig( sts[n]->old_input_signal_fx, input_frame, sub( q_com, sts[n]->q_old_inp ) ); + Copy_Scale_sig_32_16( sts[n]->old_input_signal32_fx, sts[n]->old_input_signal_fx, input_frame, sub( q_com, sts[n]->q_old_inp32 ) ); sts[n]->q_old_inp = q_com; move16(); @@ -754,29 +753,32 @@ ivas_error ivas_cpe_enc_fx( sts[1]->exp_old_inp_12k8 = Q15; move16(); } - } - test(); - IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL ) - { - Word16 q_min; + q_min = sts[1]->q_old_inp; move16(); q_min = s_min( q_min, sts[1]->q_inp ); q_min = s_min( q_min, sts[0]->q_old_inp ); q_min = s_min( q_min, sts[0]->q_inp ); + q_min = s_min( q_min, hCPE->q_input_mem[0] ); + q_min = s_min( q_min, hCPE->q_input_mem[1] ); shift = norm_arr( sts[1]->old_input_signal_fx, input_frame ); shift = s_min( shift, norm_arr( sts[1]->input_fx, input_frame ) ); shift = s_min( shift, norm_arr( sts[0]->old_input_signal_fx, input_frame ) ); shift = s_min( shift, norm_arr( sts[0]->input_fx, input_frame ) ); + shift = s_min( shift, norm_arr( hCPE->input_mem_fx[0], hCPE->hStereoMdct->hDft_ana->dft_ovl ) ); + shift = s_min( shift, norm_arr( hCPE->input_mem_fx[1], hCPE->hStereoMdct->hDft_ana->dft_ovl ) ); q_min = add( q_min, shift ); - scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */ - scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */ - scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */ - scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */ - + scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */ + scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */ + scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */ + scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */ + scale_sig( hCPE->input_mem_fx[0], hCPE->hStereoMdct->hDft_ana->dft_ovl, sub( q_min, hCPE->q_input_mem[0] ) ); /* q_min */ + scale_sig( hCPE->input_mem_fx[1], hCPE->hStereoMdct->hDft_ana->dft_ovl, sub( q_min, hCPE->q_input_mem[1] ) ); /* q_min */ + hCPE->q_input_mem[1] = q_min; + hCPE->q_input_mem[0] = q_min; sts[1]->q_old_inp = q_min; sts[0]->q_old_inp = q_min; sts[1]->q_inp = q_min; @@ -785,12 +787,11 @@ ivas_error ivas_cpe_enc_fx( move16(); move16(); move16(); + move16(); + move16(); } stereo_td_itd_mdct_stereo_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); - - Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx - input_frame, sts[0]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[0]->q_inp32, sts[0]->q_inp ) ); - Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx - input_frame, sts[1]->input32_fx - input_frame, shl( input_frame, 1 ), sub( sts[1]->q_inp32, sts[1]->q_inp ) ); } /*----------------------------------------------------------------* @@ -816,30 +817,28 @@ ivas_error ivas_cpe_enc_fx( Word16 out_16k_start_ind = 0, out_16k_end_ind = 0; 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 ); - Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer + + 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; + sts[0]->q_old_inp32 = Q15; move16(); - - // Normalise the input buffer from Q15 - Word16 input_norm, q_inp32, common_q, fir_delay_len; - input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) ); - q_inp32 = add( Q15, input_norm ); - fir_delay_len = NS2SA_FX2( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); - // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 } - common_q = s_min( s_min( sub( q_inp32, 16 ), sts[0]->q_inp ), sts[0]->q_old_inp ); + // Normalise the input buffer from Q15 + Word16 input_norm, q_inp; //, common_q, fir_delay_len; + input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); + q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer - scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( common_q, sts[0]->q_old_inp ) ); // q_old_inp -> common_q - Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, common_q ), Q15 ) ); // Q15 -> common_q - scale_sig( sts[0]->input_fx + out_end_ind, add( sub( input_frame, out_end_ind ), fir_delay_len ), sub( common_q, sts[0]->q_inp ) ); // q_inp -> common_q + Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp // Update the Q-factors - sts[0]->q_inp = common_q; + sts[0]->q_inp = q_inp; move16(); - sts[0]->q_old_inp = common_q; + sts[0]->q_old_inp = q_inp; move16(); /* iDFT & resampling to 12.8kHz internal sampling rate */ @@ -849,7 +848,7 @@ ivas_error ivas_cpe_enc_fx( /* iDFT & resampling to 16kHz internal sampling rate for M channel */ IF( EQ_32( input_Fs, internal_Fs ) ) { - 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 ) ); /* Q_inp */ + 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 */ 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(); @@ -1225,12 +1224,12 @@ ivas_error ivas_cpe_enc_fx( /* update input samples buffer */ FOR( n = 0; n < CPE_CHANNELS; n++ ) { + Copy32( orig_input_fx32[n], sts[n]->old_input_signal32_fx, input_frame ); /* Q_orig_inp32 */ + sts[n]->q_old_inp32 = Q_orig_inp32[n]; + move16(); Copy( orig_input_fx[n], sts[n]->old_input_signal_fx, input_frame ); /* Q_orig_inp */ sts[n]->q_old_inp = Q_orig_inp[n]; move16(); - Copy_Scale_sig_16_32_no_sat( sts[n]->input_fx - input_frame, sts[n]->input32_fx - input_frame, input_frame, 16 ); // duplicating the data for input32_fx - sts[n]->q_inp32 = add( Q_orig_inp[n], 16 ); - move16(); } } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -1238,7 +1237,9 @@ ivas_error ivas_cpe_enc_fx( Copy( sts[0]->input_fx, sts[0]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */ sts[0]->q_old_inp = sts[0]->q_inp; move16(); - Copy32( sts[0]->input32_fx, sts[0]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ + Copy32( sts[0]->input32_fx, sts[0]->old_input_signal32_fx, input_frame ); /* st->q_inp32 */ + sts[0]->q_old_inp32 = sts[0]->q_inp32; + move16(); } ELSE IF( st_ivas->hMCT == NULL ) /* note: in MCT, input buffers are updated later in ivas_mct_enc() */ { @@ -1248,7 +1249,9 @@ ivas_error ivas_cpe_enc_fx( Copy( sts[n]->input_fx, sts[n]->old_input_signal_fx, input_frame ); /* sts[n]->q_inp */ sts[n]->q_old_inp = sts[n]->q_inp; move16(); - Copy32( sts[n]->input32_fx, sts[n]->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ + Copy32( sts[n]->input32_fx, sts[n]->old_input_signal32_fx, input_frame ); /* st->q_inp32 */ + sts[n]->q_old_inp32 = sts[n]->q_inp32; + move16(); } } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 81c9e01ef..122ea1d75 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -167,6 +167,8 @@ ivas_error ivas_ism_enc_fx( *-----------------------------------------------------------------*/ Word16 Q_min = s_min( q_data, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) ); scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) ); + st->q_old_inp32 = Q_min; + move16(); Copy_Scale_sig32( data[sce_id], st->input32_fx, input_frame, sub( Q_min, q_data ) ); // Q(Q_min) st->q_inp32 = Q_min; move16(); @@ -474,7 +476,9 @@ ivas_error ivas_ism_enc_fx( Copy( st->input_fx, st->old_input_signal_fx, input_frame ); /* st->q_inp */ st->q_old_inp = st->q_inp; move16(); - Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ + Copy32( st->input32_fx, st->old_input_signal32_fx, input_frame ); /* st->q_inp32 */ + st->q_old_inp32 = st->q_inp32; + move16(); hSCE->last_element_brate = hSCE->element_brate; /* Q0 */ move32(); diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 56f5e44db..ee9353379 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -484,6 +484,9 @@ ivas_error ivas_mct_enc_fx( Copy( hCPE->hCoreCoder[n]->input_fx, hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame ); hCPE->hCoreCoder[n]->q_old_inp = hCPE->hCoreCoder[n]->q_inp; move16(); + Copy32( hCPE->hCoreCoder[n]->input32_fx, hCPE->hCoreCoder[n]->old_input_signal32_fx, input_frame ); + hCPE->hCoreCoder[n]->q_old_inp32 = hCPE->hCoreCoder[n]->q_inp32; + move16(); /* common encoder updates */ updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index a578a3cfa..f0811aea6 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -124,6 +124,8 @@ ivas_error ivas_sce_enc_fx( Word16 Q_min = s_min( q_data_fx, add( st->q_inp32, L_norm_arr( st->input32_fx - input_frame, input_frame ) ) ); scale_sig32( st->input32_fx - input_frame, input_frame, sub( Q_min, st->q_inp32 ) ); + st->q_old_inp32 = Q_min; + move16(); Copy_Scale_sig32( data_fx, st->input32_fx, input_frame, sub( Q_min, q_data_fx ) ); // Q(Q_min) st->q_inp32 = Q_min; move16(); @@ -366,7 +368,9 @@ ivas_error ivas_sce_enc_fx( Copy( st->input_fx, st->old_input_signal_fx, input_frame ); st->q_old_inp = st->q_inp; move16(); - Copy32( st->input32_fx, st->input32_fx - input_frame, input_frame ); /* st->q_inp32 */ + Copy32( st->input32_fx, st->old_input_signal32_fx, input_frame ); /* st->q_inp32 */ + st->q_old_inp32 = st->q_inp32; + move16(); hSCE->last_element_brate = hSCE->element_brate; move32(); diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 6406158b4..80c4b5a21 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -1030,7 +1030,7 @@ void stereo_dft_enc_analyze_fx( FOR( n = 0; n < n_channels; n++ ) { - Scale_sig( &mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Q(sts[n]->q_inp) + Scale_sig( &mem[n][0], dft_ovl, sub( sts[n]->q_inp, q_input_mem[n] ) ); // Q(sts[n]->q_inp) q_input_mem[n] = sts[n]->q_inp; move16(); } @@ -1115,8 +1115,7 @@ void stereo_dft_enc_analyze_fx( Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - // float *output, /* o : output synthesis */ - Word32 *output_fx, /* o : output synthesis Q15 */ + Word32 *output_fx, /* o : output synthesis Q15 */ Word16 *output_start_index, Word16 *output_end_index, const Word16 chan, /* i : channel number */ @@ -1126,25 +1125,18 @@ Word32 stereo_dft_enc_synthesize_fx( Word16 *nrg_out_fx_e ) { Word16 i, j, sign; - // float *pDFT_in; Word32 *pDFT_in_fx; Word16 DFT_in_fx_e; Word16 offset, NFFT, N, ovl, zp; Word16 temp_exp; - // float fac; Word32 fac_fx; - // float *mem; Word32 *mem_fx; - // const float *trigo, *win, *win_ana; const Word16 *trigo_fx; const Word32 *win_fx; const Word16 *win_ana_fx; - // float tmp[STEREO_DFT_N_MAX_ENC]; Word32 tmp_fx[STEREO_DFT_N_MAX_ENC]; - // float nrg; Word32 nrg_fx; Word16 nrg_fx_e; - // float trigo_enc[STEREO_DFT_N_MAX_ENC / 2 + 1]; Word16 trigo_enc_fx[STEREO_DFT_N_MAX_ENC / 2 + 1]; Word16 trigo_step; Word16 scal_fac; diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index c457faa4f..309ec3377 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -499,8 +499,8 @@ void stereo_td_itd_fx( Copy( shift_input, sts[ch]->input_fx, input_frame ); sts[ch]->q_inp = q_new_shift; move16(); - /*sts[ch]->q_old_inp = q_new_shift; - move16();*/ + Copy_Scale_sig_16_32_no_sat( sts[ch]->input_fx, sts[ch]->input32_fx, input_frame, sub( sts[ch]->q_inp32, sts[ch]->q_inp ) ); + IF( EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) ) { // here shift_mem has same as input_mem, no need to update q // @@ -512,6 +512,7 @@ void stereo_td_itd_fx( sts[ch]->q_old_inp = q_new_shift; move16(); Scale_sig( mdct_mem[ch], input_frame, sub( sts[ch]->q_inp, q_shift_mem ) ); // Q(sts[ch]->q_inp) + Copy_Scale_sig_16_32_no_sat( shift_mem, sts[ch]->old_input_signal32_fx, input_frame, sub( sts[ch]->q_old_inp32, q_shift_mem ) ); } } } @@ -531,7 +532,7 @@ void stereo_td_itd_mdct_stereo_fx( const Word16 input_frame /* i : frame length */ ) { - Word16 i, n, q_com; + Word16 i; Word32 bin_nrgL_fx[STEREO_DFT_N_32k_ENC]; Word16 bin_nrgL_e[STEREO_DFT_N_32k_ENC]; Word32 bin_nrgR_fx[STEREO_DFT_N_32k_ENC]; @@ -575,37 +576,6 @@ void stereo_td_itd_mdct_stereo_fx( /*call ITD function*/ stereo_dft_enc_compute_itd_fx( hCPE, DFT_fx[0], DFT_tmp_e[0], DFT_fx[1], DFT_tmp_e[1], STEREO_DFT_OFFSET, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL_fx, bin_nrgL_e, bin_nrgR_fx, bin_nrgR_e ); - q_com = MAX_16; - move16(); - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->input_fx, input_frame ), hCPE->hCoreCoder[n]->q_inp ) ); - q_com = s_min( q_com, add( norm_arr( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame ), hCPE->hCoreCoder[n]->q_old_inp ) ); - q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl ), hCPE->q_input_mem[n] ) ); - - if ( EQ_16( q_com, Q15 ) ) - { - q_com = 0; - move16(); - } - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - scale_sig( hCPE->hCoreCoder[n]->input_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_inp ) ); - hCPE->hCoreCoder[n]->q_inp = q_com; - move16(); - - scale_sig( hCPE->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, hCPE->hCoreCoder[n]->q_old_inp ) ); - hCPE->hCoreCoder[n]->q_old_inp = q_com; - move16(); - - scale_sig( hCPE->input_mem_fx[n], hStereoMdct->hDft_ana->dft_ovl, sub( q_com, hCPE->q_input_mem[n] ) ); - hCPE->q_input_mem[n] = q_com; - move16(); - } - /* Time Domain ITD compensation using extrapolation */ stereo_td_itd_fx( hStereoMdct->hItd, NULL, NULL, 1, hStereoMdct->hDft_ana->dft_ovl, hCPE->hCoreCoder, input_frame, hCPE->input_mem_fx, hCPE->q_input_mem ); } diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 6057ace6b..d0252a1f1 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -2088,6 +2088,10 @@ void stereo_tca_enc_fx( move16(); sts[1]->q_inp32 = sub( sts[1]->q_inp32, 2 ); move16(); + sts[0]->q_old_inp32 = sub( sts[0]->q_old_inp32, 2 ); + move16(); + sts[1]->q_old_inp32 = sub( sts[1]->q_old_inp32, 2 ); + move16(); } /* update L/R DS memories */ @@ -2319,17 +2323,17 @@ static void unclr_calc_corr_features_fx( move32(); } - hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */ + hStereoClassif->unclr_fv_fx[E_corrEst0] = L_shl_sat( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */ move32(); - hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */ + hStereoClassif->unclr_fv_fx[E_corrEstMax] = L_shl_sat( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */ move32(); - hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */ + hStereoClassif->unclr_fv_fx[E_corrLagMax] = L_shl_sat( corrLagMax, 15 ); /* Q15 */ move32(); - hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */ + hStereoClassif->xtalk_fv_fx[E_corrEst0] = L_shl_sat( corrEst[abs_s( lagSearchRange[0] )], sub( corrEst_exp, 16 ) ); /* Q15 */ move32(); - hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */ + hStereoClassif->xtalk_fv_fx[E_corrEstMax] = L_shl_sat( corrEstMax, sub( corrEst_exp, 16 ) ); /* Q15 */ move32(); - hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl( corrLagMax, 15 ); /* Q15 */ + hStereoClassif->xtalk_fv_fx[E_corrLagMax] = L_shl_sat( corrLagMax, 15 ); /* Q15 */ move32(); /* L/M and R/M correlation */ diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 5f1208ba7..8e372b311 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -628,23 +628,6 @@ ivas_error stereo_memory_enc_fx( return error; } -static void v_multc_fixed_32_16( - const Word16 x[], /* i : Input vector Qx*/ - const Word32 c, /* i : Constant Q31*/ - Word32 y[], /* o : Output vector that contains c*x Qx*/ - const Word16 N /* i : Vector length Q0*/ -) -{ - Word16 i; - - FOR( i = 0; i < N; i++ ) - { - y[i] = Mpy_32_16_1( c, x[i] ); /* Q16+Qx */ - move32(); - } - - return; -} /*-------------------------------------------------------------------* * Function stereo_switching_enc() * @@ -653,7 +636,7 @@ static void v_multc_fixed_32_16( void stereo_switching_enc_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - Word16 old_input_signal_pri[], /* i : old input signal of primary channel q_inp*/ + Word32 old_input_signal_pri[], /* i : old input signal of primary channel q_inp*/ const Word16 input_frame, /* i : input frame length Q0*/ const Word16 q_inp ) { @@ -672,8 +655,8 @@ void stereo_switching_enc_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */ - hCPE->q_input_mem[n] = sts[n]->q_inp; + Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16*/ + hCPE->q_input_mem[n] = sub( sts[n]->q_inp32, 16 ); move16(); } } @@ -681,9 +664,9 @@ void stereo_switching_enc_fx( /* save original stereo input (MDCT overlap part) for both channels in unused old input of right channel for possible DFT->MDCT transition */ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - Copy( sts[0]->input_fx + sub( (Word16) Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[0]->encoderLookahead_FB ), sts[1]->input_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB ); /* sts[0]->q_inp */ + Copy32( sts[0]->input32_fx + sub( extract_l( Mpy_32_32( sts[0]->input_Fs, 42949673 /* 1/50 in Q31*/ ) ), sts[0]->encoderLookahead_FB ), sts[1]->input32_fx - shl( sts[0]->encoderLookahead_FB, 1 ), sts[0]->encoderLookahead_FB ); /* sts[0]->q_inp32 */ - Copy( sts[1]->input_fx + sub( (Word16) Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ), sts[1]->encoderLookahead_FB ), sts[1]->input_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp */ + Copy32( sts[1]->input32_fx + sub( extract_l( Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ) ), sts[1]->encoderLookahead_FB ), sts[1]->input32_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp32 */ } @@ -694,7 +677,7 @@ void stereo_switching_enc_fx( /* window DFT synthesis overlap memory @input_Fs, primary channel */ FOR( i = 0; i < dft_ovl; i++ ) { - hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shr( Mpy_32_16_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), add( q_inp, 1 ) ); // Q31 + q_inp - Q15 - (q_inp + 1) -> Q15 + 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 move32(); } /* reset 48kHz BWE overlap memory */ @@ -728,7 +711,7 @@ void stereo_switching_enc_fx( /* update DFT synthesis overlap memory @12.8kHz */ FOR( i = 0; i < STEREO_DFT_OVL_12k8; i++ ) { - 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] ), q_inp + 1 ); /* Q15 */ + 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(); } Word16 q_dmx = Q15; @@ -816,10 +799,10 @@ void stereo_switching_enc_fx( offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels ); /* Q0 */ FOR( i = 0; i < offset; i++ ) { - sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */ + sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = old_input_signal_pri[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i]; /* q_inp */ move32(); } - sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); + sts[0]->cldfbAnaEnc->Q_cldfb_state = q_inp; move16(); } @@ -838,18 +821,18 @@ void stereo_switching_enc_fx( test(); IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) ) { - v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ - sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); + v_multc_fixed( hCPE->hCoreCoder[1]->old_input_signal32_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ + sts[1]->cldfbAnaEnc->Q_cldfb_state = q_inp; move16(); } ELSE { FOR( i = 0; i < offset; i++ ) { - sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */ + sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = ( hCPE->hCoreCoder[1]->old_input_signal32_fx[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* q_inp */ move32(); } - sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp ); + sts[1]->cldfbAnaEnc->Q_cldfb_state = q_inp; move16(); } @@ -929,9 +912,9 @@ void stereo_switching_enc_fx( tmp_fx = div_s( 64, shl( sts[0]->encoderLookahead_FB, Q6 ) ); /* Q15 */ FOR( i = 0; i < sts[0]->encoderLookahead_FB; i++ ) { - sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */ + sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i] = ( Mpy_32_16_1( L_add( imult3216( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), imult3216( sts[1]->input32_fx[-sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ) ); /* sts[0]->q_inp32 */ move32(); - sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = L_shr( Mpy_32_16_1( L_add( Mpy_32_16_1( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), Mpy_32_16_1( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ), 13 ); /* q_inp32+0-15+15-15-13 */ + sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i] = ( Mpy_32_16_1( L_add( imult3216( sts[0]->input32_fx[-sts[0]->encoderLookahead_FB + i], sts[0]->encoderLookahead_FB - i ), imult3216( sts[1]->input32_fx[-2 * sts[0]->encoderLookahead_FB + i], i ) ), tmp_fx ) ); /* sts[0]->q_inp32 */ move32(); } /* restore continuous signal in right channel (part of old_output was used to store original left channel) */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 4da0bff61..3d6f23dd3 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1457,7 +1457,9 @@ typedef struct enc_core_structure Word16 q_inp32; Word16 q_inp; Word16 *old_input_signal_fx; + Word32 *old_input_signal32_fx; Word16 q_old_inp; + Word16 q_old_inp32; Word16 Q_old_wtda; SIGNAL_BUFFERS_ENC_HANDLE hSignalBuf; -- GitLab