From 47fe3fc529be651d476e21441652186b54d0299e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:31:16 +0530 Subject: [PATCH 1/2] Speech buffer scaling fix and scaling fix in ivas_core_enc --- lib_com/ivas_prot_fx.h | 3 +- lib_com/prot.h | 1 + lib_enc/core_enc_init_fx.c | 47 +++++++++++++++++---------- lib_enc/ext_sig_ana_fx.c | 11 ++++--- lib_enc/ivas_core_enc_fx.c | 14 ++++---- lib_enc/ivas_core_pre_proc_front_fx.c | 4 +-- lib_enc/ivas_core_pre_proc_fx.c | 40 ++++++++++++----------- lib_enc/stat_enc.h | 20 ++++++------ 8 files changed, 78 insertions(+), 62 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 80bdda3c2..b581dfa7e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,8 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe ); + Word16 *Q_new); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 16f4659a0..f5d69075e 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -761,6 +761,7 @@ void preemph_ivas_fx( const Word16 L, /* i : vector size Q0*/ Word32 *mem /* i/o: memory (x[-1]) Qx*/ ); + void cb_shape( const int16_t preemphFlag, /* i : flag for pre-emphasis */ const int16_t pitchFlag, /* i : flag for pitch sharpening */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 4151725af..c2b1c22e1 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -3,8 +3,8 @@ ====================================================================================*/ #include -//#include "prot_fx.h" -//#include "basop_mpy.h" +// #include "prot_fx.h" +// #include "basop_mpy.h" #include "options.h" #include "cnst.h" #include "stl.h" @@ -1375,6 +1375,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol } // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); st->exp_buf_wspeech_enc = st->exp_old_wsp; move16(); @@ -1384,25 +1385,36 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol test(); IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) { - // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_12k8 ) + { + Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_12k8 ) ); // Scaling to common Q + Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_12k8; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) { lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_16k ) + { + Copy_Scale_sig( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_16k ) ); // Scaling to common Q + Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_16k; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; @@ -1416,6 +1428,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) { + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); st->exp_buf_wspeech_enc = st->exp_old_wsp; diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c437be5be..732c1ba11 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,8 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */ - Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1 + Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -747,10 +748,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + + PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 - Preemph_scaled( st->new_speech_enc_pe, Q_new, &( st->mem_preemph_enc ), - st->Q_max_enc, st->preemph_fac, 1, 0, 2, L_frame, st->coder_type_raw, 1 ); } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6dc3d10ec..303adecfd 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -734,8 +734,8 @@ ivas_error ivas_core_enc_fx( Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda } - Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, input_frame ); - Scale_sig( new_swb_speech_buffer_fx_16, input_frame, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer + Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer /* SWB TBE encoder */ test(); @@ -759,11 +759,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { - Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 - Scale_sig( new_swb_speech_fx_16, input_frame, negate( q_new_swb_speech_buffer ) ); // Q0 + Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, negate( q_new_swb_speech_buffer ) ); // q_new_swb_speech_buffer -> Q0 /* SWB(FB) BWE encoder */ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); - Scale_sig( new_swb_speech_fx_16, input_frame, q_new_swb_speech_buffer ); // q_new_swb_speech_buffer + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0 -> q_new_swb_speech_buffer } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 @@ -793,8 +793,8 @@ ivas_error ivas_core_enc_fx( stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); - Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer - 16 - > q_new_swb_speech_buffer + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 7bb67cbbd..04e518e99 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -725,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx( shift = sub( norm_s( inp_max ), headroom ); Word16 Q_min; - shift = s_max( shift, -1 ); + shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); *Q_new = s_min( shift, Q_min ); @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 1 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 718a09026..f4712a771 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -579,14 +579,28 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); - Word16 Q_old_inp_128k = *Q_new; + Word16 Q_inp_12k8 = *Q_new; + move16(); + Word16 Q_inp_16k = *Q_new; move16(); IF( !flag_16k_smc ) { error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 0 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k); + IF (GT_16(Q_inp_16k, Q_inp_12k8)) + { + Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); + *Q_new = Q_inp_12k8; + } + ELSE + { + Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); + *Q_new = Q_inp_16k; + } + move16(); + IF( error != IVAS_ERR_OK ) { return error; @@ -628,7 +642,7 @@ ivas_error pre_proc_ivas_fx( IF( flag_16k_smc ) { - Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_new - 1 */ + Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */ } /*-----------------------------------------------------------------* @@ -643,14 +657,11 @@ ivas_error pre_proc_ivas_fx( /* set the pointer of the current frame for the ACELP core */ IF( EQ_16( st->L_frame, L_FRAME ) ) { - *inp_fx = inp_12k8_fx; /* Q_old_inp_128k */ - *Q_new = Q_old_inp_128k; - move16(); + *inp_fx = inp_12k8_fx; /* Q_old_inp_12k8 */ } ELSE { *inp_fx = inp_16k_fx; - Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_128k ) ); } /* Update VAD hangover frame counter in active frames */ @@ -703,9 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe /* Q0 */ -) + Word16 *Q_new) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1103,14 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - IF( downscale_buf_speech_enc_pe ) - { - shift = negate( *Q_new ); - } - ELSE - { - shift = 0; - } + shift = negate(*Q_new); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1148,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + 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 ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6292c4b33..12cf078cf 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; - Word16 *buf_wspeech_enc; + Word16 *buf_speech_enc; //exp_buf_speech_enc + Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; - Word16 *speech_enc_pe; - Word16 *new_speech_enc; - Word16 *new_speech_enc_pe; - Word16 *wspeech_enc; + Word16 *speech_enc; //exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; //exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; //exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab From 42806254d09551b20f527354a61fff694d80d9a9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:33:58 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ext_sig_ana_fx.c | 11 +++++------ lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 20 ++++++++++---------- lib_enc/stat_enc.h | 22 +++++++++++----------- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b581dfa7e..a61d6228d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,7 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new); + Word16 *Q_new ); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 732c1ba11..9e6318591 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,9 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); - /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc - This is considering new_samples is in q 0 in current code*/ + Copy_Scale_sig( new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc ) ); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -748,10 +748,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same - - PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 04e518e99..f963b55a4 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index f4712a771..1234a6876 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -588,19 +588,19 @@ ivas_error pre_proc_ivas_fx( error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k); - IF (GT_16(Q_inp_16k, Q_inp_12k8)) + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); + IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { - Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); - *Q_new = Q_inp_12k8; + Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) ); + *Q_new = Q_inp_12k8; } ELSE { - Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); - *Q_new = Q_inp_16k; + Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_inp_16k, Q_inp_12k8 ) ); + *Q_new = Q_inp_16k; } move16(); - + IF( error != IVAS_ERR_OK ) { return error; @@ -714,7 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new) + Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1112,7 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - shift = negate(*Q_new); + shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1150,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + 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 ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 12cf078cf..d9f71128d 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; //exp_buf_speech_enc - Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16 *buf_speech_enc; // exp_buf_speech_enc + Word16 *buf_wspeech_enc; // exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; //exp_buf_speech_enc - Word16 *speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *new_speech_enc; //exp_buf_speech_enc - Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *wspeech_enc; //exp_buf_wspeech_enc + Word16 *speech_enc; // exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; // exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; // exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab