From 1587355652f70ddd70e10a7eed681b3fe8affe82 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 10:54:53 +0100 Subject: [PATCH 1/7] FIX_2344_ALIGN_PREPROC --- lib_com/ivas_prot_fx.h | 4 +- lib_com/options.h | 1 + lib_enc/ivas_core_enc_fx.c | 20 +++++ lib_enc/ivas_core_pre_proc_fx.c | 145 +++++++++++++++++++++++++++----- 4 files changed, 147 insertions(+), 23 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9934f6e46..89a477f52 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5870,8 +5870,8 @@ ivas_error ivas_compute_core_buffers_fx( Word32 epsP[M + 1], /* i/o: LP prediction errors */ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ - Word16 Q_old_inp_16k, - Word16 Q_r[2], + const Word16 Q_old_inp_16k, + const Word16 Q_r[2], Word16 *Q_new ); diff --git a/lib_com/options.h b/lib_com/options.h index a884d61ec..de2306030 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ +#define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7dd2bcb04..05a28cdf5 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -230,6 +230,24 @@ ivas_error ivas_core_enc_fx( #endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } + +#ifdef FIX_2344_ALIGN_PREPROC + Word32 last_element_brate_tmp = last_element_brate; + move32(); + IF( EQ_32( ivas_format, SBA_FORMAT ) ) + { + last_element_brate_tmp = element_brate; + move32(); + } + + IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( EQ_32( ivas_format, SBA_FORMAT ) ) { IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, @@ -250,6 +268,8 @@ ivas_error ivas_core_enc_fx( return error; } } +#endif + test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) ) { diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 9857c3e12..28d8d4a0a 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -111,6 +111,7 @@ ivas_error pre_proc_ivas_fx( lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS ); move16(); } + /*----------------------------------------------------------------* * Selection of internal ACELP Fs (12.8 kHz or 16 kHz) *----------------------------------------------------------------*/ @@ -163,6 +164,26 @@ ivas_error pre_proc_ivas_fx( move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + total_brate_tmp = ACELP_16k40; + move16(); + } + ELSE + { + total_brate_tmp = ACELP_9k60; + move16(); + } + + test(); + test(); + test(); + IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) + { + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp ); + } +#else test(); test(); test(); @@ -182,6 +203,7 @@ ivas_error pre_proc_ivas_fx( { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); } +#endif if ( st->ini_frame == 0 ) { @@ -224,6 +246,7 @@ ivas_error pre_proc_ivas_fx( * IC frames selection * enforce TC frames in case of switching *-----------------------------------------------------------------*/ + test(); test(); test(); @@ -284,7 +307,6 @@ ivas_error pre_proc_ivas_fx( move16(); } - /*---------------------------------------------------------------------* * Decision matrix (selection of technologies) *---------------------------------------------------------------------*/ @@ -305,6 +327,7 @@ ivas_error pre_proc_ivas_fx( /* core selection */ ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode ); + test(); test(); if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */ @@ -396,14 +419,14 @@ ivas_error pre_proc_ivas_fx( } } - /*-----------------------------------------------------------------* * Update of ACELP harmonicity counter (used in ACELP transform codebook @32kbps) *-----------------------------------------------------------------*/ + test(); test(); test(); - IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) ) + IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << Q8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) ) { st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */ move16(); @@ -471,6 +494,7 @@ ivas_error pre_proc_ivas_fx( } } +#ifndef FIX_2344_ALIGN_PREPROC /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */ test(); test(); @@ -479,7 +503,7 @@ ivas_error pre_proc_ivas_fx( st->sharpFlag = 1; move16(); } - +#endif /* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */ test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) @@ -514,6 +538,7 @@ ivas_error pre_proc_ivas_fx( /*-----------------------------------------------------------------* * Compute core-coder buffers at internal sampling rate *-----------------------------------------------------------------*/ + IF( st->tcxonly == 0 ) { sr_core_tmp = INT_FS_16k; @@ -567,16 +592,28 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); +#ifndef FIX_2344_ALIGN_PREPROC Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k = *Q_new; move16(); +#endif + 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_inp_16k ); +#ifdef FIX_2344_ALIGN_PREPROC + Word16 Q_inp_12k8 = *Q_new; + move16(); + Word16 Q_inp_16k; +#endif + 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 ); +#ifdef FIX_2344_ALIGN_PREPROC + IF( error != IVAS_ERR_OK ) + { + return error; + } +#endif + IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) ); @@ -589,11 +626,12 @@ ivas_error pre_proc_ivas_fx( } move16(); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } - +#endif test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -601,6 +639,7 @@ ivas_error pre_proc_ivas_fx( move16(); } } + test(); IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) ) { @@ -681,11 +720,13 @@ ivas_error pre_proc_ivas_fx( return error; } + /*-------------------------------------------------------------------* * ivas_compute_core_buffers() * * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ + ivas_error ivas_compute_core_buffers_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ @@ -700,8 +741,8 @@ ivas_error ivas_compute_core_buffers_fx( Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 Q_old_inp_16k, - Word16 Q_r[2], + const Word16 Q_old_inp_16k, + const Word16 Q_r[2], Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; @@ -716,19 +757,28 @@ ivas_error ivas_compute_core_buffers_fx( Word16 Q_tmp, mem_decim16k_size, size_modified; Word16 epsP_h[M + 1]; Word16 epsP_l[M + 1]; - +#ifdef FIX_2344_ALIGN_PREPROC + Word16 i, shift, Q_min; + Word16 preemp_len, inp_max; +#else Word16 headroom = 1, preemp_len = 0, inp_max = 0; move16(); move16(); move16(); +#endif Word16 *preemp_start_idx = NULL; +#ifdef FIX_2344_ALIGN_PREPROC + Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; +#else Word32 sig_out[960], max_32; - /*Word16 Q_exp, Q_wsp_exp*/; +#endif + +#ifndef FIX_2344_ALIGN_PREPROC set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k ); set16_fx( epsP_h, 0, M + 1 ); set16_fx( epsP_l, 0, M + 1 ); set16_fx( input_buf_fx, 0, L_FRAME48k * 2 ); - +#endif Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); @@ -754,9 +804,9 @@ ivas_error ivas_compute_core_buffers_fx( /*---------------------------------------------------------------* * Preprocessing at other sampling frequency rate (16/25.6/32kHz) *----------------------------------------------------------------*/ + IF( st->tcxonly == 0 ) { - L_frame_tmp = L_FRAME16k; move16(); } @@ -845,14 +895,23 @@ ivas_error ivas_compute_core_buffers_fx( Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#ifdef FIX_2344_ALIGN_PREPROC + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#else + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#endif Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); IF( lMemRecalc > 0 ) { +#ifdef FIX_2344_ALIGN_PREPROC + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#else size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#endif } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); @@ -936,6 +995,7 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } +#ifndef FIX_2344_ALIGN_PREPROC test(); test(); @@ -948,10 +1008,21 @@ ivas_error ivas_compute_core_buffers_fx( { headroom = add( headroom, 1 ); } + +#endif test(); +#ifdef FIX_2344_ALIGN_PREPROC + IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) +#else test(); IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) +#endif { +#ifdef FIX_2344_ALIGN_PREPROC + preemp_len = 0; + move16(); +#endif + IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */ @@ -1037,8 +1108,11 @@ ivas_error ivas_compute_core_buffers_fx( maximum_abs_32_fx( sig_out, preemp_len, &max_32 ); inp_max = s_max( extract_h( max_32 ), 1 ); +#ifdef FIX_2344_ALIGN_PREPROC + shift = sub( norm_s( inp_max ), 1 /* headroom */ ); +#else Word16 shift = sub( norm_s( inp_max ), headroom ); - Word16 Q_min, i; +#endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min ); @@ -1063,8 +1137,13 @@ ivas_error ivas_compute_core_buffers_fx( Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE /* keep memory up-to-date in case of bitrate switching */ +#else ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ +#endif { +#ifndef FIX_2344_ALIGN_PREPROC IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ @@ -1075,7 +1154,9 @@ ivas_error ivas_compute_core_buffers_fx( st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ move16(); } - ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + ELSE +#endif + IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { st->mem_preemph16k_fx = 0; move16(); @@ -1098,7 +1179,9 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { /* update signal buffers */ +#ifndef FIX_2344_ALIGN_PREPROC Word16 shift; +#endif shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -1134,6 +1217,14 @@ ivas_error ivas_compute_core_buffers_fx( analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); } +#ifdef FIX_2344_ALIGN_PREPROC + FOR( i = 0; i < M + 1; i++ ) + { + epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); + move32(); + } + +#endif /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ @@ -1148,20 +1239,30 @@ ivas_error ivas_compute_core_buffers_fx( /* update old input signal @16kHz buffer */ test(); test(); +#ifndef FIX_2344_ALIGN_PREPROC test(); +#endif IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); st->exp_old_inp_16k = 0; move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE IF( EQ_32( sr_core, INT_FS_16k ) ) +#else ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) +#endif { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) move16(); } +#ifdef FIX_2344_ALIGN_PREPROC + ELSE +#else ELSE IF( GT_32( input_Fs, 8000 ) ) +#endif { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); @@ -1178,6 +1279,8 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k ); } + +#ifndef FIX_2344_ALIGN_PREPROC test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -1187,6 +1290,6 @@ ivas_error ivas_compute_core_buffers_fx( move32(); } } - +#endif return IVAS_ERR_OK; } -- GitLab From 19900d340debff41bb3b4e34f1d0d3f45abaa36c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 11:27:38 +0100 Subject: [PATCH 2/7] updates --- lib_com/ivas_prot_fx.h | 16 +++++++++-- lib_enc/ivas_core_enc_fx.c | 10 ++----- lib_enc/ivas_core_pre_proc_front_fx.c | 12 ++++++++ lib_enc/ivas_core_pre_proc_fx.c | 40 +++++++++++++++++++-------- lib_enc/ivas_cpe_enc_fx.c | 17 ++++++++---- lib_enc/ivas_ism_enc_fx.c | 15 +++++++--- lib_enc/ivas_sce_enc_fx.c | 25 +++++++++++++++++ 7 files changed, 106 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 70ec25d85..09dc6d3b3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5856,7 +5856,11 @@ ivas_error ivas_mct_enc_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void ivas_compute_core_buffers_fx( +#else ivas_error ivas_compute_core_buffers_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ @@ -5871,7 +5875,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ const Word16 Q_old_inp_16k, - const Word16 Q_r[2], + Word16 Q_r[2], Word16 *Q_new ); @@ -5961,7 +5965,11 @@ void ivas_mct_enc_close_fx( MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_front_ivas_fx( +#else ivas_error pre_proc_front_ivas_fx( +#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -6017,7 +6025,11 @@ ivas_error pre_proc_front_ivas_fx( Word16 *Q_new /* i/o : Q factor of speech buffers */ ); +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_ivas_fx( +#else ivas_error pre_proc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -6046,7 +6058,7 @@ ivas_error pre_proc_ivas_fx( const Word16 e_enerBuffer, /* i : Q value of energy buffer */ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/ - Word16 *Q_new /* i/o : Q factor of speech buffers */ + Word16 *Q_new /* i/o: Q factor of speech buffers */ ); void ivas_initialize_handles_enc_fx( diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 05a28cdf5..30d8f315e 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -240,13 +240,9 @@ ivas_error ivas_core_enc_fx( move32(); } - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } + pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ); #else IF( EQ_32( ivas_format, SBA_FORMAT ) ) { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index d17b4d358..e621a4bdc 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -76,7 +76,11 @@ static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_front_ivas_fx( +#else ivas_error pre_proc_front_ivas_fx( +#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -1476,11 +1480,15 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ +#ifdef FIX_2344_ALIGN_PREPROC + 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 ); +#else 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 ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } +#endif *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1571,7 +1579,11 @@ ivas_error pre_proc_front_ivas_fx( free( temp1F_icatdmResampBuf_fx ); #endif pop_wmops(); +#ifdef FIX_2344_ALIGN_PREPROC + return; +#else return error; +#endif } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 63c7b839a..adfabb741 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -46,7 +46,11 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void pre_proc_ivas_fx( +#else ivas_error pre_proc_ivas_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -75,20 +79,23 @@ ivas_error pre_proc_ivas_fx( const Word16 e_enerBuffer, /* i : Q value of energy buffer */ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/ - Word16 *Q_new /* i/o : Q factor of speech buffers */ + Word16 *Q_new /* i/o: Q factor of speech buffers */ ) { Word16 L_look, element_mode, lMemRecalc_12k8; Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */ Word16 *wsp_fx; /* weighted input signal buffer */ Word32 sr_core_tmp, total_brate_tmp; +#ifndef FIX_2344_ALIGN_PREPROC ivas_error error; +#endif push_wmops( "pre_proc" ); +#ifndef FIX_2344_ALIGN_PREPROC error = IVAS_ERR_OK; move32(); - +#endif /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -607,13 +614,14 @@ ivas_error pre_proc_ivas_fx( Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k; -#endif - 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 ); -#ifdef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return 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 ); +#else + 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 ); + #endif IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) @@ -719,7 +727,11 @@ ivas_error pre_proc_ivas_fx( } pop_wmops(); +#ifdef FIX_2344_ALIGN_PREPROC + return; +#else return error; +#endif } @@ -729,7 +741,11 @@ ivas_error pre_proc_ivas_fx( * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ +#ifdef FIX_2344_ALIGN_PREPROC +void ivas_compute_core_buffers_fx( +#else ivas_error ivas_compute_core_buffers_fx( +#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ @@ -744,7 +760,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ const Word16 Q_old_inp_16k, - const Word16 Q_r[2], + Word16 Q_r[2], Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; @@ -1292,6 +1308,8 @@ ivas_error ivas_compute_core_buffers_fx( move32(); } } -#endif return IVAS_ERR_OK; +#else + return; +#endif } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index f0ba8fc26..40e443317 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -918,16 +918,23 @@ ivas_error ivas_cpe_enc_fx( { front_vad_flag = 0; } + move16(); + +#ifndef FIX_2344_ALIGN_PREPROC + error = +#endif + pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], + &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], + realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], + fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); - error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], - &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], - realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], - fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } +#endif e_old_wsp[n] = sub( Q15, q_old_wsp ); move16(); } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index be2e223f3..2cfed0ac5 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -244,19 +244,26 @@ ivas_error ivas_ism_enc_fx( Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } #endif + set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP ); q_old_wsp = Q15; move16(); Word16 q_fr_bands[2]; - error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], - &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], - realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); +#ifndef FIX_2344_ALIGN_PREPROC + error = +#endif + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], + &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], + realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); +#ifndef FIX_2344_ALIGN_PREPROC IF( error != IVAS_ERR_OK ) { return error; } +#endif + e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); move16(); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 144e86643..48dfc9ba7 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -251,6 +251,30 @@ ivas_error ivas_sce_enc_fx( move16(); Word16 q_fr_bands[2]; +#ifdef FIX_2344_ALIGN_PREPROC + Word16 front_vad_flag, force_front_vad, front_vad_dtx_flag; + IF( st_ivas->hSpar != NULL ) + { + front_vad_flag = st_ivas->hSpar->front_vad_flag; + force_front_vad = st_ivas->hSpar->force_front_vad; + front_vad_dtx_flag = st_ivas->hSpar->front_vad_dtx_flag; + } + ELSE + { + front_vad_flag = 0; + force_front_vad = 0; + front_vad_dtx_flag = 0; + } + move16(); + move16(); + move16(); + + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], + &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], + realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], + fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, + front_vad_flag, force_front_vad, front_vad_dtx_flag, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); +#else error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], @@ -260,6 +284,7 @@ ivas_error ivas_sce_enc_fx( { return error; } +#endif e_old_wsp[0] = sub( Q15, q_old_wsp ); move16(); -- GitLab From 7030b1086c7d2bc47899688561647208f8dd918f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 11:49:25 +0100 Subject: [PATCH 3/7] fix build --- lib_enc/ivas_core_pre_proc_front_fx.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index e621a4bdc..5cce1c590 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -161,7 +161,9 @@ ivas_error pre_proc_front_ivas_fx( STEREO_CLASSIF_HANDLE hStereoClassif; Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; +#ifndef FIX_2344_ALIGN_PREPROC ivas_error error; +#endif Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ @@ -171,7 +173,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ #else Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ + Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ #endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; @@ -229,21 +231,30 @@ ivas_error pre_proc_front_ivas_fx( Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); +#ifdef FIX_2344_ALIGN_PREPROC + Word16 headroom, preemp_len, inp_max; +#else Word16 headroom = 0, preemp_len = 0, inp_max = 0; move16(); move16(); move16(); +#endif Word16 *preemp_start_idx = NULL; +#ifdef FIX_2344_ALIGN_PREPROC + Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; +#else Word32 sig_out[960], max_32; +#endif push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ +#ifndef FIX_2344_ALIGN_PREPROC error = IVAS_ERR_OK; move32(); - +#endif cldfbScale.lb_scale = Q31; cldfbScale.hb_scale = Q31; move16(); @@ -548,12 +559,17 @@ ivas_error pre_proc_front_ivas_fx( * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ +#ifndef FIX_2344_ALIGN_PREPROC *Q_new = 0; move16(); set32_fx( sig_out, 0, 960 ); - +#endif headroom = 2; move16(); +#ifdef FIX_2344_ALIGN_PREPROC + preemp_len = 0; + move16(); +#endif st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); @@ -640,6 +656,7 @@ ivas_error pre_proc_front_ivas_fx( preemp_len = L_FRAME + L_FILT; move16(); } + st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */ move16(); st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ @@ -1333,12 +1350,11 @@ ivas_error pre_proc_front_ivas_fx( * 1st stage speech/music classification (GMM model) *----------------------------------------------------------------*/ - SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; shift = getScaleFactor32( PS_fx, 128 ); scale_sig32( PS_fx, 128, shift ); Qfact_PS = add( Qfact_PS, shift ); - smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ + smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, st->hSpMusClas->past_PS_Q ); /* Q0 */ #ifdef DEBUGGING if ( st->idchan == 0 ) -- GitLab From ef48de6448e776cd074746d348d411c60cd8dcf1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 12:21:21 +0100 Subject: [PATCH 4/7] fix sanitizer error --- lib_enc/ivas_core_pre_proc_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index adfabb741..76bf25027 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1013,7 +1013,10 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } -#ifndef FIX_2344_ALIGN_PREPROC +#ifdef FIX_2344_ALIGN_PREPROC + *Q_new = 0; + move16(); +#else test(); test(); @@ -1028,6 +1031,7 @@ ivas_error ivas_compute_core_buffers_fx( } #endif + test(); #ifdef FIX_2344_ALIGN_PREPROC IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -- GitLab From 2708b6c50f4fe5427080441a2764ec4d66901ff3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 13:27:40 +0100 Subject: [PATCH 5/7] fix within FIX_2344_ALIGN_PREPROC --- lib_enc/ivas_core_enc_fx.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 30d8f315e..c640d8a2e 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -232,11 +232,11 @@ ivas_error ivas_core_enc_fx( } #ifdef FIX_2344_ALIGN_PREPROC - Word32 last_element_brate_tmp = last_element_brate; + Word32 last_element_brate_tmp = element_brate; move32(); IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - last_element_brate_tmp = element_brate; + last_element_brate_tmp = last_element_brate; move32(); } @@ -760,16 +760,21 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); - shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); - Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch - Q_shb_spch = add( Q_shb_spch, shift ); - - IF( st->hBWE_FD ) +#ifdef FIX_2344_ALIGN_PREPROC + IF( st->tcxonly == 0 ) +#endif { - shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); - st->Q_old_wtda = add( st->Q_old_wtda, shift ); - move16(); - Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch + Q_shb_spch = add( Q_shb_spch, shift ); + + IF( st->hBWE_FD ) + { + shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k ); + st->Q_old_wtda = add( st->Q_old_wtda, shift ); + move16(); + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda + } } /* SWB TBE encoder */ -- GitLab From c93eec3464ebb91f8616749c0ba28a8038f345cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 14:27:22 +0100 Subject: [PATCH 6/7] fix within FIX_2344_ALIGN_PREPROC --- lib_enc/ivas_core_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index c640d8a2e..dc3502265 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -761,7 +761,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC - IF( st->tcxonly == 0 ) + IF( st->tcxonly == 0 || hStereoICBWE != NULL ) #endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); -- GitLab From 308dc44c392347db3b4f1c6331ee1cf361ff3296 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 20:36:23 +0100 Subject: [PATCH 7/7] temp. fix to keep BE until #1504 (FLP) is solved --- lib_enc/ivas_core_enc_fx.c | 3 ++- lib_enc/ivas_core_pre_proc_fx.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index dc3502265..57191757d 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -761,7 +761,8 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); #ifdef FIX_2344_ALIGN_PREPROC - IF( st->tcxonly == 0 || hStereoICBWE != NULL ) + IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: + // IF( st->tcxonly == 0 ) #endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 76bf25027..92e7dab6e 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1134,6 +1134,7 @@ ivas_error ivas_compute_core_buffers_fx( shift = sub( norm_s( inp_max ), 1 /* headroom */ ); #else Word16 shift = sub( norm_s( inp_max ), headroom ); + Word16 Q_min, i; #endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); -- GitLab