Loading lib_com/float_to_fix_ops.c +15 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,21 @@ Word16 Q_factor_arrL(float *x, Word16 l) } return Q; } #ifdef IVAS_FLOAT_FIXED Word16 L_get_q( float f ) { if ( fabsf( f ) > (float) INT_MAX ) { return sub( sub( W_norm( (Word64) f ), 32 ), 0 ); } else { return sub( norm_l( (Word32) f ), 0 ); } } #endif #ifdef IVAS_FLOAT_FIXED void stereo_tcx_dec_mode_switch_reconf_To_fixed( Decoder_State *st, Loading lib_com/ivas_cov_smooth.c +183 −13 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ static Word32 ivas_calculate_update_factor_fx( FOR( k = 0; k < active_bins; k++ ) { update_factor_temp += p_bin_to_band[k]; // Q22 update_factor_temp = L_add( update_factor_temp, p_bin_to_band[k] ); // Q22 } return update_factor_temp; Loading Loading @@ -109,27 +109,33 @@ static void ivas_calculate_smoothning_factor_fx( Word16 tmp, exp_diff = 0; tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // (Q15 - exp_diff) *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q13, exp_diff ) ); // Q28 *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q16, exp_diff ) ); // Q31 move32(); IF( NE_32( smooth_mode, COV_SMOOTH_MC ) ) { IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) { smooth_fact = (Word32) ( 0.5f * ONE_IN_Q31 ); move32(); } ELSE { smooth_fact = (Word32) ( 0.75f * ONE_IN_Q31 ); move32(); } L_tmp = Mpy_32_16_1( smooth_fact, add( j, 1 ) ); // (Q31 , Q0) -> Q16 *Smoothing_factor = Mpy_32_32( *Smoothing_factor, L_tmp ); // (Q28, Q16) -> Q13 *Smoothing_factor = L_shl_sat( *Smoothing_factor, Q15 ); // Q28 *Smoothing_factor = Mpy_32_32( *Smoothing_factor, L_tmp ); // (Q31, Q16) -> Q16 move32(); *Smoothing_factor = L_shl_sat( *Smoothing_factor, Q15 ); // Q31 move32(); } IF( *Smoothing_factor > max_update_rate ) // Q28 IF( GT_32( *Smoothing_factor, max_update_rate ) ) // Q31 { *Smoothing_factor = max_update_rate; move32(); } return; Loading Loading @@ -200,7 +206,6 @@ static void ivas_set_up_cov_smoothing_fx( Word16 active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; update_factor = ivas_calculate_update_factor_fx( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j], active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q28; } } ELSE Loading @@ -211,11 +216,11 @@ static void ivas_set_up_cov_smoothing_fx( Word16 active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; update_factor = ivas_calculate_update_factor_fx( p_bin_to_band, active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q28; } } hCovState->prior_bank_idx = -1; move16(); return; } Loading Loading @@ -286,14 +291,15 @@ ivas_error ivas_spar_covar_smooth_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL ) #ifdef IVAS_FLOAT_FIXED IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } #ifdef IVAS_FLOAT_FIXED IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) #else if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } #endif Loading @@ -306,6 +312,13 @@ ivas_error ivas_spar_covar_smooth_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } set_zero( hCovState->pPrior_cov_real[i][j], cov_smooth_cfg->max_bands ); #ifdef IVAS_FLOAT_FIXED if ( ( hCovState->pPrior_cov_real_fx[i][j] = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" ); } set_zero_fx( hCovState->pPrior_cov_real_fx[i][j], cov_smooth_cfg->max_bands ); #endif } } Loading Loading @@ -339,11 +352,12 @@ void ivas_spar_covar_smooth_enc_close( if ( hCovState != NULL ) { free( hCovState->pSmoothing_factor ); hCovState->pSmoothing_factor = NULL; #ifdef IVAS_FLOAT_FIXED free( hCovState->pSmoothing_factor_fx ); hCovState->pSmoothing_factor_fx = NULL; #else free( hCovState->pSmoothing_factor ); hCovState->pSmoothing_factor = NULL; #endif for ( i = 0; i < nchan_inp; i++ ) Loading @@ -352,6 +366,10 @@ void ivas_spar_covar_smooth_enc_close( { free( hCovState->pPrior_cov_real[i][j] ); hCovState->pPrior_cov_real[i][j] = NULL; #ifdef IVAS_FLOAT_FIXED free( hCovState->pPrior_cov_real_fx[i][j] ); hCovState->pPrior_cov_real_fx[i][j] = NULL; #endif } } Loading @@ -363,6 +381,120 @@ void ivas_spar_covar_smooth_enc_close( } #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* * Function ivas_compute_smooth_cov_fx() * * Compute smooth covariance real/imag. *-----------------------------------------------------------------------------------------*/ static void ivas_compute_smooth_cov_fx( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, Word32 *pCov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word32 *pPrior_cov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const Word32 fac, const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) { Word16 i, j, k; Word16 prev_idx = hCovState->prior_bank_idx; Word32 factor = 0, L_tmp, L_tmp1; Word16 sm_b; Word16 non_sm_b_idx; sm_b = BAND_SMOOTH_REST_START_IDX; assert( end_band <= pFb->filterbank_num_bands ); IF( EQ_16( prev_idx, -1 ) || EQ_16( transient_det[1], 1 ) ) { FOR( i = 0; i < num_ch; i++ ) { FOR( k = start_band; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i][k], Q31 ) ) ); move32(); } } } ELSE IF( EQ_16( transient_det[0], 1 ) ) { non_sm_b_idx = s_min( sm_b, end_band ); FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { IF( EQ_16( i, j ) ) { factor = fac; move32(); } ELSE { factor = 0; move32(); } FOR( k = start_band; k < non_sm_b_idx; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 ); move32(); L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j][k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); move32(); } } } FOR( i = 0; i < num_ch; i++ ) { FOR( k = non_sm_b_idx; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i][k], Q31 ) ) ); move32(); } } } ELSE IF( EQ_16( prev_idx, 0 ) ) { FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { IF( EQ_16( i, j ) ) { factor = fac; move32(); } ELSE { factor = 0; move32(); } FOR( k = start_band; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 ); move32(); L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j][k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); move32(); } } } } return; } #else /*-----------------------------------------------------------------------------------------* * Function ivas_compute_smooth_cov() * Loading Loading @@ -454,8 +586,45 @@ static void ivas_compute_smooth_cov( return; } #endif #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* * Function ivas_cov_smooth_process_fx() * * Covariance smoothing process *-----------------------------------------------------------------------------------------*/ void ivas_cov_smooth_process_fx( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) { Word16 i, j; Word16 num_bands = end_band - start_band; ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, (Word32) ( 1e-20f * ONE_IN_Q31 ), start_band, end_band, num_ch, transient_det, q_cov ); FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { mvl2l( &cov_real[i][j][start_band], &hCovState->pPrior_cov_real_fx[i][j][start_band], num_bands ); } } hCovState->prior_bank_idx = 0; move16(); return; } #else /*-----------------------------------------------------------------------------------------* * Function ivas_cov_smooth_process() * Loading Loading @@ -488,3 +657,4 @@ void ivas_cov_smooth_process( return; } #endif lib_com/ivas_prot.h +35 −0 Original line number Diff line number Diff line Loading @@ -5305,6 +5305,27 @@ void ivas_spar_covar_enc_close( const int16_t nchan_inp /* i : number of input channels */ ); #ifdef IVAS_FLOAT_FIXED ivas_error ivas_enc_cov_handler_process( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ float **ppIn_FR_real, float **ppIn_FR_imag, float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const int16_t start_band, const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, const int16_t transient_det[2], const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH], int16_t *res_ind, const int16_t *remix_order, int16_t *dyn_active_w_flag, const int16_t nchan_transport, const int16_t is_sba ); #else void ivas_enc_cov_handler_process( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ float **ppIn_FR_real, Loading @@ -5324,6 +5345,7 @@ void ivas_enc_cov_handler_process( const int16_t nchan_transport, const int16_t is_sba ); #endif ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */ Loading @@ -5339,6 +5361,18 @@ void ivas_spar_covar_smooth_enc_close( const int16_t nchan_inp /* i : number of input channels */ ); #ifdef IVAS_FLOAT_FIXED void ivas_cov_smooth_process_fx( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ); #else void ivas_cov_smooth_process( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Loading @@ -5348,6 +5382,7 @@ void ivas_cov_smooth_process( const int16_t num_ch, const int16_t transient_det[2] ); #endif /* Transient detector module */ ivas_error ivas_transient_det_open( Loading lib_com/ivas_stat_com.h +3 −0 Original line number Diff line number Diff line Loading @@ -354,9 +354,12 @@ typedef struct ivas_cov_smooth_state_t { float *pPrior_cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; int16_t prior_bank_idx; #ifndef IVAS_FLOAT_FIXED float *pSmoothing_factor; #endif int16_t num_bins; #ifdef IVAS_FLOAT_FIXED Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 *pSmoothing_factor_fx; #endif Loading lib_com/prot_fx2.h +5 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,11 @@ void fix2f_16(Word16 *var_fix, float *var_flt, Word32 expo); void f2fix(float *var_flt, Word32 *var_fix, Word32 expo); void fix2f(Word32 *var_fix, float *var_flt, Word32 expo); #ifdef IVAS_FLOAT_FIXED // Get max Q factor for a float value before sat in 32-bit Word16 L_get_q( float f ); #endif Word32 Mult_32_16( Word32 a, Word16 b); Loading Loading
lib_com/float_to_fix_ops.c +15 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,21 @@ Word16 Q_factor_arrL(float *x, Word16 l) } return Q; } #ifdef IVAS_FLOAT_FIXED Word16 L_get_q( float f ) { if ( fabsf( f ) > (float) INT_MAX ) { return sub( sub( W_norm( (Word64) f ), 32 ), 0 ); } else { return sub( norm_l( (Word32) f ), 0 ); } } #endif #ifdef IVAS_FLOAT_FIXED void stereo_tcx_dec_mode_switch_reconf_To_fixed( Decoder_State *st, Loading
lib_com/ivas_cov_smooth.c +183 −13 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ static Word32 ivas_calculate_update_factor_fx( FOR( k = 0; k < active_bins; k++ ) { update_factor_temp += p_bin_to_band[k]; // Q22 update_factor_temp = L_add( update_factor_temp, p_bin_to_band[k] ); // Q22 } return update_factor_temp; Loading Loading @@ -109,27 +109,33 @@ static void ivas_calculate_smoothning_factor_fx( Word16 tmp, exp_diff = 0; tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // (Q15 - exp_diff) *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q13, exp_diff ) ); // Q28 *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q16, exp_diff ) ); // Q31 move32(); IF( NE_32( smooth_mode, COV_SMOOTH_MC ) ) { IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) { smooth_fact = (Word32) ( 0.5f * ONE_IN_Q31 ); move32(); } ELSE { smooth_fact = (Word32) ( 0.75f * ONE_IN_Q31 ); move32(); } L_tmp = Mpy_32_16_1( smooth_fact, add( j, 1 ) ); // (Q31 , Q0) -> Q16 *Smoothing_factor = Mpy_32_32( *Smoothing_factor, L_tmp ); // (Q28, Q16) -> Q13 *Smoothing_factor = L_shl_sat( *Smoothing_factor, Q15 ); // Q28 *Smoothing_factor = Mpy_32_32( *Smoothing_factor, L_tmp ); // (Q31, Q16) -> Q16 move32(); *Smoothing_factor = L_shl_sat( *Smoothing_factor, Q15 ); // Q31 move32(); } IF( *Smoothing_factor > max_update_rate ) // Q28 IF( GT_32( *Smoothing_factor, max_update_rate ) ) // Q31 { *Smoothing_factor = max_update_rate; move32(); } return; Loading Loading @@ -200,7 +206,6 @@ static void ivas_set_up_cov_smoothing_fx( Word16 active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; update_factor = ivas_calculate_update_factor_fx( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j], active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q28; } } ELSE Loading @@ -211,11 +216,11 @@ static void ivas_set_up_cov_smoothing_fx( Word16 active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; update_factor = ivas_calculate_update_factor_fx( p_bin_to_band, active_bins ); ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j ); hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q28; } } hCovState->prior_bank_idx = -1; move16(); return; } Loading Loading @@ -286,14 +291,15 @@ ivas_error ivas_spar_covar_smooth_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL ) #ifdef IVAS_FLOAT_FIXED IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } #ifdef IVAS_FLOAT_FIXED IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) #else if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } #endif Loading @@ -306,6 +312,13 @@ ivas_error ivas_spar_covar_smooth_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" ); } set_zero( hCovState->pPrior_cov_real[i][j], cov_smooth_cfg->max_bands ); #ifdef IVAS_FLOAT_FIXED if ( ( hCovState->pPrior_cov_real_fx[i][j] = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" ); } set_zero_fx( hCovState->pPrior_cov_real_fx[i][j], cov_smooth_cfg->max_bands ); #endif } } Loading Loading @@ -339,11 +352,12 @@ void ivas_spar_covar_smooth_enc_close( if ( hCovState != NULL ) { free( hCovState->pSmoothing_factor ); hCovState->pSmoothing_factor = NULL; #ifdef IVAS_FLOAT_FIXED free( hCovState->pSmoothing_factor_fx ); hCovState->pSmoothing_factor_fx = NULL; #else free( hCovState->pSmoothing_factor ); hCovState->pSmoothing_factor = NULL; #endif for ( i = 0; i < nchan_inp; i++ ) Loading @@ -352,6 +366,10 @@ void ivas_spar_covar_smooth_enc_close( { free( hCovState->pPrior_cov_real[i][j] ); hCovState->pPrior_cov_real[i][j] = NULL; #ifdef IVAS_FLOAT_FIXED free( hCovState->pPrior_cov_real_fx[i][j] ); hCovState->pPrior_cov_real_fx[i][j] = NULL; #endif } } Loading @@ -363,6 +381,120 @@ void ivas_spar_covar_smooth_enc_close( } #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* * Function ivas_compute_smooth_cov_fx() * * Compute smooth covariance real/imag. *-----------------------------------------------------------------------------------------*/ static void ivas_compute_smooth_cov_fx( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, Word32 *pCov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word32 *pPrior_cov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const Word32 fac, const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) { Word16 i, j, k; Word16 prev_idx = hCovState->prior_bank_idx; Word32 factor = 0, L_tmp, L_tmp1; Word16 sm_b; Word16 non_sm_b_idx; sm_b = BAND_SMOOTH_REST_START_IDX; assert( end_band <= pFb->filterbank_num_bands ); IF( EQ_16( prev_idx, -1 ) || EQ_16( transient_det[1], 1 ) ) { FOR( i = 0; i < num_ch; i++ ) { FOR( k = start_band; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i][k], Q31 ) ) ); move32(); } } } ELSE IF( EQ_16( transient_det[0], 1 ) ) { non_sm_b_idx = s_min( sm_b, end_band ); FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { IF( EQ_16( i, j ) ) { factor = fac; move32(); } ELSE { factor = 0; move32(); } FOR( k = start_band; k < non_sm_b_idx; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 ); move32(); L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j][k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); move32(); } } } FOR( i = 0; i < num_ch; i++ ) { FOR( k = non_sm_b_idx; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31 pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i][k], Q31 ) ) ); move32(); } } } ELSE IF( EQ_16( prev_idx, 0 ) ) { FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { IF( EQ_16( i, j ) ) { factor = fac; move32(); } ELSE { factor = 0; move32(); } FOR( k = start_band; k < end_band; k++ ) { L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j][k]) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 ); move32(); L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j][k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j][k] pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp ); move32(); } } } } return; } #else /*-----------------------------------------------------------------------------------------* * Function ivas_compute_smooth_cov() * Loading Loading @@ -454,8 +586,45 @@ static void ivas_compute_smooth_cov( return; } #endif #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* * Function ivas_cov_smooth_process_fx() * * Covariance smoothing process *-----------------------------------------------------------------------------------------*/ void ivas_cov_smooth_process_fx( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) { Word16 i, j; Word16 num_bands = end_band - start_band; ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, (Word32) ( 1e-20f * ONE_IN_Q31 ), start_band, end_band, num_ch, transient_det, q_cov ); FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { mvl2l( &cov_real[i][j][start_band], &hCovState->pPrior_cov_real_fx[i][j][start_band], num_bands ); } } hCovState->prior_bank_idx = 0; move16(); return; } #else /*-----------------------------------------------------------------------------------------* * Function ivas_cov_smooth_process() * Loading Loading @@ -488,3 +657,4 @@ void ivas_cov_smooth_process( return; } #endif
lib_com/ivas_prot.h +35 −0 Original line number Diff line number Diff line Loading @@ -5305,6 +5305,27 @@ void ivas_spar_covar_enc_close( const int16_t nchan_inp /* i : number of input channels */ ); #ifdef IVAS_FLOAT_FIXED ivas_error ivas_enc_cov_handler_process( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ float **ppIn_FR_real, float **ppIn_FR_imag, float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const int16_t start_band, const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, const int16_t transient_det[2], const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH], int16_t *res_ind, const int16_t *remix_order, int16_t *dyn_active_w_flag, const int16_t nchan_transport, const int16_t is_sba ); #else void ivas_enc_cov_handler_process( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ float **ppIn_FR_real, Loading @@ -5324,6 +5345,7 @@ void ivas_enc_cov_handler_process( const int16_t nchan_transport, const int16_t is_sba ); #endif ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */ Loading @@ -5339,6 +5361,18 @@ void ivas_spar_covar_smooth_enc_close( const int16_t nchan_inp /* i : number of input channels */ ); #ifdef IVAS_FLOAT_FIXED void ivas_cov_smooth_process_fx( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], ivas_filterbank_t *pFb, /* i/o: FB handle */ const Word16 start_band, const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], Word16 q_cov[][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ); #else void ivas_cov_smooth_process( ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */ float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Loading @@ -5348,6 +5382,7 @@ void ivas_cov_smooth_process( const int16_t num_ch, const int16_t transient_det[2] ); #endif /* Transient detector module */ ivas_error ivas_transient_det_open( Loading
lib_com/ivas_stat_com.h +3 −0 Original line number Diff line number Diff line Loading @@ -354,9 +354,12 @@ typedef struct ivas_cov_smooth_state_t { float *pPrior_cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; int16_t prior_bank_idx; #ifndef IVAS_FLOAT_FIXED float *pSmoothing_factor; #endif int16_t num_bins; #ifdef IVAS_FLOAT_FIXED Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 *pSmoothing_factor_fx; #endif Loading
lib_com/prot_fx2.h +5 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,11 @@ void fix2f_16(Word16 *var_fix, float *var_flt, Word32 expo); void f2fix(float *var_flt, Word32 *var_fix, Word32 expo); void fix2f(Word32 *var_fix, float *var_flt, Word32 expo); #ifdef IVAS_FLOAT_FIXED // Get max Q factor for a float value before sat in 32-bit Word16 L_get_q( float f ); #endif Word32 Mult_32_16( Word32 a, Word16 b); Loading