Loading lib_com/hq_tools_fx.c +139 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "rom_com.h" /* Static table prototypes FIP version */ #include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" #include "prot.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif Loading Loading @@ -1920,6 +1921,104 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * calc_nor_delta_hf() * * *--------------------------------------------------------------------------*/ 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*/ Word16 *ynrm, /* i/o: norm indices */ Word16 *Rsubband, /* i/o: sub-band bit allocation */ const Word16 num_env_bands, /* i : Number coded envelope bands */ const Word16 nb_sfm, /* i : Number of envelope bands */ const Word16 *sfmsize, /* i : band length */ const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ) { Word16 i; Word16 ynrm_t[44], normqlg2_t[44]; Word16 delta, max_delta, min_delta, bitsforDelta, add_bits_denv; max_delta = -100; move16(); calc_norm_fx( t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); add_bits_denv = 0; move16(); FOR( i = num_env_bands; i < nb_sfm; ++i ) { IF( Rsubband[i] != 0 ) { delta = sub( ynrm_t[i], ynrm[i] ); IF( delta > 0 ) { delta = add( delta, 1 ); } ELSE { delta = negate( delta ); } if ( GT_16( delta, max_delta ) ) { max_delta = delta; move16(); } } } IF( GE_16( core_sfm, num_env_bands ) ) { IF( LT_16( max_delta, 16 ) ) { bitsforDelta = 2; move16(); FOR( ; max_delta >= 2; max_delta >>= 1 ) { bitsforDelta = add( bitsforDelta, 1 ); } } ELSE { bitsforDelta = 5; move16(); } max_delta = sub( shl( 1, sub( bitsforDelta, 1 ) ), 1 ); min_delta = negate( add( max_delta, 1 ) ); /* updating norm & storing delta norm */ add_bits_denv = 2; move16(); push_indice( hBstr, IND_DELTA_ENV_HQ, sub( bitsforDelta, 2 ), 2 ); FOR( i = num_env_bands; i < nb_sfm; ++i ) { IF( Rsubband[i] != 0 ) { delta = sub( ynrm_t[i], ynrm[i] ); IF( GT_16( delta, max_delta ) ) { delta = max_delta; move16(); } ELSE IF( LT_16( delta, min_delta ) ) { delta = min_delta; move16(); } push_indice( hBstr, IND_DELTA_ENV_HQ, delta - min_delta, bitsforDelta ); ynrm[i] = add( ynrm[i], delta ); move16(); add_bits_denv = add( add_bits_denv, bitsforDelta ); } } /* updating bit allocation */ update_rsubband_fx( nb_sfm, Rsubband, add_bits_denv ); } return add_bits_denv; } #endif /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -2555,9 +2654,49 @@ void enforce_zero_for_min_envelope_fx( } } return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * apply_envelope() * * Apply spectral envelope with envelope adjustments *--------------------------------------------------------------------------*/ void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ const Word16 num_sfm, /* i : Total number of bands Q0 */ const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ) { Word16 i; Word16 sfm; UWord16 lsb; Word32 normq; Word32 L_tmp; FOR( sfm = 0; sfm < num_sfm; sfm++ ) { normq = dicn_fx[norm[sfm]]; move16(); FOR( i = sfm_start[sfm]; i < sfm_end[sfm]; i++ ) { /*coeff_out[i] = coeff[i]*normq; */ Mpy_32_16_ss( normq, coeff[i], &L_tmp, &lsb ); coeff_out[i] = L_add( L_shl( L_tmp, 1 ), L_shr( lsb, 15 ) ); move32(); /* Q12 (14+12+1-16)+1 */ } } return; } #endif /*--------------------------------------------------------------------------* * apply_envelope() * Loading lib_com/ivas_dirac_com.c +11 −5 Original line number Diff line number Diff line Loading @@ -1372,12 +1372,18 @@ void computeDiffuseness_fixed( min_q_shift2 = Q31; move16(); min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_energy, i_mult( DIRAC_NUM_DIMS, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ) ); min_q_shift2 = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); } } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); q_ene = add( q_factor_energy[0], min_q_shift1 ); move16(); q_intensity = sub( q_factor_intensity[0], min_q_shift2 ); q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) Loading @@ -1403,13 +1409,13 @@ void computeDiffuseness_fixed( q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ q_tmp = sub( q_factor_intensity[i], min_q_shift2 ); q_tmp = add( q_factor_intensity[i], min_q_shift2 ); FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shr( p_tmp[k], min_q_shift2 ); tmp = L_shl( p_tmp[k], min_q_shift2 ); IF( LT_16( q_intensity, q_tmp ) ) { intensity_slow[add( i_mult( j, num_freq_bands ), k )] = L_add( intensity_slow[add( i_mult( j, num_freq_bands ), k )], L_shr( tmp, sub( q_tmp, q_intensity ) ) ); Loading lib_com/ivas_prot.h +14 −0 Original line number Diff line number Diff line Loading @@ -80,15 +80,29 @@ void copy_encoder_config( const int16_t flag_all /* i : flag 1==update all, 0=partial update */ ); #ifndef IVAS_FLOAT_FIXED void ivas_write_format( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); #else void ivas_write_format_fx( /* i/o: IVAS encoder structure */ Encoder_Struct *st_ivas ); #endif #ifndef IVAS_FLOAT_FIXED void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #else void ivas_write_format_sid_fx( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 element_mode, /* i : element bitrate */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #endif ivas_error create_sce_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ Loading lib_com/logqnorm_fx.c +0 −2 Original line number Diff line number Diff line Loading @@ -294,8 +294,6 @@ void calc_norm_ivas_fx( Word16 tmp; set16_fx( norm, 0, start_band ); // logqnorm_ivas_fx( &x_fx[band_start[start_band]], 12, &x[band_start[start_band]], &nrm, 32, band_len[start_band], thren_HQ ); logqnorm_ivas_fx( &x_fx[band_start[start_band]], 12, &nrm, 32, band_len[start_band], thren_HQ_fx ); norm[start_band] = nrm; move16(); Loading lib_com/prot_fx.h +37 −3 Original line number Diff line number Diff line Loading @@ -675,7 +675,19 @@ Word16 calc_nor_delta_hf_fx( const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #ifdef IVAS_FLOAT_FIXED 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*/ Word16 *ynrm, /* i/o: norm indices */ Word16 *Rsubband, /* i/o: sub-band bit allocation */ const Word16 num_env_bands, /* i : Number coded envelope bands */ const Word16 nb_sfm, /* i : Number of envelope bands */ const Word16 *sfmsize, /* i : band length */ const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #endif void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode */ Word32 *coeff_out1, /* i/o: BWE i & temporary buffer */ Loading Loading @@ -717,7 +729,14 @@ void enforce_zero_for_min_envelope_fx( const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end /* i : Sub band end indices Q0 */ ); void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ const Word16 num_sfm, /* i : Total number of bands Q0 */ const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ); void apply_envelope_fx( const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope */ Loading Loading @@ -4660,7 +4679,16 @@ void fine_gain_quant_fx( Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); #ifdef IVAS_FLOAT_FIXED void fine_gain_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order */ const Word16 num_sfm, /* i : Number of bands */ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); #endif void get_max_pulses_fx( const Word16 *band_start, /* i : Sub band start indices */ const Word16 *band_end, /* i : Sub band end indices */ Loading Loading @@ -10531,4 +10559,10 @@ void writeTCXparam_fx( Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); void calculate_hangover_attenuation_gain_ivas_fx( Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor */ const Word16 vad_hover_flag /* i : VAD hangover flag */ ); #endif Loading
lib_com/hq_tools_fx.c +139 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "rom_com.h" /* Static table prototypes FIP version */ #include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" #include "prot.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif Loading Loading @@ -1920,6 +1921,104 @@ Word16 get_nor_delta_hf_fx( } return add_bits_denv; } #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * calc_nor_delta_hf() * * *--------------------------------------------------------------------------*/ 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*/ Word16 *ynrm, /* i/o: norm indices */ Word16 *Rsubband, /* i/o: sub-band bit allocation */ const Word16 num_env_bands, /* i : Number coded envelope bands */ const Word16 nb_sfm, /* i : Number of envelope bands */ const Word16 *sfmsize, /* i : band length */ const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ) { Word16 i; Word16 ynrm_t[44], normqlg2_t[44]; Word16 delta, max_delta, min_delta, bitsforDelta, add_bits_denv; max_delta = -100; move16(); calc_norm_fx( t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start ); add_bits_denv = 0; move16(); FOR( i = num_env_bands; i < nb_sfm; ++i ) { IF( Rsubband[i] != 0 ) { delta = sub( ynrm_t[i], ynrm[i] ); IF( delta > 0 ) { delta = add( delta, 1 ); } ELSE { delta = negate( delta ); } if ( GT_16( delta, max_delta ) ) { max_delta = delta; move16(); } } } IF( GE_16( core_sfm, num_env_bands ) ) { IF( LT_16( max_delta, 16 ) ) { bitsforDelta = 2; move16(); FOR( ; max_delta >= 2; max_delta >>= 1 ) { bitsforDelta = add( bitsforDelta, 1 ); } } ELSE { bitsforDelta = 5; move16(); } max_delta = sub( shl( 1, sub( bitsforDelta, 1 ) ), 1 ); min_delta = negate( add( max_delta, 1 ) ); /* updating norm & storing delta norm */ add_bits_denv = 2; move16(); push_indice( hBstr, IND_DELTA_ENV_HQ, sub( bitsforDelta, 2 ), 2 ); FOR( i = num_env_bands; i < nb_sfm; ++i ) { IF( Rsubband[i] != 0 ) { delta = sub( ynrm_t[i], ynrm[i] ); IF( GT_16( delta, max_delta ) ) { delta = max_delta; move16(); } ELSE IF( LT_16( delta, min_delta ) ) { delta = min_delta; move16(); } push_indice( hBstr, IND_DELTA_ENV_HQ, delta - min_delta, bitsforDelta ); ynrm[i] = add( ynrm[i], delta ); move16(); add_bits_denv = add( add_bits_denv, bitsforDelta ); } } /* updating bit allocation */ update_rsubband_fx( nb_sfm, Rsubband, add_bits_denv ); } return add_bits_denv; } #endif /*-------------------------------------------------------------------* * calc_nor_delta_hf() * Loading Loading @@ -2555,9 +2654,49 @@ void enforce_zero_for_min_envelope_fx( } } return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * apply_envelope() * * Apply spectral envelope with envelope adjustments *--------------------------------------------------------------------------*/ void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ const Word16 num_sfm, /* i : Total number of bands Q0 */ const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ) { Word16 i; Word16 sfm; UWord16 lsb; Word32 normq; Word32 L_tmp; FOR( sfm = 0; sfm < num_sfm; sfm++ ) { normq = dicn_fx[norm[sfm]]; move16(); FOR( i = sfm_start[sfm]; i < sfm_end[sfm]; i++ ) { /*coeff_out[i] = coeff[i]*normq; */ Mpy_32_16_ss( normq, coeff[i], &L_tmp, &lsb ); coeff_out[i] = L_add( L_shl( L_tmp, 1 ), L_shr( lsb, 15 ) ); move32(); /* Q12 (14+12+1-16)+1 */ } } return; } #endif /*--------------------------------------------------------------------------* * apply_envelope() * Loading
lib_com/ivas_dirac_com.c +11 −5 Original line number Diff line number Diff line Loading @@ -1372,12 +1372,18 @@ void computeDiffuseness_fixed( min_q_shift2 = Q31; move16(); min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_energy, i_mult( DIRAC_NUM_DIMS, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ) ); min_q_shift2 = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); } } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); q_ene = add( q_factor_energy[0], min_q_shift1 ); move16(); q_intensity = sub( q_factor_intensity[0], min_q_shift2 ); q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) Loading @@ -1403,13 +1409,13 @@ void computeDiffuseness_fixed( q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ q_tmp = sub( q_factor_intensity[i], min_q_shift2 ); q_tmp = add( q_factor_intensity[i], min_q_shift2 ); FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shr( p_tmp[k], min_q_shift2 ); tmp = L_shl( p_tmp[k], min_q_shift2 ); IF( LT_16( q_intensity, q_tmp ) ) { intensity_slow[add( i_mult( j, num_freq_bands ), k )] = L_add( intensity_slow[add( i_mult( j, num_freq_bands ), k )], L_shr( tmp, sub( q_tmp, q_intensity ) ) ); Loading
lib_com/ivas_prot.h +14 −0 Original line number Diff line number Diff line Loading @@ -80,15 +80,29 @@ void copy_encoder_config( const int16_t flag_all /* i : flag 1==update all, 0=partial update */ ); #ifndef IVAS_FLOAT_FIXED void ivas_write_format( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); #else void ivas_write_format_fx( /* i/o: IVAS encoder structure */ Encoder_Struct *st_ivas ); #endif #ifndef IVAS_FLOAT_FIXED void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #else void ivas_write_format_sid_fx( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 element_mode, /* i : element bitrate */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); #endif ivas_error create_sce_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ Loading
lib_com/logqnorm_fx.c +0 −2 Original line number Diff line number Diff line Loading @@ -294,8 +294,6 @@ void calc_norm_ivas_fx( Word16 tmp; set16_fx( norm, 0, start_band ); // logqnorm_ivas_fx( &x_fx[band_start[start_band]], 12, &x[band_start[start_band]], &nrm, 32, band_len[start_band], thren_HQ ); logqnorm_ivas_fx( &x_fx[band_start[start_band]], 12, &nrm, 32, band_len[start_band], thren_HQ_fx ); norm[start_band] = nrm; move16(); Loading
lib_com/prot_fx.h +37 −3 Original line number Diff line number Diff line Loading @@ -675,7 +675,19 @@ Word16 calc_nor_delta_hf_fx( const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #ifdef IVAS_FLOAT_FIXED 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*/ Word16 *ynrm, /* i/o: norm indices */ Word16 *Rsubband, /* i/o: sub-band bit allocation */ const Word16 num_env_bands, /* i : Number coded envelope bands */ const Word16 nb_sfm, /* i : Number of envelope bands */ const Word16 *sfmsize, /* i : band length */ const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); #endif void hq_bwe_fx( const Word16 HQ_mode, /* i : HQ mode */ Word32 *coeff_out1, /* i/o: BWE i & temporary buffer */ Loading Loading @@ -717,7 +729,14 @@ void enforce_zero_for_min_envelope_fx( const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end /* i : Sub band end indices Q0 */ ); void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ const Word16 num_sfm, /* i : Total number of bands Q0 */ const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ); void apply_envelope_fx( const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope */ Loading Loading @@ -4660,7 +4679,16 @@ void fine_gain_quant_fx( Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); #ifdef IVAS_FLOAT_FIXED void fine_gain_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order */ const Word16 num_sfm, /* i : Number of bands */ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); #endif void get_max_pulses_fx( const Word16 *band_start, /* i : Sub band start indices */ const Word16 *band_end, /* i : Sub band end indices */ Loading Loading @@ -10531,4 +10559,10 @@ void writeTCXparam_fx( Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); void calculate_hangover_attenuation_gain_ivas_fx( Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor */ const Word16 vad_hover_flag /* i : VAD hangover flag */ ); #endif