From 33b110c9d2c52083ec561276e615c1c34862667f Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Wed, 18 Mar 2026 16:03:41 +0100 Subject: [PATCH 1/7] issue: 2479 changes required to harmonize function pair tcx_ltp_pitch_search_fx() --- lib_com/options.h | 1 + lib_enc/tcx_ltp_enc_fx.c | 104 ++++++++++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 40df8a614..1039107e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,6 +99,7 @@ #define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ #define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ +#define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 9f481bbd1..e01dacb9c 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -73,7 +73,7 @@ static Word32 interpolate_corr( return s; } - +#ifndef FIX_2479_HARM_PITCH_GAIN static void tcx_ltp_pitch_search( Word16 pitch_ol, Word16 *pitch_int, @@ -278,6 +278,9 @@ static void tcx_ltp_pitch_search( } } + +#endif // !FIX_2479_HARM_PITCH_GAIN +#ifndef FIX_2479_HARM_PITCH_GAIN static void tcx_ltp_pitch_search_ivas_fx( const Word16 pitch_ol, Word16 *pitch_int, @@ -293,6 +296,24 @@ static void tcx_ltp_pitch_search_ivas_fx( const Word16 pitres, const Word16 check_border_case, Word16 *border_case ) +#else +static void tcx_ltp_pitch_search_fx( + const Word16 pitch_ol, + Word16* pitch_int, + Word16* pitch_fr, + Word16* index, + Word16* norm_corr, + const Word16 len, + const Word16* wsp, // Qx + const Word16 pitmin, + const Word16 pitfr1, + const Word16 pitfr2, + const Word16 pitmax, + const Word16 pitres, + const Word16 check_border_case, + Word16* border_case, + Word16 element_mode) +#endif // !FIX_2479_HARM_PITCH_GAIN { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; Word16 cor_idx_ini, cor_idx; @@ -328,6 +349,12 @@ static void tcx_ltp_pitch_search_ivas_fx( t_max = add( t0_max, L_INTERPOL1 ); /* normalize wsp */ +#ifdef FIX_2479_HARM_PITCH_GAIN + IF(EQ_16(element_mode, EVS_MONO)) { + assert(len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1); + } +#endif // FIX_2479_HARM_PITCH_GAIN + s_wsp = getScaleFactor16( wsp - t_max, add( len, t_max ) ); s_wsp = sub( s_wsp, 4 ); FOR( t = negate( t_max ); t < len; t++ ) @@ -336,9 +363,14 @@ static void tcx_ltp_pitch_search_ivas_fx( move16(); } wsp = wsp2 + t_max; +#ifdef FIX_2479_HARM_PITCH_GAIN + move16(); +#endif // FIX_2479_HARM_PITCH_GAIN pt_cor = cor; - +#ifdef FIX_2479_HARM_PITCH_GAIN + move32(); +#endif // FIX_2479_HARM_PITCH_GAIN FOR( t = t_min; t <= t_max; t++ ) { *pt_cor = dot( wsp, wsp - t, len ); // 2*(x + s_wsp) @@ -350,6 +382,10 @@ static void tcx_ltp_pitch_search_ivas_fx( cor_max = L_add( *pt_cor++, 0 ); t1 = t0_min; move16(); +#ifdef FIX_2479_HARM_PITCH_GAIN + move32(); +#endif // FIX_2479_HARM_PITCH_GAIN + FOR( t = t0_min + 1; t <= t0_max; t++ ) { @@ -385,15 +421,15 @@ static void tcx_ltp_pitch_search_ivas_fx( temp_e = sub( negate( s ), temp_e ); *norm_corr = shl_sat( temp_m, temp_e ); - +#ifndef FIX_2479_HARM_PITCH_GAIN test(); - IF( check_border_case && EQ_16( t1, t0_min ) ) + IF(check_border_case&& EQ_16(t1, t0_min)) { Word32 tmpCor; - FOR( t = t1 - L_INTERPOL1; t < t1; t++ ) + FOR(t = t1 - L_INTERPOL1; t < t1; t++) { - tmpCor = dot( wsp, wsp - t, len ); - IF( GT_32( tmpCor, cor_max ) ) + tmpCor = dot(wsp, wsp - t, len); + IF(GT_32(tmpCor, cor_max)) { *border_case = 1; move16(); @@ -401,6 +437,26 @@ static void tcx_ltp_pitch_search_ivas_fx( } } } +#else + IF(NE_16(element_mode, EVS_MONO)) { + test(); + IF(check_border_case && EQ_16(t1, t0_min)) + { + Word32 tmpCor; + FOR(t = t1 - L_INTERPOL1; t < t1; t++) + { + tmpCor = dot(wsp, wsp - t, len); + IF(GT_32(tmpCor, cor_max)) + { + *border_case = 1; + move16(); + BREAK; + } + } + } + } +#endif // !FIX_2479_HARM_PITCH_GAIN + IF( GE_16( t1, pitfr1 ) ) { @@ -630,7 +686,11 @@ void tcx_ltp_encode_fx( Word16 buf_zir[M + L_SUBFR], *zir; Word16 Aest[M + 1]; Word16 alpha, step; - +#ifdef FIX_2479_HARM_PITCH_GAIN + Word16 leg_flag; + leg_flag = 1; + Word16 border_case; +#endif // FIX_2479_HARM_PITCH_GAIN norm_corr = 0; move16(); @@ -662,8 +722,13 @@ void tcx_ltp_encode_fx( } /* Find pitch lag */ - tcx_ltp_pitch_search( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres ); +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_pitch_search(Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres); +#else + tcx_ltp_pitch_search_fx(Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, leg_flag); +#endif // !FIX_2479_HARM_PITCH_GAIN + nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) ); nPrevSubblocks = add( s_min( nPrevSubblocks, NSUBBLOCKS ), 1 ); @@ -957,7 +1022,11 @@ void tcx_ltp_encode_ivas_fx( IF( LT_16( abs_s( sub( Top[0], Top[1] ) ), shr( delta, 1 ) ) ) { /* estimates are close enough and stable, take the artihmetic mean as estimate */ - tcx_ltp_pitch_search_ivas_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_pitch_search_ivas_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case); +#else + tcx_ltp_pitch_search_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode); +#endif // !FIX_2479_HARM_PITCH_GAIN } ELSE { @@ -969,8 +1038,13 @@ void tcx_ltp_encode_ivas_fx( FOR( i = 0; i < 2; i++ ) { - tcx_ltp_pitch_search_ivas_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); - } +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_pitch_search_ivas_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case); +#else + tcx_ltp_pitch_search_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode); +#endif // !FIX_2479_HARM_PITCH_GAIN + + } IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) ) { @@ -1004,7 +1078,11 @@ void tcx_ltp_encode_ivas_fx( tmp = 0; } move16(); - tcx_ltp_pitch_search_ivas_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case ); +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_pitch_search_ivas_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case); +#else + tcx_ltp_pitch_search_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case, element_mode); +#endif // !FIX_2479_HARM_PITCH_GAIN } if ( border_case ) -- GitLab From c56d2eba523c9d63b07c1547d020099878afad85 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Wed, 18 Mar 2026 16:10:05 +0100 Subject: [PATCH 2/7] issue: 2479 Clang formatting patch --- lib_enc/tcx_ltp_enc_fx.c | 59 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index e01dacb9c..3372d384d 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -299,20 +299,20 @@ static void tcx_ltp_pitch_search_ivas_fx( #else static void tcx_ltp_pitch_search_fx( const Word16 pitch_ol, - Word16* pitch_int, - Word16* pitch_fr, - Word16* index, - Word16* norm_corr, + Word16 *pitch_int, + Word16 *pitch_fr, + Word16 *index, + Word16 *norm_corr, const Word16 len, - const Word16* wsp, // Qx + const Word16 *wsp, // Qx const Word16 pitmin, const Word16 pitfr1, const Word16 pitfr2, const Word16 pitmax, const Word16 pitres, const Word16 check_border_case, - Word16* border_case, - Word16 element_mode) + Word16 *border_case, + Word16 element_mode ) #endif // !FIX_2479_HARM_PITCH_GAIN { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; @@ -350,8 +350,9 @@ static void tcx_ltp_pitch_search_fx( /* normalize wsp */ #ifdef FIX_2479_HARM_PITCH_GAIN - IF(EQ_16(element_mode, EVS_MONO)) { - assert(len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1); + IF( EQ_16( element_mode, EVS_MONO ) ) + { + assert( len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1 ); } #endif // FIX_2479_HARM_PITCH_GAIN @@ -423,13 +424,13 @@ static void tcx_ltp_pitch_search_fx( *norm_corr = shl_sat( temp_m, temp_e ); #ifndef FIX_2479_HARM_PITCH_GAIN test(); - IF(check_border_case&& EQ_16(t1, t0_min)) + IF( check_border_case && EQ_16( t1, t0_min ) ) { Word32 tmpCor; - FOR(t = t1 - L_INTERPOL1; t < t1; t++) + FOR( t = t1 - L_INTERPOL1; t < t1; t++ ) { - tmpCor = dot(wsp, wsp - t, len); - IF(GT_32(tmpCor, cor_max)) + tmpCor = dot( wsp, wsp - t, len ); + IF( GT_32( tmpCor, cor_max ) ) { *border_case = 1; move16(); @@ -438,15 +439,16 @@ static void tcx_ltp_pitch_search_fx( } } #else - IF(NE_16(element_mode, EVS_MONO)) { + IF( NE_16( element_mode, EVS_MONO ) ) + { test(); - IF(check_border_case && EQ_16(t1, t0_min)) + IF( check_border_case && EQ_16( t1, t0_min ) ) { Word32 tmpCor; - FOR(t = t1 - L_INTERPOL1; t < t1; t++) + FOR( t = t1 - L_INTERPOL1; t < t1; t++ ) { - tmpCor = dot(wsp, wsp - t, len); - IF(GT_32(tmpCor, cor_max)) + tmpCor = dot( wsp, wsp - t, len ); + IF( GT_32( tmpCor, cor_max ) ) { *border_case = 1; move16(); @@ -723,12 +725,12 @@ void tcx_ltp_encode_fx( /* Find pitch lag */ #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search(Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres); + tcx_ltp_pitch_search( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres ); #else - tcx_ltp_pitch_search_fx(Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, leg_flag); + tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, leg_flag ); #endif // !FIX_2479_HARM_PITCH_GAIN - + nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) ); nPrevSubblocks = add( s_min( nPrevSubblocks, NSUBBLOCKS ), 1 ); @@ -1023,9 +1025,9 @@ void tcx_ltp_encode_ivas_fx( { /* estimates are close enough and stable, take the artihmetic mean as estimate */ #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case); + tcx_ltp_pitch_search_ivas_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #else - tcx_ltp_pitch_search_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode); + tcx_ltp_pitch_search_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode ); #endif // !FIX_2479_HARM_PITCH_GAIN } ELSE @@ -1039,12 +1041,11 @@ void tcx_ltp_encode_ivas_fx( FOR( i = 0; i < 2; i++ ) { #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case); + tcx_ltp_pitch_search_ivas_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #else - tcx_ltp_pitch_search_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode); + tcx_ltp_pitch_search_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode ); #endif // !FIX_2479_HARM_PITCH_GAIN - - } + } IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) ) { @@ -1079,9 +1080,9 @@ void tcx_ltp_encode_ivas_fx( } move16(); #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case); + tcx_ltp_pitch_search_ivas_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case ); #else - tcx_ltp_pitch_search_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case, element_mode); + tcx_ltp_pitch_search_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case, element_mode ); #endif // !FIX_2479_HARM_PITCH_GAIN } -- GitLab From c2428c99873af4d7b6370bf53988b55b8d59f14b Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Thu, 19 Mar 2026 10:00:19 +0100 Subject: [PATCH 3/7] issue: 2479 Harmonizing function tcx_ltp_find_gain_fx(), removing one definition. Changing instances accordingly --- lib_enc/tcx_ltp_enc_fx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 3372d384d..4ac33fdcd 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -553,7 +553,7 @@ static void tcx_ltp_pitch_search_fx( } } - +#ifndef FIX_2479_HARM_PITCH_GAIN static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_frame, Word16 *gain, Word16 *gain_index ) { Word32 corr, ener; @@ -600,8 +600,12 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra *gain = imult1616( add( g, 1 ), 0x1400 ); move16(); } - -static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speech /*Qx*/, Word16 L_frame, Word16 *gain, Word16 *gain_index ) +#endif // !FIX_2479_HARM_PITCH_GAIN +#ifndef FIX_2479_HARM_PITCH_GAIN +static void tcx_ltp_find_gain_ivas_fx(Word16* speech /*Qx*/, Word16* pred_speech /*Qx*/, Word16 L_frame, Word16* gain, Word16* gain_index) +#else +static void tcx_ltp_find_gain_fx(Word16* speech /*Qx*/, Word16* pred_speech /*Qx*/, Word16 L_frame, Word16* gain, Word16* gain_index) +#endif // !FIX_2479_HARM_PITCH_GAIN { Word32 corr, ener; Word16 i, g, s1, s2, tmp; @@ -789,8 +793,11 @@ void tcx_ltp_encode_fx( predict_signal( speech, pred_speech, *pitch_int, *pitch_fr, pitres, L_frame ); /* Find gain */ - tcx_ltp_find_gain( speech, pred_speech, L_frame, gain, <p_param[2] ); - +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_find_gain(speech, pred_speech, L_frame, gain, <p_param[2]); +#else + tcx_ltp_find_gain_fx(speech, pred_speech, L_frame, gain, <p_param[2]); +#endif // !FIX_2479_HARM_PITCH_GAIN /* Total number of bits for LTP */ IF( NE_16( ltp_param[2], -1 ) ) /* gain > 0 */ { @@ -1207,8 +1214,11 @@ void tcx_ltp_encode_ivas_fx( predict_signal( speech_fx, pred_speech_fx, hTcxEnc->tcxltp_pitch_int, hTcxEnc->tcxltp_pitch_fr, st->pit_res_max, L_frame ); /* Find gain */ - tcx_ltp_find_gain_ivas_fx( speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); - +#ifndef FIX_2479_HARM_PITCH_GAIN + tcx_ltp_find_gain_ivas_fx(speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2]); +#else + tcx_ltp_find_gain_fx(speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2]); +#endif // !FIX_2479_HARM_PITCH_GAIN IF( ltp_param[0] ) { /* Total number of bits for LTP */ -- GitLab From f5ddb406f2aac8ff31f101c7984875b0699be6b4 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Thu, 19 Mar 2026 10:29:20 +0100 Subject: [PATCH 4/7] issue: 2481 Clang formatting patch --- lib_enc/tcx_ltp_enc_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 4ac33fdcd..31c0b8cb8 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -602,9 +602,9 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra } #endif // !FIX_2479_HARM_PITCH_GAIN #ifndef FIX_2479_HARM_PITCH_GAIN -static void tcx_ltp_find_gain_ivas_fx(Word16* speech /*Qx*/, Word16* pred_speech /*Qx*/, Word16 L_frame, Word16* gain, Word16* gain_index) +static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speech /*Qx*/, Word16 L_frame, Word16 *gain, Word16 *gain_index ) #else -static void tcx_ltp_find_gain_fx(Word16* speech /*Qx*/, Word16* pred_speech /*Qx*/, Word16 L_frame, Word16* gain, Word16* gain_index) +static void tcx_ltp_find_gain_fx( Word16 *speech /*Qx*/, Word16 *pred_speech /*Qx*/, Word16 L_frame, Word16 *gain, Word16 *gain_index ) #endif // !FIX_2479_HARM_PITCH_GAIN { Word32 corr, ener; @@ -794,9 +794,9 @@ void tcx_ltp_encode_fx( /* Find gain */ #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_find_gain(speech, pred_speech, L_frame, gain, <p_param[2]); + tcx_ltp_find_gain( speech, pred_speech, L_frame, gain, <p_param[2] ); #else - tcx_ltp_find_gain_fx(speech, pred_speech, L_frame, gain, <p_param[2]); + tcx_ltp_find_gain_fx( speech, pred_speech, L_frame, gain, <p_param[2] ); #endif // !FIX_2479_HARM_PITCH_GAIN /* Total number of bits for LTP */ IF( NE_16( ltp_param[2], -1 ) ) /* gain > 0 */ @@ -1215,9 +1215,9 @@ void tcx_ltp_encode_ivas_fx( /* Find gain */ #ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_find_gain_ivas_fx(speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2]); + tcx_ltp_find_gain_ivas_fx( speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); #else - tcx_ltp_find_gain_fx(speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2]); + tcx_ltp_find_gain_fx( speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); #endif // !FIX_2479_HARM_PITCH_GAIN IF( ltp_param[0] ) { -- GitLab From 1ad714649216121284b10e6245a34ae349485f85 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 23 Mar 2026 15:57:04 +0100 Subject: [PATCH 5/7] issue 2479: fixing removed switch - replacing leg_flag with EVS_MONO and removing leg_flag's definition and initiation --- lib_com/options.h | 1 + lib_enc/tcx_ltp_enc_fx.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 42f391301..2efd0f8a9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ #define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ +#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ #define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index fdae43e98..e538994b6 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -693,8 +693,6 @@ void tcx_ltp_encode_fx( Word16 Aest[M + 1]; Word16 alpha, step; #ifdef FIX_2479_HARM_PITCH_GAIN - Word16 leg_flag; - leg_flag = 1; Word16 border_case; #endif // FIX_2479_HARM_PITCH_GAIN norm_corr = 0; @@ -731,7 +729,7 @@ void tcx_ltp_encode_fx( #ifndef FIX_2479_HARM_PITCH_GAIN tcx_ltp_pitch_search( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres ); #else - tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, leg_flag ); + tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, EVS_MONO ); #endif // !FIX_2479_HARM_PITCH_GAIN -- GitLab From f655f656b70743a31c407f3e3883aa5698f24eda Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 23 Mar 2026 17:01:44 +0100 Subject: [PATCH 6/7] remove merge artifacts in options.h --- lib_com/options.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9a25e6388..16dbbe70d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,11 +89,6 @@ #define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2463_EVS_BWE_LSF /* VA: basop issue 2463: harmonize calling of Quant_BWE_LSF_fx() */ - -#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ -#define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ -#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ -#define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ /* #################### End BE switches ################################## */ -- GitLab From f83c0acea11d7b1373d04451360afe4f3d6c6ba1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 23 Mar 2026 17:28:42 +0100 Subject: [PATCH 7/7] cleanup --- lib_enc/tcx_ltp_enc_fx.c | 63 +++++++++++++--------------------------- 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index e538994b6..0a1b0039a 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -311,8 +311,7 @@ static void tcx_ltp_pitch_search_fx( const Word16 pitmax, const Word16 pitres, const Word16 check_border_case, - Word16 *border_case, - Word16 element_mode ) + Word16 *border_case ) #endif // !FIX_2479_HARM_PITCH_GAIN { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; @@ -350,10 +349,7 @@ static void tcx_ltp_pitch_search_fx( /* normalize wsp */ #ifdef FIX_2479_HARM_PITCH_GAIN - IF( EQ_16( element_mode, EVS_MONO ) ) - { - assert( len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1 ); - } + assert( len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1 ); #endif // FIX_2479_HARM_PITCH_GAIN s_wsp = getScaleFactor16( wsp - t_max, add( len, t_max ) ); @@ -363,15 +359,9 @@ static void tcx_ltp_pitch_search_fx( wsp2[t + t_max] = shl( wsp[t], s_wsp ); // Q(x + s_wsp) move16(); } - wsp = wsp2 + t_max; -#ifdef FIX_2479_HARM_PITCH_GAIN - move16(); -#endif // FIX_2479_HARM_PITCH_GAIN + wsp = wsp2 + t_max; pt_cor = cor; -#ifdef FIX_2479_HARM_PITCH_GAIN - move32(); -#endif // FIX_2479_HARM_PITCH_GAIN FOR( t = t_min; t <= t_max; t++ ) { *pt_cor = dot( wsp, wsp - t, len ); // 2*(x + s_wsp) @@ -383,10 +373,6 @@ static void tcx_ltp_pitch_search_fx( cor_max = L_add( *pt_cor++, 0 ); t1 = t0_min; move16(); -#ifdef FIX_2479_HARM_PITCH_GAIN - move32(); -#endif // FIX_2479_HARM_PITCH_GAIN - FOR( t = t0_min + 1; t <= t0_max; t++ ) { @@ -422,7 +408,7 @@ static void tcx_ltp_pitch_search_fx( temp_e = sub( negate( s ), temp_e ); *norm_corr = shl_sat( temp_m, temp_e ); -#ifndef FIX_2479_HARM_PITCH_GAIN + test(); IF( check_border_case && EQ_16( t1, t0_min ) ) { @@ -438,27 +424,6 @@ static void tcx_ltp_pitch_search_fx( } } } -#else - IF( NE_16( element_mode, EVS_MONO ) ) - { - test(); - IF( check_border_case && EQ_16( t1, t0_min ) ) - { - Word32 tmpCor; - FOR( t = t1 - L_INTERPOL1; t < t1; t++ ) - { - tmpCor = dot( wsp, wsp - t, len ); - IF( GT_32( tmpCor, cor_max ) ) - { - *border_case = 1; - move16(); - BREAK; - } - } - } - } -#endif // !FIX_2479_HARM_PITCH_GAIN - IF( GE_16( t1, pitfr1 ) ) { @@ -729,7 +694,7 @@ void tcx_ltp_encode_fx( #ifndef FIX_2479_HARM_PITCH_GAIN tcx_ltp_pitch_search( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres ); #else - tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, EVS_MONO ); + tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 0, &border_case ); #endif // !FIX_2479_HARM_PITCH_GAIN @@ -1032,7 +997,7 @@ void tcx_ltp_encode_ivas_fx( #ifndef FIX_2479_HARM_PITCH_GAIN tcx_ltp_pitch_search_ivas_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #else - tcx_ltp_pitch_search_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode ); + tcx_ltp_pitch_search_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #endif // !FIX_2479_HARM_PITCH_GAIN } ELSE @@ -1048,7 +1013,7 @@ void tcx_ltp_encode_ivas_fx( #ifndef FIX_2479_HARM_PITCH_GAIN tcx_ltp_pitch_search_ivas_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #else - tcx_ltp_pitch_search_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode ); + tcx_ltp_pitch_search_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); #endif // !FIX_2479_HARM_PITCH_GAIN } @@ -1074,6 +1039,17 @@ void tcx_ltp_encode_ivas_fx( } ELSE { +#ifdef FIX_2479_HARM_PITCH_GAIN + Word16 check_border_case; + IF( GT_16( element_mode, EVS_MONO ) ) + { + check_border_case = 1; + } + ELSE + { + check_border_case = 0; + } +#else Word16 tmp; IF( GT_16( element_mode, EVS_MONO ) ) { @@ -1083,11 +1059,12 @@ void tcx_ltp_encode_ivas_fx( { tmp = 0; } +#endif move16(); #ifndef FIX_2479_HARM_PITCH_GAIN tcx_ltp_pitch_search_ivas_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case ); #else - tcx_ltp_pitch_search_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case, element_mode ); + tcx_ltp_pitch_search_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, check_border_case, &border_case ); #endif // !FIX_2479_HARM_PITCH_GAIN } -- GitLab