From bb8bbf0339f6caab9bf3d9c91806f66a0ca9ea33 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 14:41:41 +0100 Subject: [PATCH 1/6] HARM_COREDECODER_FUNCTIONS --- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 ++-- lib_dec/dec_post_fx.c | 20 +++++++----- lib_dec/dec_prm_fx.c | 4 +++ lib_dec/dec_tran_fx.c | 4 +++ lib_dec/dlpc_avq_fx.c | 5 +++ lib_dec/gain_dec_fx.c | 73 ++++++++++++++++++++++++++++++++----------- 7 files changed, 86 insertions(+), 27 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a112a55d0..82096b939 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #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 HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1a194d468..9209746d5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6763,6 +6763,7 @@ void gain_dec_tc_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void gain_dec_tc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ @@ -6773,7 +6774,7 @@ void gain_dec_tc_ivas_fx( Word16 *gain_inov_fx, /* o : unscaled innovation gain */ Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); - +#endif void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ @@ -8780,6 +8781,7 @@ Word16 decode_lpc_avq_fx( Word16 *param_lpc /* o : lpc parameters */ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 decode_lpc_avq_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ @@ -8788,7 +8790,7 @@ Word16 decode_lpc_avq_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ ); - +#endif void vlpc_1st_dec( Word16 index, /* i : codebook index */ Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index bb24978b2..14a7b958f 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -34,8 +34,9 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); - +#ifndef HARM_COREDECODER_FUNCTIONS static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); +#endif /*-------------------------------------------------------------------------- @@ -445,7 +446,11 @@ static void Dec_formant_postfilt_fx( } /* Controls short term pst filter gain and compute parcor0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); +#else calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 ); +#endif /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) ); @@ -1290,22 +1295,20 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain * controls gain : computation of energy impulse response as * SUMn (abs (h[n])) and computes parcor0 *---------------------------------------------------------------------------- */ + static void calc_st_filt_local_fx( Word16 *apond2, /* i : coefficients of numerator Q12 */ - Word16 *apond1, /* i : coefficients of denominator Q12 */ + Word16 *apond1, /* i : coefficients of denominator Q12 */ Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15*/ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */ - Word16 *mem_zero /* i : All zero memory */ + Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */ + Word16 *mem_zero /* i : All zero memory */ ) { Word32 L_g0; - Word16 h[LONG_H_ST]; - Word16 g0, temp; Word16 i; - temp = sub( 2, norm_s( apond2[0] ) ); /* compute i.r. of composed filter apond2 / apond1 */ @@ -1337,6 +1340,7 @@ static void calc_st_filt_local_fx( return; } +#ifndef HARM_COREDECODER_FUNCTIONS static void calc_st_filt_ivas_fx( Word16 *apond2, /* i : coefficients of numerator Q12 */ Word16 *apond1, /* i : coefficients of denominator Q12 */ @@ -1391,6 +1395,8 @@ static void calc_st_filt_ivas_fx( return; } +#endif + /*---------------------------------------------------------------------------- * filt_mu * diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 6b6748b80..1fe960d7d 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -52,7 +52,11 @@ void getLPCparam_fx( { IF( st->lpcQuantization == 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + decode_lpc_avq_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); +#else decode_lpc_avq_ivas_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); +#endif } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) { diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 110c6e97f..93a9cf8ca 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -145,6 +145,9 @@ void decod_tran_fx( IF( Jopt_flag == 0 ) { /* 2/3-bit decoding */ +#ifdef HARM_COREDECODER_FUNCTIONS + gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); +#else IF( st_fx->element_mode == EVS_MONO ) { gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); @@ -153,6 +156,7 @@ void decod_tran_fx( { gain_dec_tc_ivas_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } +#endif } ELSE { diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c index 97b41d98b..2b1264218 100644 --- a/lib_dec/dlpc_avq_fx.c +++ b/lib_dec/dlpc_avq_fx.c @@ -146,6 +146,7 @@ static Word16 pack4bits_fx( } Word16 decode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc /* o : lpc parameters */ @@ -285,6 +286,7 @@ Word16 decode_lpc_avq_fx( } Word16 decode_lpc_avq_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -324,6 +326,7 @@ Word16 decode_lpc_avq_ivas_fx( param_lpc[j] = q_type; j = add( j, 1 ); } + test(); IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 ) { @@ -338,6 +341,7 @@ Word16 decode_lpc_avq_ivas_fx( j = add( j, 1 ); move16(); } + /* Decode quantization indices */ IF( q_type == 0 ) @@ -362,6 +366,7 @@ Word16 decode_lpc_avq_ivas_fx( } j = add( j, 1 ); } + /* * 2nd stage decoding is skipped if: * - we are in low bitrate mode and no joint SNS coding is used diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index cd19197cd..3ac75b9c7 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -90,7 +90,8 @@ void Es_pred_dec_fx( /*======================================================================================*/ void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifndef HARM_COREDECODER_FUNCTIONS + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ @@ -222,6 +223,7 @@ void gain_dec_tc_fx( /*======================================================================================*/ void gain_dec_tc_ivas_fx( +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -245,8 +247,10 @@ void gain_dec_tc_ivas_fx( /*----------------------------------------------------------------* * find number of bits for gain dequantization *----------------------------------------------------------------*/ - nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )]; + + nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / L_SUBFR )]; move16(); + /*-----------------------------------------------------------------* * calculate the predicted gain code *-----------------------------------------------------------------*/ @@ -264,7 +268,6 @@ void gain_dec_tc_ivas_fx( *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); move16(); /* gain_inov in Q12 */ - /* Ei = 10 * (float)log10( Ecode );*/ e_tmp = norm_l( L_tmp1 ); f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ @@ -279,6 +282,7 @@ void gain_dec_tc_ivas_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -286,23 +290,40 @@ void gain_dec_tc_ivas_fx( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); + /*------------------------------------------------------------------------------------------* * Select the gain quantization table and dequantize the gain *------------------------------------------------------------------------------------------*/ - /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/ index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ - - IF( GT_16( nBits, 3 ) ) +#ifdef HARM_COREDECODER_FUNCTIONS + IF( st_fx->element_mode == EVS_MONO ) { - wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); - wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/ + IF( GT_16( nBits, 3 ) ) + { + wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); + wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ + } + ELSE /* nBits == 3 */ + { + wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/ + move16(); + } } - ELSE /* nBits == 3 */ + ELSE +#endif { - wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12 - move16(); + IF( GT_16( nBits, 3 ) ) + { + wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); + wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/ + } + ELSE /* nBits == 3 */ + { + wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12 + move16(); + } } /*-----------------------------------------------------------------* @@ -310,8 +331,18 @@ void gain_dec_tc_ivas_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ - L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ - *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ +#ifdef HARM_COREDECODER_FUNCTIONS + IF( st_fx->element_mode == EVS_MONO ) + { + L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ + } + ELSE +#endif + { + L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ + *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ + } move32(); /**norm_gain_code = *gain_code / *gain_inov;*/ @@ -353,8 +384,9 @@ void gain_dec_tc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ + void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ const Word16 coder_type, /* i : coding type */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -431,6 +463,7 @@ void gain_dec_mless_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -528,6 +561,7 @@ void gain_dec_mless_fx( L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ } + /*-----------------------------------------------------------------* * calculate the predicted gain code *-----------------------------------------------------------------*/ @@ -540,6 +574,7 @@ void gain_dec_mless_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ @@ -650,6 +685,7 @@ void gain_dec_lbr_fx( * calculate prediction of gcode * search for the best codeword *-----------------------------------------------------------------*/ + test(); IF( i_subfr == 0 ) { @@ -698,7 +734,6 @@ void gain_dec_lbr_fx( gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */ - /*-----------------------------------------------------------------* * gcode0 = pow(10.0, gcode0/20) * = pow(2, 3.321928*gcode0/20) @@ -775,6 +810,7 @@ void gain_dec_lbr_fx( * gcode0 = pow(10.0, dotp(b, aux, n_pred) * = pow(2, 3.321928*dotp(b, aux, n_pred) *-----------------------------------------------------------------*/ + L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ @@ -848,6 +884,7 @@ void gain_dec_lbr_fx( * gcode0 = pow(10.0, dotp(b, aux, n_pred) * = pow(2, 3.321928*dotp(b, aux, n_pred) *-----------------------------------------------------------------*/ + L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ @@ -879,7 +916,6 @@ void gain_dec_lbr_fx( n_pred = 8; move16(); - cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/ IF( EQ_16( nBits, 7 ) ) @@ -984,7 +1020,6 @@ void gain_dec_lbr_fx( /* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */ /* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */ /*-----------------------------------------------------------------------*/ - /*-----------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -1275,7 +1310,7 @@ void gain_dec_SQ_fx( *---------------------------------------------------------------------*/ void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ @@ -1305,6 +1340,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Select the gain quantization table *-----------------------------------------------------------------*/ + nbits = 7; move16(); t_qua_gain = t_qua_gain7b_fx; @@ -1364,6 +1400,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Decode code gain *-----------------------------------------------------------------*/ + qua_en = t_qua_gain[( index2 + 1 )]; move16(); -- GitLab From 2529d7d463f75d76b720788c012f62649f56d742 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:07:00 +0100 Subject: [PATCH 2/6] HARM_COREDECODER_FUNCTIONS --- lib_com/prot_fx.h | 11 ++-- lib_dec/core_dec_init_fx.c | 4 ++ lib_dec/dec_post_fx.c | 103 ++++++++++++++++++-------------- lib_dec/dec_prm_fx.c | 4 ++ lib_dec/waveadjust_fec_dec_fx.c | 3 +- 5 files changed, 74 insertions(+), 51 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9209746d5..028556b88 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6180,10 +6180,11 @@ void concealment_init_x( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); +#ifdef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); - +#endif void concealment_update_x( const Word16 bfi, const Word16 core, @@ -6563,6 +6564,7 @@ void formant_post_filt_fx( const Word16 off_flag /* i : off flag */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void Filt_mu_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ @@ -6576,7 +6578,7 @@ void Filt_mu_ivas_fx( Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ Word16 L_subfr, /* i : the length of subframe */ const Word16 extl ); - +#endif void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal */ Word16 *sig_out, /* i/o: postfilter o signal */ @@ -8776,13 +8778,14 @@ Word16 dlpc_avq_fx( Word32 sr_core ); Word16 decode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc /* o : lpc parameters */ ); -#ifndef HARM_COREDECODER_FUNCTIONS Word16 decode_lpc_avq_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -8790,7 +8793,7 @@ Word16 decode_lpc_avq_ivas_fx( const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ ); -#endif + void vlpc_1st_dec( Word16 index, /* i : codebook index */ Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 22fed24cb..2ff4ce84f 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1978,7 +1978,11 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo ); +#else concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); +#endif } } ELSE diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 14a7b958f..596b8574c 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -34,7 +34,10 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -#ifndef HARM_COREDECODER_FUNCTIONS + +#ifdef HARM_COREDECODER_FUNCTIONS +static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr ); +#else static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); #endif @@ -73,11 +76,13 @@ void Init_post_filter_fx( return; } + /*-------------------------------------------------------------------------- * NB_post_filt: * * Main routine to perform post filtering on NB synthesis *--------------------------------------------------------------------------*/ + void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ @@ -133,7 +138,6 @@ void nb_post_filt_fx( move16(); } - /* run the post filter */ p_Aq = Aq; // Q12 move16(); @@ -149,10 +153,10 @@ void nb_post_filt_fx( j = add( j, 1 ); } - return; } + /*---------------------------------------------------------------------------- * Dec_postfilt() * @@ -176,15 +180,16 @@ void nb_post_filt_fx( * 1. search around 1st subframe delay (3 integer values) * 2. search around best integer with fract. delays (1/8) *----------------------------------------------------------------------------*/ + static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ const Word16 t0, /* i : pitch delay given by coder Q0 */ const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */ - const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ + const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ Word16 *sig_out, /* o : postfiltered output Q15*/ const Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ const Word16 gamma2, /* i : short term postfilt. num. weighting factor Q15*/ - const Word16 Gain_factor, /* i : Gain Factor (Q15) */ + const Word16 Gain_factor, /* i : Gain Factor (Q15) */ const Word16 disable_hpf ) { /* Local variables and arrays */ @@ -192,14 +197,11 @@ static void Dec_postfilt_fx( Word16 apond2[LONG_H_ST]; // Q12 Word16 sig_ltp[L_SUBFR + 1]; /* H0 output signal */ Word16 res2[SIZ_RES2]; // Q0 - Word16 *sig_ltp_ptr; Word16 *res2_ptr; Word16 *ptr_mem_stp; - Word16 parcor0; // Q15 - /* Init pointers and restore memories */ res2_ptr = res2 + DECMEM_RES2; ptr_mem_stp = hPFstat->mem_stp + L_SYN_MEM - 1; @@ -245,10 +247,10 @@ static void Dec_postfilt_fx( /* Update for next subframe */ Copy( &res2[L_SUBFR], hPFstat->mem_res2, DECMEM_RES2 ); - return; } + /*-------------------------------------------------------------------------- * formant_post_filt_fx: * @@ -468,7 +470,12 @@ static void Dec_formant_postfilt_fx( } /* Tilt filtering */ +#ifdef HARM_COREDECODER_FUNCTIONS + Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR ); +#else Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 ); +#endif + IF( scale_down ) { Scale_sig( sig_out, L_SUBFR, 1 ); @@ -477,10 +484,10 @@ static void Dec_formant_postfilt_fx( /* Gain control */ scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR ); - return; } + /*------------------------------------------------------------------------------------ * modify_pst_param() * @@ -499,7 +506,6 @@ static void modify_pst_param_fx( Word16 lp_noiseQ12; Word32 L_tmp; - test(); IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) ) { @@ -539,20 +545,21 @@ static void modify_pst_param_fx( *gain_factor = extract_h( L_shl( L_tmp, 7 ) ); /* Q24=>Q31=>Q15 */ - return; } + /*---------------------------------------------------------------------------- * pst_ltp_fx * * Perform harmonic postfilter *----------------------------------------------------------------------------*/ + static void pst_ltp_fx( Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */ - Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ - Word16 gain_factor /* i : Gain Factor (Q15) */ + Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ + Word16 gain_factor /* i : Gain Factor (Q15) */ ) { Word32 L_temp; @@ -575,7 +582,6 @@ static void pst_ltp_fx( Word16 off_yup; Word16 nb_sh_sig; - /* i signal justified on 13 bits */ ptr_sig = ptr_sig_in - DECMEM_RES2; // Qx nb_sh_sig = getScaleFactor16( ptr_sig, DECMEM_RES2 + L_SUBFR ); @@ -592,7 +598,6 @@ static void pst_ltp_fx( /* Sub optimal delay search */ search_del_fx( t0, ptr_sig_cadr, <pdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup ); - IF( num_gltp == 0 ) { Copy( ptr_sig_in, ptr_sig_pst0, L_SUBFR ); @@ -608,7 +613,6 @@ static void pst_ltp_fx( /* Filtering with long filter */ compute_ltp_l_fx( ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2 ); - IF( EQ_16( select_ltp_fx( num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2 ), 1 ) ) { /* select short filter */ @@ -677,15 +681,19 @@ static void pst_ltp_fx( /** filtering by H0(z) = harmonic filter **/ filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt ); } + + return; } + /*---------------------------------------------------------------------------- * search_del_fx: * * Computes best (shortest) integer LTP delay + fine search *---------------------------------------------------------------------------*/ + static void search_del_fx( - Word16 t0, /* i : pitch delay given by coder Q0 */ + Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : i signal (with delay line) */ Word16 *ltpdel, /* o : delay = *ltpdel - *phase / f_up */ Word16 *phase, /* o : phase */ @@ -720,7 +728,6 @@ static void search_del_fx( Word16 i_max, lambda, phi, phi_max, ioff; Word16 temp; - /*------------------------------------- * Computes energy of current signal *-------------------------------------*/ @@ -752,6 +759,7 @@ static void search_del_fx( * Selects best of 3 integer delays * Maximum of 3 numerators around t0 *-------------------------------------*/ + lambda = sub( t0, 1 ); ptr_sig_past = ptr_sig_in - lambda; L_num_int = L_deposit_l( -1 ); @@ -952,7 +960,6 @@ static void search_del_fx( ptr_L_den1 = L_den1; ptr_y_up = y_up; - /* if den_max = 0 : will be selected and declared unvoiced */ /* if num!=0 & den=0 : will be selected and declared unvoiced */ /* degenerated seldom cases, switch off LT is OK */ @@ -1030,6 +1037,7 @@ static void search_del_fx( /*--------------------------------------------------- * test if normalized crit0[iopt] > THRESHCRIT *--------------------------------------------------*/ + test(); IF( num_max == 0 || LE_16( den_max, 1 ) ) { @@ -1098,30 +1106,28 @@ static void search_del_fx( move16(); } - return; } + /*---------------------------------------------------------------------------- * filt_plt_fx: * * Perform long term postfilter *----------------------------------------------------------------------------*/ + static void filt_plt_fx( Word16 *s_in, /* i : i signal with past Qx */ Word16 *s_ltp, /* i : filtered signal with gain 1 Qx*/ Word16 *s_out, /* o : signal Qx */ - Word16 gain_plt /* i : filter gain Q15 */ + Word16 gain_plt /* i : filter gain Q15 */ ) { - /* Local variables */ Word32 L_acc; - Word16 n; Word16 gain_plt_1; - gain_plt_1 = sub( 32767, gain_plt ); // Q15 gain_plt_1 = add( gain_plt_1, 1 ); /* 2**15 (1 - g) */ @@ -1133,7 +1139,6 @@ static void filt_plt_fx( move16(); /* no overflow */ } - return; } @@ -1144,6 +1149,7 @@ static void filt_plt_fx( * compute delayed signal, num & den of gain for fractional delay * with long interpolation filter *----------------------------------------------------------------------------*/ + static void compute_ltp_l_fx( Word16 *s_in, /* i/o: signal with past */ Word16 ltpdel, /* i : delay factor */ @@ -1219,10 +1225,10 @@ static void compute_ltp_l_fx( move16(); move16(); - return; } + /*---------------------------------------------------------------------------- * select_ltp_fx: * @@ -1230,23 +1236,22 @@ static void compute_ltp_l_fx( * with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1 * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2 *----------------------------------------------------------------------------*/ -static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain */ - Word16 num1, /* i : numerator of gain1 Q(sh_num1) */ - Word16 den1, /* i : denominator of gain1 Q(sh_den1) */ - Word16 sh_num1, /* i : just. factor for num1 */ - Word16 sh_den1, /* i : just. factor for den1 */ - Word16 num2, /* i : numerator of gain2 Q(sh_num2) */ - Word16 den2, /* i : denominator of gain2 Q(sh_den2) */ - Word16 sh_num2, /* i : just. factor for num2 */ - Word16 sh_den2 /* i : just. factor for den2 */ +/* o : 1 = 1st gain, 2 = 2nd gain */ +static Word16 select_ltp_fx( + Word16 num1, /* i : numerator of gain1 Q(sh_num1) */ + Word16 den1, /* i : denominator of gain1 Q(sh_den1) */ + Word16 sh_num1, /* i : just. factor for num1 */ + Word16 sh_den1, /* i : just. factor for den1 */ + Word16 num2, /* i : numerator of gain2 Q(sh_num2) */ + Word16 den2, /* i : denominator of gain2 Q(sh_den2) */ + Word16 sh_num2, /* i : just. factor for num2 */ + Word16 sh_den2 /* i : just. factor for den2 */ ) { Word32 L_temp1, L_temp2; Word32 L_temp; - Word16 temp1, temp2; - IF( den2 == 0 ) { return 1; @@ -1288,6 +1293,7 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain return temp1; } + /*---------------------------------------------------------------------------- * calc_st_filt_local_fx * @@ -1336,7 +1342,6 @@ static void calc_st_filt_local_fx( } } - return; } @@ -1403,7 +1408,12 @@ static void calc_st_filt_ivas_fx( * tilt filtering with : (1 + mu z-1) * (1/1-|mu|) * computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1]) *---------------------------------------------------------------------------*/ + +#ifdef HARM_COREDECODER_FUNCTIONS +static void Filt_mu_fx( +#else void Filt_mu_fx( +#endif Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1411,14 +1421,11 @@ void Filt_mu_fx( ) { Word32 L_acc, L_temp, L_fact; - Word16 *ptrs; - Word16 n; Word16 mu, mu2, ga, temp; Word16 fact, sh_fact; - IF( parcor0 > 0 ) { mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 @@ -1464,10 +1471,10 @@ void Filt_mu_fx( BASOP_SATURATE_WARNING_ON_EVS; } - return; } +#ifndef HARM_COREDECODER_FUNCTIONS void Filt_mu_ivas_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ @@ -1557,12 +1564,16 @@ void Filt_mu_ivas_fx( return; } + +#endif + /*---------------------------------------------------------------------------- * scale_st_fx() * * control of the subframe gain * gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out *---------------------------------------------------------------------------*/ + void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal Qx */ Word16 *sig_out, /* i/o: postfilter o signal Qx */ @@ -1570,12 +1581,11 @@ void scale_st_fx( Word16 L_subfr ) { Word32 L_acc, L_temp; - Word16 i; Word16 scal_in, scal_out; Word16 s_g_in, s_g_out, temp, sh_g0, g0; Word16 gain = 0; - + move16(); /* compute i gain */ L_acc = L_deposit_l( 0 ); @@ -1654,10 +1664,10 @@ void scale_st_fx( *gain_prec = gain; move16(); - return; } + /*---------------------------------------------------------------------------- * blend_subfr2_fx() * @@ -1677,6 +1687,7 @@ void blend_subfr2_fx( move16(); move16(); move16(); + FOR( i = 0; i < L_SUBFR / 2; i++ ) { sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 1fe960d7d..91a5a671f 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -1007,7 +1007,11 @@ void dec_prm_fx( { IF( st->lpcQuantization == 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 ); +#else decode_lpc_avq_fx( st, st->numlpc, param_lpc ); +#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index b103b4c93..c6b658a2d 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -839,7 +839,7 @@ void concealment_init_x( return; } - +#ifndef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ) @@ -898,6 +898,7 @@ void concealment_init_ivas_fx( } return; } +#endif static Word16 own_random_fix( /* o : output random value */ Word16 *seed /* i/o: random seed Q0 */ -- GitLab From 3eace83dd732de5fd196ec538511a2af4980bff9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:34:29 +0100 Subject: [PATCH 3/6] HARM_COREDECODER_FUNCTIONS --- lib_enc/enc_prm_fx.c | 23 ++++++++++++++++---- lib_enc/ivas_mdct_core_enc_fx.c | 7 +++++- lib_enc/lsf_msvq_ma_enc_fx.c | 14 ++++++------ lib_enc/prot_fx_enc.h | 12 +++++++---- lib_enc/qlpc_avq_fx.c | 38 ++++++++++++++++++++++++++++++--- 5 files changed, 74 insertions(+), 20 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index d0b050ac0..89abd96da 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -1152,7 +1152,11 @@ void writeLPCparam_fx( IF( st->enableTcxLpc && st->core != ACELP_CORE ) { /* Encode the indices */ - *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */ +#else + *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ +#endif move16(); } ELSE @@ -1171,7 +1175,11 @@ void writeLPCparam_fx( move16(); } - *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#else + *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ +#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) @@ -1181,13 +1189,20 @@ void writeLPCparam_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) { assert( st->element_mode == EVS_MONO ); - - *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#else + *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#endif move16(); } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + *nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#else *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ +#endif move16(); } } diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 19f52647f..f4889bf5f 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2445,14 +2445,17 @@ void ivas_mdct_core_whitening_enc_fx( } } +#ifdef HARM_COREDECODER_FUNCTIONS + encode_lpc_avq_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); +#else encode_lpc_avq_ivas_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); +#endif st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( hBstr->nb_bits_tot, nbits_start_sns ) ); move16(); } } - /*update pitch buffer*/ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -2474,6 +2477,8 @@ void ivas_mdct_core_whitening_enc_fx( pop_wmops(); return; } + + void ivas_mdct_quant_coder_fx( CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index b79099911..00d5b8d45 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1466,7 +1466,6 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee /*mvi2i (indices[1]+c2*stages, Idx, stages);*/ Copy( indices[1] + c2 * stages, Idx, stages ); - return; } @@ -1496,7 +1495,6 @@ Word16 lsf_msvq_ma_encprm_fx( FOR( i = 0; i < no_indices; i++ ) { - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); param_lpc++; nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); @@ -1506,7 +1504,6 @@ Word16 lsf_msvq_ma_encprm_fx( test(); IF( ( core == ACELP_CORE ) && acelp_midLpc ) { - push_next_indice( hBstr, *param_lpc, bits_midlpc ); nbits_lpc = add( nbits_lpc, bits_midlpc ); } @@ -1515,7 +1512,7 @@ Word16 lsf_msvq_ma_encprm_fx( return nbits_lpc; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, // Q0 @@ -1553,7 +1550,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( return nbits_lpc; } - +#endif /*--------------------------------------------------------------------------* * midlsf_enc_fx() @@ -1995,7 +1992,7 @@ Word16 enc_lsf_tcxlpc_fx( return NumBits; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 enc_lsf_tcxlpc_ivas_fx( const Word16 **indices, /* i : Ptr to VQ indices */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ @@ -2029,7 +2026,7 @@ Word16 enc_lsf_tcxlpc_ivas_fx( } return NumBits; } - +#endif /*--------------------------------------------------------------------------* * lsf_bctcvq_encprm_fx() @@ -2056,7 +2053,7 @@ Word16 lsf_bctcvq_encprm_fx( return nbits_lpc; } - +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, @@ -2078,3 +2075,4 @@ Word16 lsf_bctcvq_encprm_ivas_fx( return nbits_lpc; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0b607089f..389152dac 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2808,12 +2808,13 @@ Word16 enc_lsf_tcxlpc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); +#ifndef HARM_COREDECODER_FUNCTIONS /* Returns: number of bits written */ Word16 enc_lsf_tcxlpc_ivas_fx( const Word16 **indices, /* i : Ptr to VQ indices */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); - +#endif Word16 encode_lpc_avq_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2822,6 +2823,7 @@ Word16 encode_lpc_avq_fx( const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 encode_lpc_avq_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2829,19 +2831,20 @@ Word16 encode_lpc_avq_ivas_fx( const Word16 core, /* i : core Q0*/ const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); - +#endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, Word16 *param_lpc, Word16 *bits_param_lpc, Word16 no_indices ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, const Word16 *bits_param_lpc, const Word16 no_indices ); - +#endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, Word16 *param_lpc, @@ -2851,6 +2854,7 @@ Word16 lsf_msvq_ma_encprm_fx( Word16 *bits_param_lpc, Word16 no_indices ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, @@ -2859,7 +2863,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( const Word16 acelp_midLpc, const Word16 *bits_param_lpc, const Word16 no_indices ); - +#endif /* o: number of bits written per frame */ Word16 IGFEncWriteBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 67b481ea0..0b28d1b77 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -123,15 +123,21 @@ void qlpc_avq_fx( return; } + /*-------------------------------------------------------------------* * unary_code() * * *--------------------------------------------------------------------*/ +#ifdef HARM_COREDECODER_FUNCTIONS +static Word16 unary_code_fx( +#else static Word16 unary_code( +#endif Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) +#ifndef HARM_COREDECODER_FUNCTIONS { Word16 nb_bits; @@ -155,6 +161,7 @@ static Word16 unary_code( static Word16 unary_code_ivas_fx( Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) +#endif { Word16 nb_bits; @@ -181,12 +188,18 @@ static Word16 unary_code_ivas_fx( return ( nb_bits ); } + /*-------------------------------------------------------------------* * unpack4bits() * * *--------------------------------------------------------------------*/ + +#ifdef HARM_COREDECODER_FUNCTIONS +static Word16 unpack4bits_fx( +#else static Word16 unpack4bits( +#endif Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ BSTR_ENC_HANDLE hBstr ) @@ -215,6 +228,7 @@ static Word16 unpack4bits( return ( i ); } +#ifndef HARM_COREDECODER_FUNCTIONS static Word16 unpack4bits_ivas_fx( Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ @@ -244,6 +258,7 @@ static Word16 unpack4bits_ivas_fx( return ( i ); } +#endif /*-------------------------------------------------------------------* * encode_lpc_avq_fx() * @@ -251,6 +266,7 @@ static Word16 unpack4bits_ivas_fx( *--------------------------------------------------------------------*/ Word16 encode_lpc_avq_fx( +#ifndef HARM_COREDECODER_FUNCTIONS BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ @@ -458,7 +474,8 @@ Word16 encode_lpc_avq_fx( } Word16 encode_lpc_avq_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ +#endif + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ const Word16 core, /* i : core Q0*/ @@ -491,8 +508,6 @@ Word16 encode_lpc_avq_ivas_fx( FOR( k = 0; k < numlpc; k++ ) { /* Retrieve quantizer type */ - - move16(); q_type = 0; IF( k != 0 ) @@ -508,6 +523,7 @@ Word16 encode_lpc_avq_ivas_fx( move16(); j = add( j, 1 ); } + /* Determine number of AVQ indices */ move16(); nb_ind = 0; @@ -615,7 +631,11 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + unary_code_fx( nb, hBstr ); +#else unary_code_ivas_fx( nb, hBstr ); +#endif } nb_bits = add( nb_bits, nb ); @@ -643,17 +663,29 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { +#ifdef HARM_COREDECODER_FUNCTIONS + unary_code_fx( nb, hBstr ); +#else unary_code_ivas_fx( nb, hBstr ); +#endif } nb_bits = add( nb_bits, nb ); avqBits = shl( qn1, 2 ); +#ifdef HARM_COREDECODER_FUNCTIONS + unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); +#else unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); +#endif j = add( j, qn1 ); nb_bits = add( nb_bits, avqBits ); // Q0 avqBits = shl( qn2, 2 ); +#ifdef HARM_COREDECODER_FUNCTIONS + unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); +#else unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); +#endif j = add( j, qn2 ); nb_bits = add( nb_bits, avqBits ); // Q0 } -- GitLab From 5fe3418e90b619a3207c2ba2a9464ae361d5e830 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 15:52:47 +0100 Subject: [PATCH 4/6] HARM_COREDECODER_FUNCTIONS --- lib_com/parameter_bitmaping_fx.c | 14 ++++++++++++-- lib_com/prot_fx.h | 3 ++- lib_enc/tns_base_enc_fx.c | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 923872090..412ab4647 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -25,6 +25,7 @@ static Word16 PutIntoBitstream_fx( return value; } +#ifndef HARM_COREDECODER_FUNCTIONS static Word16 PutIntoBitstream_ivas_fx( const Word16 **pStream, TEncodeValue EncodeValue, @@ -43,6 +44,7 @@ static Word16 PutIntoBitstream_ivas_fx( return value; } +#endif static Word16 FixedWidthEncoding( Word16 value, Word16 index ) { @@ -252,6 +254,8 @@ void SetParameters_fx( } } } + + return; } @@ -266,13 +270,11 @@ void WriteToBitstream_fx( Word16 index; Word16 iParam, nParams; - assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) ); nParams = paramsBitMap->nParams; FOR( index = 0; index < nArrayLength; index++ ) { - FOR( iParam = 0; iParam < nParams; iParam++ ) { ParamBitMap const *param; @@ -321,7 +323,11 @@ void WriteToBitstream_fx( } } } + + return; } + +#ifndef HARM_COREDECODER_FUNCTIONS void WriteToBitstream_ivas_fx( ParamsBitMap const *paramsBitMap, const Word16 nArrayLength, @@ -389,6 +395,7 @@ void WriteToBitstream_ivas_fx( } } } +#endif /** Get nBits long value from bitstream into *pStream. */ static Word16 GetFromBitstream( @@ -457,6 +464,9 @@ void ReadFromBitstream_fx( } } } + move16(); *pnSize = add( *pnSize, i_mult( nParams, nArrayLength ) ); + + return; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 028556b88..86312b8e9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10869,6 +10869,7 @@ void WriteToBitstream_fx( BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); +#ifndef HARM_COREDECODER_FUNCTIONS void WriteToBitstream_ivas_fx( ParamsBitMap const *paramsBitMap, const Word16 nArrayLength, @@ -10876,7 +10877,7 @@ void WriteToBitstream_ivas_fx( Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); - +#endif /*===========================================================================================*/ /*----------------------------------------------------------------------------------* diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index d8e5899da..08f3e5033 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -791,32 +791,53 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } } ELSE { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } } } ELSE { +#ifdef HARM_COREDECODER_FUNCTIONS + WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#else WriteToBitstream_ivas_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); +#endif } return TNS_NO_ERROR; } + /*********************************************************************************************/ /* Definitions of functions used in the mapping between TNS parameters and a bitstream. */ /*********************************************************************************************/ -- GitLab From c3dcc2dcc2aadc8480f98a3a886053d398591239 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 16:06:27 +0100 Subject: [PATCH 5/6] fix build --- lib_enc/enc_prm_fx.c | 4 ---- lib_enc/lsf_msvq_ma_enc_fx.c | 22 +++++++++++----------- lib_enc/prot_fx_enc.h | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 89abd96da..80d74522d 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -23,7 +23,6 @@ static void enc_prm_hm( Word8 flag; BSTR_ENC_HANDLE hBstr = st->hBstr; - /* Disable HM for non-GC,VC modes */ test(); IF( NE_16( st->hTcxCfg->coder_type, VOICED ) && NE_16( st->hTcxCfg->coder_type, GENERIC ) ) @@ -1111,15 +1110,12 @@ void enc_prm_fx( } /* k, window index */ } - /*--------------------------------------------------------------------------------* * END *--------------------------------------------------------------------------------*/ - total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */ - /* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */ if ( st->bits_frame_core && ( total_nbbits > st->bits_frame_core ) ) { diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 00d5b8d45..bf2b1a704 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1478,12 +1478,12 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, // Q0 - Word16 core, - Word16 acelp_mode, - Word16 acelp_midLpc, - Word16 *bits_param_lpc, - Word16 no_indices ) + const Word16 *param_lpc, // Q0 + const Word16 core, + const Word16 acelp_mode, + const Word16 acelp_midLpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ) { Word16 i, nbits_lpc; Word16 bits_midlpc; @@ -1959,8 +1959,8 @@ Word16 Q_lsf_tcxlpc_ivas_fx( *--------------------------------------------------------------------------*/ Word16 enc_lsf_tcxlpc_fx( - Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + const Word16 **indices, /* i : Ptr to VQ indices */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { Word16 i, NumBits; @@ -2036,9 +2036,9 @@ Word16 enc_lsf_tcxlpc_ivas_fx( Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, // Q0 - Word16 *bits_param_lpc, - Word16 no_indices ) + const Word16 *param_lpc, // Q0 + const Word16 *bits_param_lpc, + const Word16 no_indices ) { Word16 i, nbits_lpc; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 389152dac..6dfc26f53 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2804,8 +2804,8 @@ void enc_prm_side_Info_fx( /* Returns: number of bits written */ Word16 enc_lsf_tcxlpc_fx( - Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + const Word16 **indices, /* i : Ptr to VQ indices */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #ifndef HARM_COREDECODER_FUNCTIONS @@ -2834,9 +2834,9 @@ Word16 encode_lpc_avq_ivas_fx( #endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, - Word16 *bits_param_lpc, - Word16 no_indices ); + const Word16 *param_lpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ); #ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_bctcvq_encprm_ivas_fx( @@ -2847,12 +2847,12 @@ Word16 lsf_bctcvq_encprm_ivas_fx( #endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, - Word16 core, - Word16 acelp_mode, - Word16 acelp_midLpc, - Word16 *bits_param_lpc, - Word16 no_indices ); + const Word16 *param_lpc, + const Word16 core, + const Word16 acelp_mode, + const Word16 acelp_midLpc, + const Word16 *bits_param_lpc, + const Word16 no_indices ); #ifndef HARM_COREDECODER_FUNCTIONS Word16 lsf_msvq_ma_encprm_ivas_fx( -- GitLab From 382491812b20ed617e5480b0d6a5356f68c9a62f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jan 2026 16:27:22 +0100 Subject: [PATCH 6/6] fix build --- lib_enc/enc_prm_fx.c | 14 +++++++------- lib_enc/prot_fx_enc.h | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 80d74522d..74b27351a 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -451,14 +451,14 @@ void enc_prm_rf_fx( *-----------------------------------------------------------------*/ void enc_prm_fx( - const Word16 coder_type, /* (i) : coding type */ - Word16 param[], /* (i) : parameters Q0*/ - Word16 param_lpc[], /* (i) : LPC parameters Q0*/ - Encoder_State *st, /* i/o : quantization Analysis values */ - Word16 L_frame, /* Q0 */ + const Word16 coder_type, /* (i) : coding type */ + Word16 param[], /* (i) : parameters Q0*/ + const Word16 param_lpc[], /* (i) : LPC parameters Q0*/ + Encoder_State *st, /* i/o : quantization Analysis values */ + const Word16 L_frame, /* Q0 */ CONTEXT_HM_CONFIG hm_cfg[], - Word16 *bits_param_lpc, /* Q0 */ - Word16 no_param_lpc /* Q0 */ + Word16 *bits_param_lpc, /* Q0 */ + const Word16 no_param_lpc /* Q0 */ ) { Word16 j, k, n, sfr, core, last_core, *prm, tmp; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6dfc26f53..7d2ead3da 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2499,14 +2499,14 @@ void coder_tcx_post_ivas_fx( Word16 Q_new ); void enc_prm_fx( - const Word16 coder_type, /* i : coding type */ - Word16 param[], /* i : parameters */ - Word16 param_lpc[], /* i : LPC parameters */ - Encoder_State *st, /* i/o: quantization Analysis values */ - Word16 L_Frame, + const Word16 coder_type, /* i : coding type */ + Word16 param[], /* i : parameters */ + const Word16 param_lpc[], /* i : LPC parameters */ + Encoder_State *st, /* i/o: quantization Analysis values */ + const Word16 L_Frame, CONTEXT_HM_CONFIG hm_cfg[], Word16 *bits_param_lpc, - Word16 no_param_lpc ); + const Word16 no_param_lpc ); void IGFEncSetMode_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ @@ -3738,6 +3738,7 @@ void gain_enc_tc_fx( const Word16 Q_xn /* i : xn and y1 scaling */ ); +#ifndef HARM_COREDECODER_FUNCTIONS void gain_enc_tc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3752,7 +3753,7 @@ void gain_enc_tc_ivas_fx( Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ const Word16 Q_xn /* i : xn and y1 scaling */ ); - +#endif Word16 gaus_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3773,6 +3774,7 @@ Word16 gaus_encode_fx( Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); +#ifndef HARM_COREDECODER_FUNCTIONS Word16 gaus_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3792,7 +3794,7 @@ Word16 gaus_encode_ivas_fx( const Word16 shift, /* i : scaling factor */ Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); - +#endif void pre_proc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_frame, /* i : frame length */ -- GitLab