Loading lib_com/fill_spectrum_fx.c +24 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,19 @@ #include "ivas_prot_fx.h" #ifdef HARM_HQ_CORE /*--------------------------------------------------------------------------* * fill_spectrum() * * Apply spectral filling by * - filling zero-bit bands below BWE region * - applying BWE above transition frequency *--------------------------------------------------------------------------*/ void fill_spectrum_fx( #else void ivas_fill_spectrum_fx( #endif Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ const Word16 *R, /* i : number of pulses per band Q0 */ Loading Loading @@ -173,7 +185,6 @@ void ivas_fill_spectrum_fx( move16(); } /*----------------------------------------------------------------* * Build noise-fill codebook *----------------------------------------------------------------*/ Loading Loading @@ -250,10 +261,15 @@ void ivas_fill_spectrum_fx( /*----------------------------------------------------------------* * Harmonic BWE, HVQ BWE and HQ SWB BWE *----------------------------------------------------------------*/ test(); IF( EQ_16( HQ_mode, HQ_HARMONIC ) ) { #ifdef HARM_HQ_CORE harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode ); #else ivas_harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode ); #endif } ELSE IF( EQ_16( HQ_mode, HQ_HVQ ) ) { Loading @@ -262,12 +278,17 @@ void ivas_fill_spectrum_fx( } ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) ) { #ifdef HARM_HQ_CORE hq_bwe_fx( element_mode, HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); #else hq_bwe_ivas_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); #endif } /*----------------------------------------------------------------* * HQ WB BWE refinements *----------------------------------------------------------------*/ test(); IF( EQ_16( length, L_FRAME16k ) && LE_32( L_core_brate, HQ_32k ) ) { Loading Loading @@ -304,7 +325,7 @@ void ivas_fill_spectrum_fx( return; } #ifndef HARM_HQ_CORE void fill_spectrum_fx( Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ Loading Loading @@ -564,3 +585,4 @@ void fill_spectrum_fx( return; } #endif lib_com/fine_gain_bits_fx.c +32 −9 Original line number Diff line number Diff line Loading @@ -14,7 +14,11 @@ * * HQ core encoder *--------------------------------------------------------------------------*/ static void subband_gain_bits_fx( #ifdef HARM_HQ_CORE const Word16 element_mode, /* i : element mode */ #endif const Word16 *Rk, /* i : bit allocation per band Q3 */ const Word16 N, /* i : number of bands */ Word16 *bits, /* o : gain bits per band */ Loading @@ -30,7 +34,17 @@ static void subband_gain_bits_fx( FOR( i = 0; i < N; i++ ) { /*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]); inexact C-integer division approx. */ #ifdef HARM_HQ_CORE if ( element_mode > EVS_MONO ) { bps = extract_l( L_shr( L_mult0( Rk[i], fg_inv_tbl_fx[sfmsize[i] >> 3] ), 18 ) ); /* 3+15 */ } ELSE #endif { bps = extract_l( L_shr( L_mult0( Rk[i], inv_tbl_fx[sfmsize[i]] ), 18 ) ); /* 3+15 */ } if ( EQ_32( L_shl( L_mult0( sfmsize[i], add( bps, 1 ) ), 3 ), Rk[i] ) ) { bps = add( bps, 1 ); Loading Loading @@ -60,7 +74,11 @@ static void subband_gain_bits_fx( * Assign gain adjustment bits and update bit budget *--------------------------------------------------------------------------*/ Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits */ /* o : Number of assigned gain bits */ Word16 assign_gain_bits_fx( #ifdef HARM_HQ_CORE const Word16 element_mode, /* i : element mode */ #endif const Word16 core, /* i : HQ core */ const Word16 BANDS, /* i : Number of bands */ const Word16 *band_width, /* i : Sub band bandwidth */ Loading @@ -75,7 +93,11 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned /* Allocate gain bits for every subband used, based on bit rate and bandwidth */ IF( EQ_16( core, HQ_CORE ) ) { #ifdef HARM_HQ_CORE subband_gain_bits_fx( element_mode, Rk, BANDS, gain_bits_array, band_width ); #else subband_gain_bits_fx( Rk, BANDS, gain_bits_array, band_width ); #endif } ELSE { Loading @@ -101,7 +123,7 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned return gain_bits_tot; } #ifndef HARM_HQ_CORE static void ivas_subband_gain_bits_fx( const Word16 *Rk, /* i : bit allocation per band Q3 */ const Word16 N, /* i : number of bands */ Loading Loading @@ -183,3 +205,4 @@ Word16 ivas_assign_gain_bits_fx( /* o : Number of ass return gain_bits_tot; } #endif lib_com/hq_bit_allocation_fx.c +56 −49 Original line number Diff line number Diff line Loading @@ -14,7 +14,11 @@ * Assign bits for HQ fine structure coding with PVQ *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE void hq_bit_allocation_fx( #else void ivas_hq_bit_allocation_fx( #endif const Word32 core_brate, /* i : Core bit-rate Q0 */ const Word16 length, /* i : Frame length Q0 */ const Word16 hqswb_clas, /* i : HQ class Q0 */ Loading @@ -39,8 +43,6 @@ void ivas_hq_bit_allocation_fx( Word16 E_hb_mean; Word16 E_max; Word16 i_max; /* Temp */ Word16 sfm_limit = nb_sfm; move16(); Loading Loading @@ -164,8 +166,10 @@ void ivas_hq_bit_allocation_fx( } avrg_wnorm = shr( avrg_wnorm, 3 ); FOR( i = 0; i < 4; i++ ){ IF( LT_16( wnorm[i], avrg_wnorm ) ){ FOR( i = 0; i < 4; i++ ) { if ( LT_16( wnorm[i], avrg_wnorm ) ) { wnorm[i] = avrg_wnorm; move16(); } Loading Loading @@ -227,6 +231,8 @@ move16(); return; } #ifndef HARM_HQ_CORE void hq_bit_allocation_fx( const Word32 core_brate, /* i : Core bit-rate Q0 */ const Word16 length, /* i : Frame length Q0 */ Loading Loading @@ -441,3 +447,4 @@ void hq_bit_allocation_fx( return; } #endif lib_com/hq_conf_fx.c +2 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ * * Configuration routine for HQ mode *--------------------------------------------------------------------------*/ #ifndef HARM_HQ_CORE void ivas_hq_configure_fx( const Word16 length, /* i : Frame length Q0 */ const Word16 hqswb_clas, /* i : HQ SWB class Q0 */ Loading Loading @@ -539,6 +539,7 @@ void hq_configure_evs_fx( return; } #endif void hq_configure_fx( const Word16 length, /* i : Frame length Q0 */ Loading lib_com/hq_tools_fx.c +67 −8 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 @@ -808,7 +812,11 @@ void apply_nf_gain_fx( * HQ Harmonic BWE *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE void harm_bwe_fx( #else void ivas_harm_bwe_fx( #endif const Word16 *coeff_fine, /* i : fine structure for BWE Q12*/ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ const Word16 num_sfm, /* i : Number of subbands Q0*/ Loading Loading @@ -968,9 +976,11 @@ void ivas_harm_bwe_fx( { set32_fx( &coeff_out[800], 0, 160 ); } return; } #ifndef HARM_HQ_CORE void harm_bwe_fx( const Word16 *coeff_fine, /* i : fine structure for BWE Q12*/ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ Loading Loading @@ -1133,6 +1143,7 @@ void harm_bwe_fx( } return; } #endif /*--------------------------------------------------------------------------* * HVQ_bwe_fx() Loading Loading @@ -1486,11 +1497,13 @@ void hvq_bwe_fx( return; } /*-------------------------------------------------------------------* * hvq_concat_bands_fx() * * Compute the band limits for concatenated bands for PVQ target signal in HVQ *--------------------------------------------------------------------------*/ void hvq_concat_bands_fx( const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target Q0*/ const Word16 *sel_bnds, /* i : Array of selected high bands Q0*/ Loading Loading @@ -1531,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 @@ -1582,6 +1603,8 @@ void noise_mix_fx( move32(); } } return; } Loading @@ -1590,6 +1613,7 @@ void noise_mix_fx( * * Prepare HQ GENERIC HF fine structure *--------------------------------------------------------------------------*/ void hq_generic_fine_fx( Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ const Word16 last_sfm, /* i : Last coded band Q0*/ Loading Loading @@ -1627,11 +1651,13 @@ void hq_generic_fine_fx( return; } /*--------------------------------------------------------------------------* * overlap_hq_bwe_fx() * * Overlapping at the boundary between HQ core and BWE *--------------------------------------------------------------------------*/ static void overlap_hq_bwe_fx( const Word32 *hq_swb_overlap_buf, /* i : spectrum from HQ core Q12*/ Word32 *coeff_out, /* i/o: spectrum from BWE, overlapped output Q12*/ Loading Loading @@ -1679,14 +1705,17 @@ static void overlap_hq_bwe_fx( } } } return; } /*--------------------------------------------------------------------------* * map_hq_generic_fenv_norm() * * mapping high frequency envelope to high band norm *--------------------------------------------------------------------------*/ void map_hq_generic_fenv_norm_fx( const Word16 hqswb_clas, /*Q0*/ const Word16 *hq_generic_fenv, /* Q1, frequency-domain BWE envelope */ Loading Loading @@ -1787,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 @@ -1816,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 @@ -1860,6 +1900,8 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifndef HARM_HQ_CORE /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -1956,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 @@ -1979,7 +2024,7 @@ Word16 calc_nor_delta_hf_fx( max_delta = -100; move16(); calc_norm_fx( t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); calc_norm_fx( t_audio, Q12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); add_bits_denv = 0; move16(); FOR( i = num_env_bands; i < nb_sfm; ++i ) Loading Loading @@ -2050,6 +2095,7 @@ Word16 calc_nor_delta_hf_fx( /* updating bit allocation */ update_rsubband_fx( nb_sfm, Rsubband, add_bits_denv ); } return add_bits_denv; } Loading @@ -2059,6 +2105,7 @@ Word16 calc_nor_delta_hf_fx( * * HQ GENERIC *--------------------------------------------------------------------------*/ #ifndef HARM_HQ_CORE void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode Q0*/ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/ Loading Loading @@ -2088,8 +2135,14 @@ void hq_bwe_fx( return; } #endif #ifdef HARM_HQ_CORE void hq_bwe_fx( const Word16 element_mode, /* i : element mode */ #else void hq_bwe_ivas_fx( #endif const Word16 HQ_mode, /* i : HQ mode Q0*/ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/ const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes Q1*/ Loading @@ -2109,16 +2162,20 @@ void hq_bwe_ivas_fx( n_swb_overlap_offset = add( swb_bwe_subband[0], hq_generic_offset ); n_swb_overlap = sub( sfm_end[( num_env_bands - 1 )], n_swb_overlap_offset ); /*Q0*/ Copy32( &coeff_out[n_swb_overlap_offset], hq_swb_overlap_buf_fx, sub( add( n_swb_overlap, sfm_end[( num_sfm - 1 )] ), sfm_end[( num_env_bands - 1 )] ) ); /*Q12*/ #ifdef HARM_HQ_CORE hq_generic_decoding_fx( element_mode, HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R ); #else hq_generic_decoding_ivas_fx( HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R ); #endif overlap_hq_bwe_fx( hq_swb_overlap_buf_fx, coeff_out, n_swb_overlap_offset, n_swb_overlap, R, num_env_bands, num_sfm, sfm_end ); return; } /*--------------------------------------------------------------------------* * hq_wb_nf_bwe() * Loading Loading @@ -2537,6 +2594,7 @@ void hq_wb_nf_bwe_fx( return; } /*--------------------------------------------------------------------------* * enforce_zero_for_min_envelope_fx() * Loading Loading @@ -2581,6 +2639,8 @@ void enforce_zero_for_min_envelope_fx( return; } /*--------------------------------------------------------------------------* * apply_envelope() * Loading Loading @@ -2616,10 +2676,10 @@ void apply_envelope_enc_ivas_fx( } } return; } /*--------------------------------------------------------------------------* * apply_envelope() * Loading Loading @@ -2716,6 +2776,5 @@ void apply_envelope_fx( } } return; } Loading
lib_com/fill_spectrum_fx.c +24 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,19 @@ #include "ivas_prot_fx.h" #ifdef HARM_HQ_CORE /*--------------------------------------------------------------------------* * fill_spectrum() * * Apply spectral filling by * - filling zero-bit bands below BWE region * - applying BWE above transition frequency *--------------------------------------------------------------------------*/ void fill_spectrum_fx( #else void ivas_fill_spectrum_fx( #endif Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ const Word16 *R, /* i : number of pulses per band Q0 */ Loading Loading @@ -173,7 +185,6 @@ void ivas_fill_spectrum_fx( move16(); } /*----------------------------------------------------------------* * Build noise-fill codebook *----------------------------------------------------------------*/ Loading Loading @@ -250,10 +261,15 @@ void ivas_fill_spectrum_fx( /*----------------------------------------------------------------* * Harmonic BWE, HVQ BWE and HQ SWB BWE *----------------------------------------------------------------*/ test(); IF( EQ_16( HQ_mode, HQ_HARMONIC ) ) { #ifdef HARM_HQ_CORE harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode ); #else ivas_harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode ); #endif } ELSE IF( EQ_16( HQ_mode, HQ_HVQ ) ) { Loading @@ -262,12 +278,17 @@ void ivas_fill_spectrum_fx( } ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) ) { #ifdef HARM_HQ_CORE hq_bwe_fx( element_mode, HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); #else hq_bwe_ivas_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R ); #endif } /*----------------------------------------------------------------* * HQ WB BWE refinements *----------------------------------------------------------------*/ test(); IF( EQ_16( length, L_FRAME16k ) && LE_32( L_core_brate, HQ_32k ) ) { Loading Loading @@ -304,7 +325,7 @@ void ivas_fill_spectrum_fx( return; } #ifndef HARM_HQ_CORE void fill_spectrum_fx( Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ Loading Loading @@ -564,3 +585,4 @@ void fill_spectrum_fx( return; } #endif
lib_com/fine_gain_bits_fx.c +32 −9 Original line number Diff line number Diff line Loading @@ -14,7 +14,11 @@ * * HQ core encoder *--------------------------------------------------------------------------*/ static void subband_gain_bits_fx( #ifdef HARM_HQ_CORE const Word16 element_mode, /* i : element mode */ #endif const Word16 *Rk, /* i : bit allocation per band Q3 */ const Word16 N, /* i : number of bands */ Word16 *bits, /* o : gain bits per band */ Loading @@ -30,7 +34,17 @@ static void subband_gain_bits_fx( FOR( i = 0; i < N; i++ ) { /*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]); inexact C-integer division approx. */ #ifdef HARM_HQ_CORE if ( element_mode > EVS_MONO ) { bps = extract_l( L_shr( L_mult0( Rk[i], fg_inv_tbl_fx[sfmsize[i] >> 3] ), 18 ) ); /* 3+15 */ } ELSE #endif { bps = extract_l( L_shr( L_mult0( Rk[i], inv_tbl_fx[sfmsize[i]] ), 18 ) ); /* 3+15 */ } if ( EQ_32( L_shl( L_mult0( sfmsize[i], add( bps, 1 ) ), 3 ), Rk[i] ) ) { bps = add( bps, 1 ); Loading Loading @@ -60,7 +74,11 @@ static void subband_gain_bits_fx( * Assign gain adjustment bits and update bit budget *--------------------------------------------------------------------------*/ Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits */ /* o : Number of assigned gain bits */ Word16 assign_gain_bits_fx( #ifdef HARM_HQ_CORE const Word16 element_mode, /* i : element mode */ #endif const Word16 core, /* i : HQ core */ const Word16 BANDS, /* i : Number of bands */ const Word16 *band_width, /* i : Sub band bandwidth */ Loading @@ -75,7 +93,11 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned /* Allocate gain bits for every subband used, based on bit rate and bandwidth */ IF( EQ_16( core, HQ_CORE ) ) { #ifdef HARM_HQ_CORE subband_gain_bits_fx( element_mode, Rk, BANDS, gain_bits_array, band_width ); #else subband_gain_bits_fx( Rk, BANDS, gain_bits_array, band_width ); #endif } ELSE { Loading @@ -101,7 +123,7 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned return gain_bits_tot; } #ifndef HARM_HQ_CORE static void ivas_subband_gain_bits_fx( const Word16 *Rk, /* i : bit allocation per band Q3 */ const Word16 N, /* i : number of bands */ Loading Loading @@ -183,3 +205,4 @@ Word16 ivas_assign_gain_bits_fx( /* o : Number of ass return gain_bits_tot; } #endif
lib_com/hq_bit_allocation_fx.c +56 −49 Original line number Diff line number Diff line Loading @@ -14,7 +14,11 @@ * Assign bits for HQ fine structure coding with PVQ *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE void hq_bit_allocation_fx( #else void ivas_hq_bit_allocation_fx( #endif const Word32 core_brate, /* i : Core bit-rate Q0 */ const Word16 length, /* i : Frame length Q0 */ const Word16 hqswb_clas, /* i : HQ class Q0 */ Loading @@ -39,8 +43,6 @@ void ivas_hq_bit_allocation_fx( Word16 E_hb_mean; Word16 E_max; Word16 i_max; /* Temp */ Word16 sfm_limit = nb_sfm; move16(); Loading Loading @@ -164,8 +166,10 @@ void ivas_hq_bit_allocation_fx( } avrg_wnorm = shr( avrg_wnorm, 3 ); FOR( i = 0; i < 4; i++ ){ IF( LT_16( wnorm[i], avrg_wnorm ) ){ FOR( i = 0; i < 4; i++ ) { if ( LT_16( wnorm[i], avrg_wnorm ) ) { wnorm[i] = avrg_wnorm; move16(); } Loading Loading @@ -227,6 +231,8 @@ move16(); return; } #ifndef HARM_HQ_CORE void hq_bit_allocation_fx( const Word32 core_brate, /* i : Core bit-rate Q0 */ const Word16 length, /* i : Frame length Q0 */ Loading Loading @@ -441,3 +447,4 @@ void hq_bit_allocation_fx( return; } #endif
lib_com/hq_conf_fx.c +2 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ * * Configuration routine for HQ mode *--------------------------------------------------------------------------*/ #ifndef HARM_HQ_CORE void ivas_hq_configure_fx( const Word16 length, /* i : Frame length Q0 */ const Word16 hqswb_clas, /* i : HQ SWB class Q0 */ Loading Loading @@ -539,6 +539,7 @@ void hq_configure_evs_fx( return; } #endif void hq_configure_fx( const Word16 length, /* i : Frame length Q0 */ Loading
lib_com/hq_tools_fx.c +67 −8 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 @@ -808,7 +812,11 @@ void apply_nf_gain_fx( * HQ Harmonic BWE *--------------------------------------------------------------------------*/ #ifdef HARM_HQ_CORE void harm_bwe_fx( #else void ivas_harm_bwe_fx( #endif const Word16 *coeff_fine, /* i : fine structure for BWE Q12*/ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ const Word16 num_sfm, /* i : Number of subbands Q0*/ Loading Loading @@ -968,9 +976,11 @@ void ivas_harm_bwe_fx( { set32_fx( &coeff_out[800], 0, 160 ); } return; } #ifndef HARM_HQ_CORE void harm_bwe_fx( const Word16 *coeff_fine, /* i : fine structure for BWE Q12*/ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ Loading Loading @@ -1133,6 +1143,7 @@ void harm_bwe_fx( } return; } #endif /*--------------------------------------------------------------------------* * HVQ_bwe_fx() Loading Loading @@ -1486,11 +1497,13 @@ void hvq_bwe_fx( return; } /*-------------------------------------------------------------------* * hvq_concat_bands_fx() * * Compute the band limits for concatenated bands for PVQ target signal in HVQ *--------------------------------------------------------------------------*/ void hvq_concat_bands_fx( const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target Q0*/ const Word16 *sel_bnds, /* i : Array of selected high bands Q0*/ Loading Loading @@ -1531,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 @@ -1582,6 +1603,8 @@ void noise_mix_fx( move32(); } } return; } Loading @@ -1590,6 +1613,7 @@ void noise_mix_fx( * * Prepare HQ GENERIC HF fine structure *--------------------------------------------------------------------------*/ void hq_generic_fine_fx( Word16 *coeff, /* i : coded/noisefilled normalized spectrum Q12*/ const Word16 last_sfm, /* i : Last coded band Q0*/ Loading Loading @@ -1627,11 +1651,13 @@ void hq_generic_fine_fx( return; } /*--------------------------------------------------------------------------* * overlap_hq_bwe_fx() * * Overlapping at the boundary between HQ core and BWE *--------------------------------------------------------------------------*/ static void overlap_hq_bwe_fx( const Word32 *hq_swb_overlap_buf, /* i : spectrum from HQ core Q12*/ Word32 *coeff_out, /* i/o: spectrum from BWE, overlapped output Q12*/ Loading Loading @@ -1679,14 +1705,17 @@ static void overlap_hq_bwe_fx( } } } return; } /*--------------------------------------------------------------------------* * map_hq_generic_fenv_norm() * * mapping high frequency envelope to high band norm *--------------------------------------------------------------------------*/ void map_hq_generic_fenv_norm_fx( const Word16 hqswb_clas, /*Q0*/ const Word16 *hq_generic_fenv, /* Q1, frequency-domain BWE envelope */ Loading Loading @@ -1787,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 @@ -1816,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 @@ -1860,6 +1900,8 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifndef HARM_HQ_CORE /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -1956,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 @@ -1979,7 +2024,7 @@ Word16 calc_nor_delta_hf_fx( max_delta = -100; move16(); calc_norm_fx( t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); calc_norm_fx( t_audio, Q12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); add_bits_denv = 0; move16(); FOR( i = num_env_bands; i < nb_sfm; ++i ) Loading Loading @@ -2050,6 +2095,7 @@ Word16 calc_nor_delta_hf_fx( /* updating bit allocation */ update_rsubband_fx( nb_sfm, Rsubband, add_bits_denv ); } return add_bits_denv; } Loading @@ -2059,6 +2105,7 @@ Word16 calc_nor_delta_hf_fx( * * HQ GENERIC *--------------------------------------------------------------------------*/ #ifndef HARM_HQ_CORE void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode Q0*/ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/ Loading Loading @@ -2088,8 +2135,14 @@ void hq_bwe_fx( return; } #endif #ifdef HARM_HQ_CORE void hq_bwe_fx( const Word16 element_mode, /* i : element mode */ #else void hq_bwe_ivas_fx( #endif const Word16 HQ_mode, /* i : HQ mode Q0*/ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/ const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes Q1*/ Loading @@ -2109,16 +2162,20 @@ void hq_bwe_ivas_fx( n_swb_overlap_offset = add( swb_bwe_subband[0], hq_generic_offset ); n_swb_overlap = sub( sfm_end[( num_env_bands - 1 )], n_swb_overlap_offset ); /*Q0*/ Copy32( &coeff_out[n_swb_overlap_offset], hq_swb_overlap_buf_fx, sub( add( n_swb_overlap, sfm_end[( num_sfm - 1 )] ), sfm_end[( num_env_bands - 1 )] ) ); /*Q12*/ #ifdef HARM_HQ_CORE hq_generic_decoding_fx( element_mode, HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R ); #else hq_generic_decoding_ivas_fx( HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R ); #endif overlap_hq_bwe_fx( hq_swb_overlap_buf_fx, coeff_out, n_swb_overlap_offset, n_swb_overlap, R, num_env_bands, num_sfm, sfm_end ); return; } /*--------------------------------------------------------------------------* * hq_wb_nf_bwe() * Loading Loading @@ -2537,6 +2594,7 @@ void hq_wb_nf_bwe_fx( return; } /*--------------------------------------------------------------------------* * enforce_zero_for_min_envelope_fx() * Loading Loading @@ -2581,6 +2639,8 @@ void enforce_zero_for_min_envelope_fx( return; } /*--------------------------------------------------------------------------* * apply_envelope() * Loading Loading @@ -2616,10 +2676,10 @@ void apply_envelope_enc_ivas_fx( } } return; } /*--------------------------------------------------------------------------* * apply_envelope() * Loading Loading @@ -2716,6 +2776,5 @@ void apply_envelope_fx( } } return; }