Loading lib_com/hq_tools_fx.c +32 −4 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include <stdint.h> #include <stdlib.h> #include "options.h" /* Compilation switches */ Loading @@ -41,11 +42,15 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------------*/ static void overlap_hq_bwe_fx( const Word32 *hq_swb_overlap_buf, Word32 *coeff_out, const Word16 n_swb_overlap_offset, const Word16 n_swb_overlap, const Word16 *R, const Word16 num_env_bands, const Word16 num_sfm, const Word16 *sfm_end ); #ifdef HARM_HQ_CORE static void noise_mix_fx( const Word16 *coeff_fine, const Word32 L_E, const Word32 L_normq, Word16 *seed, const Word16 istart, const Word16 iend, const Word16 noise_level, Word32 *L_coeff_out, const Word16 qin, const Word16 qout ); #endif /*--------------------------------------------------------------------------* Loading @@ -61,7 +66,6 @@ void hq_swb_harmonic_calc_norm_envelop_fx( const Word16 SWB_flength /* i : length of input signal Q0*/ ) { Word16 lookback; Word16 env_index; Word16 n_freq; Loading Loading @@ -1540,11 +1544,19 @@ void hvq_concat_bands_fx( return; } /*--------------------------------------------------------------------------* * noise_mix_fx() * * *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE static void noise_mix_fx( #else void noise_mix_fx( #endif const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ const Word32 L_E, /* i : normalization factor Q17 */ const Word32 L_normq, /* i : quantized norm Q14 */ Loading Loading @@ -1804,10 +1816,13 @@ void map_hq_generic_fenv_norm_fx( normqlg2[i] = dicnlg2[s_min( add( ynrm[i], 10 ), 39 )]; /*Q0*/ move16(); } return; } static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ Word16 *Rsubband, /* Q3 */ Word16 b_add_bits_denv /*Q0*/ ) { Loading @@ -1833,6 +1848,14 @@ static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ return; } /*-------------------------------------------------------------------* * get_nor_delta_hf() * * *--------------------------------------------------------------------------*/ /*! r: Number of bits consumed for the delta coding */ Word16 get_nor_delta_hf_fx( Decoder_State *st, Word16 *ynrm, /*Q0*/ Loading Loading @@ -1877,6 +1900,8 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifndef HARM_HQ_CORE2 /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -1973,11 +1998,14 @@ Word16 calc_nor_delta_hf_ivas_fx( } return add_bits_denv; } #endif /*-------------------------------------------------------------------* * calc_nor_delta_hf() * * *--------------------------------------------------------------------------*/ Word16 calc_nor_delta_hf_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *t_audio, /* i : transform-domain coefficients Qx*/ Loading lib_com/low_rate_band_att_fx.c +9 −1 Original line number Diff line number Diff line Loading @@ -59,10 +59,18 @@ void ivas_fine_gain_pred_fx( bw = sfm_size[i_sort[band]]; move16(); // Extending for IVAS /* allowed. 8, 16, 24,32,40,48,64,80,96*/ #ifdef HARM_HQ_CORE bw_idx = band_len_idx[shr( bw, 3 )]; #else bw_idx = ivas_band_len_idx[shr( bw, 3 )]; #endif move16(); /* bw_idx= 0: 8 */ xx = L_deposit_l( 0 ); #ifdef HARM_HQ_CORE shift = band_len_ener_shift[bw_idx]; #else shift = ivas_band_len_ener_shift[bw_idx]; #endif move16(); FOR( i = sfm_start[i_sort[band]]; i < sfm_end[i_sort[band]]; i++ ) { Loading @@ -83,7 +91,7 @@ void ivas_fine_gain_pred_fx( #ifdef HARM_HQ_CORE IF( element_mode == EVS_MONO ) { Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ Mpy_32_16_ss( L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ } ELSE #endif Loading lib_com/prot_fx.h +4 −2 Original line number Diff line number Diff line Loading @@ -625,6 +625,7 @@ void hvq_concat_bands_fx( Word16 *hvq_band_end /* i : Band end indices */ ); #ifndef HARM_HQ_CORE void noise_mix_fx( const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ const Word32 L_E, /* i : normalization factor Q17 */ Loading @@ -636,7 +637,7 @@ void noise_mix_fx( Word32 *L_coeff_out, /* o : noisemixed spectrum Qout*/ const Word16 qin, const Word16 qout ); #endif void hq_generic_fine_fx( Word16 *coeff, /* i : coded/noisefilled normalized spectrum */ const Word16 last_sfm, /* i : Last coded band */ Loading Loading @@ -675,6 +676,7 @@ Word16 calc_nor_delta_hf_fx( const Word16 core_sfm /* i : index of the end band for core */ ); #ifndef HARM_HQ_CORE2 Word16 calc_nor_delta_hf_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *t_audio, /* i : transform-domain coefficients Qx*/ Loading @@ -686,7 +688,7 @@ Word16 calc_nor_delta_hf_ivas_fx( const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #endif #ifndef HARM_HQ_CORE void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode */ Loading lib_com/rom_com.h +4 −4 Original line number Diff line number Diff line Loading @@ -1486,14 +1486,14 @@ extern const Word16 tab_hup_l_fx[]; // Q15 extern const Word16 mfreq_loc_Q2fx[]; // Q0 extern const Word16 mfreq_loc_div_25[]; // Q0 #ifndef HARM_HQ_CORE2 extern const Word16 band_len_idx[]; // Q0 extern const Word16 band_len_ener_shift[]; // Q0 extern const Word16 fine_gain_pred_sqrt_bw[]; // Q11 #endif #ifndef HARM_HQ_CORE extern const Word16 ivas_band_len_idx[]; // Q0 extern const Word16 ivas_band_len_ener_shift[]; // Q0 extern const Word16 ivas_fine_gain_pred_sqrt_bw[]; // Q11 #endif extern const Word16 Mean_isf_wb[]; // Q2.56 extern const Word16 lsp_shb_prev_tbl_fx[]; // Q15 extern const Word16 lsp_shb_prev_tbl_swb_tbe_enc_fx[]; // Q15 Loading lib_com/rom_com_fx.c +9 −2 Original line number Diff line number Diff line Loading @@ -25776,7 +25776,14 @@ const Word16 mfreq_loc_div_25[] = { 7, 15, 31, 47, 63, 79, 95, 111, 127, 143, 15 /* sfm/8= [ 1 2 3 4 6 8 10 12]; */ /* % idx= 0 1 2 3 4 5 6 7; */ /* call with band_len_idx[sfm_size>>3] */ #ifndef HARM_HQ_CORE2 #ifdef HARM_HQ_CORE const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ -1, 0 /*8*/, 1 /*16*/, 2 /*24*/, 3 /*32*/, 4 /*40*/, 5 /*48 */, -1, 6 /*64 */, -1, 7 /*80*/, -1, 8 /*96*/ }; // Q0 const Word16 band_len_ener_shift[9] = { 1, 2, 2, 2, 3, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; // Q0 /* 96 requires 1 bit more than 48 */ const Word16 fine_gain_pred_sqrt_bw[9] = { 5793, 8192, 10033, 11585, 12953, 14189, 16384, 18318, 20066 }; /* (Q11) */ #else const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { // Q0 /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ Loading @@ -25785,13 +25792,13 @@ const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { const Word16 band_len_ener_shift[8] = { 1, 2, 2, 2, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; /* 96 requires 1 bit more than 48 */ // Q0 /*% sfms=[8,16,24,32,48,64,80,96], round(sqrt(sfms)*2^11) */ const Word16 fine_gain_pred_sqrt_bw[8] = { 5793, 8192, 10033, 11585, 14189, 16384, 18318, 20066 }; /* (Q11) */ #endif const Word16 ivas_band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ -1, 0 /*8*/, 1 /*16*/, 2 /*24*/, 3 /*32*/, 4 /*40*/, 5 /*48 */, -1, 6 /*64 */, -1, 7 /*80*/, -1, 8 /*96*/ }; // Q0 const Word16 ivas_band_len_ener_shift[9] = { 1, 2, 2, 2, 3, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; // Q0 /* 96 requires 1 bit more than 48 */ const Word16 ivas_fine_gain_pred_sqrt_bw[9] = { 5793, 8192, 10033, 11585, 12953, 14189, 16384, 18318, 20066 }; /* (Q11) */ #endif /*% sfms=[8,16,24,32,40,48,64,80,96], round(sqrt(sfms)*2^11) */ Loading
lib_com/hq_tools_fx.c +32 −4 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #include <stdint.h> #include <stdlib.h> #include "options.h" /* Compilation switches */ Loading @@ -41,11 +42,15 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------------*/ static void overlap_hq_bwe_fx( const Word32 *hq_swb_overlap_buf, Word32 *coeff_out, const Word16 n_swb_overlap_offset, const Word16 n_swb_overlap, const Word16 *R, const Word16 num_env_bands, const Word16 num_sfm, const Word16 *sfm_end ); #ifdef HARM_HQ_CORE static void noise_mix_fx( const Word16 *coeff_fine, const Word32 L_E, const Word32 L_normq, Word16 *seed, const Word16 istart, const Word16 iend, const Word16 noise_level, Word32 *L_coeff_out, const Word16 qin, const Word16 qout ); #endif /*--------------------------------------------------------------------------* Loading @@ -61,7 +66,6 @@ void hq_swb_harmonic_calc_norm_envelop_fx( const Word16 SWB_flength /* i : length of input signal Q0*/ ) { Word16 lookback; Word16 env_index; Word16 n_freq; Loading Loading @@ -1540,11 +1544,19 @@ void hvq_concat_bands_fx( return; } /*--------------------------------------------------------------------------* * noise_mix_fx() * * *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE static void noise_mix_fx( #else void noise_mix_fx( #endif const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ const Word32 L_E, /* i : normalization factor Q17 */ const Word32 L_normq, /* i : quantized norm Q14 */ Loading Loading @@ -1804,10 +1816,13 @@ void map_hq_generic_fenv_norm_fx( normqlg2[i] = dicnlg2[s_min( add( ynrm[i], 10 ), 39 )]; /*Q0*/ move16(); } return; } static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ Word16 *Rsubband, /* Q3 */ Word16 b_add_bits_denv /*Q0*/ ) { Loading @@ -1833,6 +1848,14 @@ static void update_rsubband_fx( const Word16 nb_sfm, /*Q0*/ return; } /*-------------------------------------------------------------------* * get_nor_delta_hf() * * *--------------------------------------------------------------------------*/ /*! r: Number of bits consumed for the delta coding */ Word16 get_nor_delta_hf_fx( Decoder_State *st, Word16 *ynrm, /*Q0*/ Loading Loading @@ -1877,6 +1900,8 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifndef HARM_HQ_CORE2 /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -1973,11 +1998,14 @@ Word16 calc_nor_delta_hf_ivas_fx( } return add_bits_denv; } #endif /*-------------------------------------------------------------------* * calc_nor_delta_hf() * * *--------------------------------------------------------------------------*/ Word16 calc_nor_delta_hf_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *t_audio, /* i : transform-domain coefficients Qx*/ Loading
lib_com/low_rate_band_att_fx.c +9 −1 Original line number Diff line number Diff line Loading @@ -59,10 +59,18 @@ void ivas_fine_gain_pred_fx( bw = sfm_size[i_sort[band]]; move16(); // Extending for IVAS /* allowed. 8, 16, 24,32,40,48,64,80,96*/ #ifdef HARM_HQ_CORE bw_idx = band_len_idx[shr( bw, 3 )]; #else bw_idx = ivas_band_len_idx[shr( bw, 3 )]; #endif move16(); /* bw_idx= 0: 8 */ xx = L_deposit_l( 0 ); #ifdef HARM_HQ_CORE shift = band_len_ener_shift[bw_idx]; #else shift = ivas_band_len_ener_shift[bw_idx]; #endif move16(); FOR( i = sfm_start[i_sort[band]]; i < sfm_end[i_sort[band]]; i++ ) { Loading @@ -83,7 +91,7 @@ void ivas_fine_gain_pred_fx( #ifdef HARM_HQ_CORE IF( element_mode == EVS_MONO ) { Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ Mpy_32_16_ss( L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ } ELSE #endif Loading
lib_com/prot_fx.h +4 −2 Original line number Diff line number Diff line Loading @@ -625,6 +625,7 @@ void hvq_concat_bands_fx( Word16 *hvq_band_end /* i : Band end indices */ ); #ifndef HARM_HQ_CORE void noise_mix_fx( const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */ const Word32 L_E, /* i : normalization factor Q17 */ Loading @@ -636,7 +637,7 @@ void noise_mix_fx( Word32 *L_coeff_out, /* o : noisemixed spectrum Qout*/ const Word16 qin, const Word16 qout ); #endif void hq_generic_fine_fx( Word16 *coeff, /* i : coded/noisefilled normalized spectrum */ const Word16 last_sfm, /* i : Last coded band */ Loading Loading @@ -675,6 +676,7 @@ Word16 calc_nor_delta_hf_fx( const Word16 core_sfm /* i : index of the end band for core */ ); #ifndef HARM_HQ_CORE2 Word16 calc_nor_delta_hf_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *t_audio, /* i : transform-domain coefficients Qx*/ Loading @@ -686,7 +688,7 @@ Word16 calc_nor_delta_hf_ivas_fx( const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #endif #ifndef HARM_HQ_CORE void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode */ Loading
lib_com/rom_com.h +4 −4 Original line number Diff line number Diff line Loading @@ -1486,14 +1486,14 @@ extern const Word16 tab_hup_l_fx[]; // Q15 extern const Word16 mfreq_loc_Q2fx[]; // Q0 extern const Word16 mfreq_loc_div_25[]; // Q0 #ifndef HARM_HQ_CORE2 extern const Word16 band_len_idx[]; // Q0 extern const Word16 band_len_ener_shift[]; // Q0 extern const Word16 fine_gain_pred_sqrt_bw[]; // Q11 #endif #ifndef HARM_HQ_CORE extern const Word16 ivas_band_len_idx[]; // Q0 extern const Word16 ivas_band_len_ener_shift[]; // Q0 extern const Word16 ivas_fine_gain_pred_sqrt_bw[]; // Q11 #endif extern const Word16 Mean_isf_wb[]; // Q2.56 extern const Word16 lsp_shb_prev_tbl_fx[]; // Q15 extern const Word16 lsp_shb_prev_tbl_swb_tbe_enc_fx[]; // Q15 Loading
lib_com/rom_com_fx.c +9 −2 Original line number Diff line number Diff line Loading @@ -25776,7 +25776,14 @@ const Word16 mfreq_loc_div_25[] = { 7, 15, 31, 47, 63, 79, 95, 111, 127, 143, 15 /* sfm/8= [ 1 2 3 4 6 8 10 12]; */ /* % idx= 0 1 2 3 4 5 6 7; */ /* call with band_len_idx[sfm_size>>3] */ #ifndef HARM_HQ_CORE2 #ifdef HARM_HQ_CORE const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ -1, 0 /*8*/, 1 /*16*/, 2 /*24*/, 3 /*32*/, 4 /*40*/, 5 /*48 */, -1, 6 /*64 */, -1, 7 /*80*/, -1, 8 /*96*/ }; // Q0 const Word16 band_len_ener_shift[9] = { 1, 2, 2, 2, 3, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; // Q0 /* 96 requires 1 bit more than 48 */ const Word16 fine_gain_pred_sqrt_bw[9] = { 5793, 8192, 10033, 11585, 12953, 14189, 16384, 18318, 20066 }; /* (Q11) */ #else const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { // Q0 /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ Loading @@ -25785,13 +25792,13 @@ const Word16 band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { const Word16 band_len_ener_shift[8] = { 1, 2, 2, 2, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; /* 96 requires 1 bit more than 48 */ // Q0 /*% sfms=[8,16,24,32,48,64,80,96], round(sqrt(sfms)*2^11) */ const Word16 fine_gain_pred_sqrt_bw[8] = { 5793, 8192, 10033, 11585, 14189, 16384, 18318, 20066 }; /* (Q11) */ #endif const Word16 ivas_band_len_idx[1 + ( MAX_SFM_LEN_FX / 8 )] = { /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/ -1, 0 /*8*/, 1 /*16*/, 2 /*24*/, 3 /*32*/, 4 /*40*/, 5 /*48 */, -1, 6 /*64 */, -1, 7 /*80*/, -1, 8 /*96*/ }; // Q0 const Word16 ivas_band_len_ener_shift[9] = { 1, 2, 2, 2, 3, 3, 3, 4 /*sfm==80*/, 4 /*sfm==96*/ }; // Q0 /* 96 requires 1 bit more than 48 */ const Word16 ivas_fine_gain_pred_sqrt_bw[9] = { 5793, 8192, 10033, 11585, 12953, 14189, 16384, 18318, 20066 }; /* (Q11) */ #endif /*% sfms=[8,16,24,32,40,48,64,80,96], round(sqrt(sfms)*2^11) */