diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b574152f38242990875a301aa990904652dbfe91..868cd529c89378c1255575dc1cab712c3b543d26 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -69,12 +69,13 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t #endif - #ifdef IVAS_FLOAT_FIXED static Word16 ceil_fx16( Word16 inp, Word16 Q ); -static Word16 ceil_fx16( Word16 inp, Word16 Q ) { +static Word16 ceil_fx16( Word16 inp, Word16 Q ) +{ Word16 ret = shr( inp, Q ); - IF( inp & ( ( 1 << Q ) - 1) > 0) { + IF( inp & ( ( 1 << Q ) - 1 ) > 0 ) + { ret = ret + 1; } return ret; @@ -93,10 +94,10 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fix[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Word32 *p_output_fix[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ #endif int16_t nchan_remapped; @@ -208,7 +209,7 @@ ivas_error ivas_jbm_dec_tc( hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); for ( int i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float)p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -249,7 +250,7 @@ ivas_error ivas_jbm_dec_tc( if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { #ifdef IVAS_FLOAT_FIXED -#if 1/*Cleanup changes: float to fixed*/ +#if 1 /*Cleanup changes: float to fixed*/ FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) { st_ivas->hIsmMetaData[ind]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->azimuth * ( 1 << 22 ) ); @@ -273,7 +274,7 @@ ivas_error ivas_jbm_dec_tc( } #endif ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); -#if 1/*Cleanup changes: fixed to float*/ +#if 1 /*Cleanup changes: fixed to float*/ FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) { st_ivas->hIsmMetaData[ind]->azimuth = (float) ( st_ivas->hIsmMetaData[ind]->azimuth_fx ) / (float) ( 1 << 22 ); @@ -287,10 +288,10 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_flt = (float) ( st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ) / 32767.f; IF( st_ivas->hParamIsmDec ) { - fixedToFloat_arrL( st_ivas->hParamIsmDec->azimuth_values_fx, st_ivas->hParamIsmDec->azimuth_values, 22, st_ivas->nchan_ism); - fixedToFloat_arrL( st_ivas->hParamIsmDec->elevation_values_fx, st_ivas->hParamIsmDec->elevation_values, 22, st_ivas->nchan_ism); + fixedToFloat_arrL( st_ivas->hParamIsmDec->azimuth_values_fx, st_ivas->hParamIsmDec->azimuth_values, 22, st_ivas->nchan_ism ); + fixedToFloat_arrL( st_ivas->hParamIsmDec->elevation_values_fx, st_ivas->hParamIsmDec->elevation_values, 22, st_ivas->nchan_ism ); } - FOR(Word16 ch = 0; ch < st_ivas->nchan_ism; ch++ ) + FOR( Word16 ch = 0; ch < st_ivas->nchan_ism; ch++ ) { st_ivas->hIsmMetaData[ch]->last_azimuth = fixedToFloat( st_ivas->hIsmMetaData[ch]->last_azimuth_fx, 22 ); st_ivas->hIsmMetaData[ch]->last_elevation = fixedToFloat( st_ivas->hIsmMetaData[ch]->last_elevation_fx, 22 ); @@ -334,31 +335,31 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 - Word16 Q_cngNoiseLevel[MAX_SCE]; - Word16 cng_noise_level_len, ch; - HANDLE_FD_CNG_COM hFdCngCom; - FOR(ch = 0; ch < 4; ch++) - { - IF(st_ivas->hSCE[ch] != NULL) - { - hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; - cng_noise_level_len = sub(hFdCngCom->stopFFTbin, hFdCngCom->startBand); - Q_cngNoiseLevel[ch] = Q_factor_arrL(hFdCngCom->cngNoiseLevel_flt, cng_noise_level_len); - floatToFixed_arrL(hFdCngCom->cngNoiseLevel_flt, hFdCngCom->cngNoiseLevel, Q_cngNoiseLevel[ch], cng_noise_level_len); - } - } + Word16 Q_cngNoiseLevel[MAX_SCE]; + Word16 cng_noise_level_len, ch; + HANDLE_FD_CNG_COM hFdCngCom; + FOR( ch = 0; ch < 4; ch++ ) + { + IF( st_ivas->hSCE[ch] != NULL ) + { + hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; + cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); + Q_cngNoiseLevel[ch] = Q_factor_arrL( hFdCngCom->cngNoiseLevel_flt, cng_noise_level_len ); + floatToFixed_arrL( hFdCngCom->cngNoiseLevel_flt, hFdCngCom->cngNoiseLevel, Q_cngNoiseLevel[ch], cng_noise_level_len ); + } + } #endif - ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport , Q_cngNoiseLevel); + ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); #if 1 - FOR(ch = 0; ch < 4; ch++) - { - IF(st_ivas->hSCE[ch] != NULL) - { - hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; - cng_noise_level_len = sub(hFdCngCom->stopFFTbin, hFdCngCom->startBand); - fixedToFloat_arrL(hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel_flt, Q_cngNoiseLevel[ch], cng_noise_level_len); - } - } + FOR( ch = 0; ch < 4; ch++ ) + { + IF( st_ivas->hSCE[ch] != NULL ) + { + hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; + cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); + fixedToFloat_arrL( hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel_flt, Q_cngNoiseLevel[ch], cng_noise_level_len ); + } + } #endif #else ivas_ism_dtx_limit_noise_energy_for_near_silence( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); @@ -517,19 +518,19 @@ ivas_error ivas_jbm_dec_tc( } } Word16 Q_p_output = 31; - for ( int i = 0; i< st_ivas->nchan_transport; i++ ) + for ( int i = 0; i < st_ivas->nchan_transport; i++ ) { - Q_p_output = s_min( Q_p_output, Q_factor_arrL( p_output[i], output_frame) ); + Q_p_output = s_min( Q_p_output, Q_factor_arrL( p_output[i], output_frame ) ); } for ( int i = 0; i < st_ivas->nchan_transport; i++ ) { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q_p_output, output_frame); + floatToFixed_arrL( p_output[i], p_output_fx[i], Q_p_output, output_frame ); } - ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame );/*returns Q-1*/ + ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/ Q_p_output = Q_p_output - 1; for ( int i = 0; i < st_ivas->nchan_transport; i++ ) { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_p_output, output_frame); + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_p_output, output_frame ); } for ( int lp = 0; lp < st_ivas->nchan_transport; lp++ ) { @@ -817,161 +818,161 @@ ivas_error ivas_jbm_dec_tc( { float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; static int frame_counter = 0; - if (frame_counter >= 200) + if ( frame_counter >= 200 ) frame_counter = frame_counter; float max_val = 0.0; int i_max_val_psd, i_max_val_op; CPE_DEC_HANDLE hCPE = st_ivas->hCPE[0]; SCE_DEC_HANDLE hSCE = st_ivas->hSCE[0]; - for (int ii = 0; ii < sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0]); ii++) + for ( int ii = 0; ii < sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0] ); ii++ ) { - if (max_val < fabs(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii])) + if ( max_val < fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ) ) { - max_val = (float)fabs(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii]); + max_val = (float) fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ); } } - i_max_val_psd = (int)max_val; - for (int ii = 0; ii < 2; ii++) + i_max_val_psd = (int) max_val; + for ( int ii = 0; ii < 2; ii++ ) { - for (int jj = 0; jj < (48000 / FRAMES_PER_SEC); jj++) + for ( int jj = 0; jj < ( 48000 / FRAMES_PER_SEC ); jj++ ) { - if (max_val < fabs(p_output[ii][jj])) + if ( max_val < fabs( p_output[ii][jj] ) ) { - max_val = (float)fabs(p_output[ii][jj]); + max_val = (float) fabs( p_output[ii][jj] ); } } } - i_max_val_op = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val_op) - Q10; - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q9; - IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) + i_max_val_op = (int) max_val; + hCPE->hStereoDft->q_dft = norm_l( i_max_val_op ) - Q10; + st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = norm_l( i_max_val_psd ) - Q9; + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; hCPE->hStereoDft->first_frame = 0; } - st_ivas->hCPE[0]->hCoreCoder[0]->stab_fac_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->stab_fac, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact, 15); - floatToFixed_arrL(&hCPE->hStereoDft->res_gains_ind[0][0], &hCPE->hStereoDft->res_gains_ind_fx[0][0], Q26, sizeof(hCPE->hStereoDft->res_gains_ind_fx) / sizeof(hCPE->hStereoDft->res_gains_ind_fx[0][0])); - floatToFixed_arrL(&hCPE->hStereoDft->res_pred_gain[0], &hCPE->hStereoDft->res_pred_gain_fx[0], Q31, sizeof(hCPE->hStereoDft->res_pred_gain_fx)/ sizeof(hCPE->hStereoDft->res_pred_gain_fx[0])); - floatToFixed_arrL(&hCPE->hStereoDft->itd[0], &hCPE->hStereoDft->itd_fx[0], Q1, sizeof(hCPE->hStereoDft->itd_fx) / sizeof(hCPE->hStereoDft->itd_fx[0])); - floatToFixed_arrL(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0])); - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) + st_ivas->hCPE[0]->hCoreCoder[0]->stab_fac_fx = (Word16) floatToFixed( st_ivas->hCPE[0]->hCoreCoder[0]->stab_fac, 15 ); + st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx = (Word16) floatToFixed( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact, 15 ); + st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx = (Word16) floatToFixed( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact, 15 ); + floatToFixed_arrL( &hCPE->hStereoDft->res_gains_ind[0][0], &hCPE->hStereoDft->res_gains_ind_fx[0][0], Q26, sizeof( hCPE->hStereoDft->res_gains_ind_fx ) / sizeof( hCPE->hStereoDft->res_gains_ind_fx[0][0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->res_pred_gain[0], &hCPE->hStereoDft->res_pred_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->res_pred_gain_fx ) / sizeof( hCPE->hStereoDft->res_pred_gain_fx[0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->itd[0], &hCPE->hStereoDft->itd_fx[0], Q1, sizeof( hCPE->hStereoDft->itd_fx ) / sizeof( hCPE->hStereoDft->itd_fx[0] ) ); + floatToFixed_arrL( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0] ) ); + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - if (l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii]) + if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) { l_hb_nrg_subr = hCPE->hStereoDft->hb_nrg_subr[ii]; } } hCPE->hStereoDft->q_hb_nrg_subr = 0; - if (l_hb_nrg_subr > (float)MAX_32) + if ( l_hb_nrg_subr > (float) MAX_32 ) { - int quotient = (int) ceil(l_hb_nrg_subr / (float)MAX_32); - hCPE->hStereoDft->q_hb_nrg_subr = Q31 - norm_l(quotient); + int quotient = (int) ceil( l_hb_nrg_subr / (float) MAX_32 ); + hCPE->hStereoDft->q_hb_nrg_subr = Q31 - norm_l( quotient ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg_subr[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg_subr[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - if (l_hb_nrg < hCPE->hStereoDft->hb_nrg[ii]) + if ( l_hb_nrg < hCPE->hStereoDft->hb_nrg[ii] ) { l_hb_nrg = hCPE->hStereoDft->hb_nrg[ii]; } } hCPE->hStereoDft->q_hb_nrg = 0; - if (l_hb_nrg > (float)MAX_32) + if ( l_hb_nrg > (float) MAX_32 ) { - int quotient = (int) ceil(l_hb_nrg / (float)MAX_32); - hCPE->hStereoDft->q_hb_nrg = Q31 - norm_l(quotient); + int quotient = (int) ceil( l_hb_nrg / (float) MAX_32 ); + hCPE->hStereoDft->q_hb_nrg = Q31 - norm_l( quotient ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - floatToFixed_arrL(&hCPE->hStereoDft->side_gain[0], &hCPE->hStereoDft->side_gain_fx[0], Q31,sizeof(hCPE->hStereoDft->side_gain_fx) / sizeof(hCPE->hStereoDft->side_gain_fx[0])); - floatToFixed_arrL(&hCPE->hStereoDft->gipd[0], &hCPE->hStereoDft->gipd_fx[0], Q13, sizeof(hCPE->hStereoDft->gipd_fx) / sizeof(hCPE->hStereoDft->gipd_fx[0])); - floatToFixed_arr(&hCPE->hStereoDft->g_state[0], &hCPE->hStereoDft->g_state_fx[0], Q15, sizeof(hCPE->hStereoDft->g_state_fx) / sizeof(hCPE->hStereoDft->g_state_fx[0])); - floatToFixed_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0])); - IF (hCPE->hStereoCng != NULL) + floatToFixed_arrL( &hCPE->hStereoDft->side_gain[0], &hCPE->hStereoDft->side_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->side_gain_fx ) / sizeof( hCPE->hStereoDft->side_gain_fx[0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->gipd[0], &hCPE->hStereoDft->gipd_fx[0], Q13, sizeof( hCPE->hStereoDft->gipd_fx ) / sizeof( hCPE->hStereoDft->gipd_fx[0] ) ); + floatToFixed_arr( &hCPE->hStereoDft->g_state[0], &hCPE->hStereoDft->g_state_fx[0], Q15, sizeof( hCPE->hStereoDft->g_state_fx ) / sizeof( hCPE->hStereoDft->g_state_fx[0] ) ); + floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0] ) ); + IF( hCPE->hStereoCng != NULL ) { - floatToFixed_arr(&hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof(hCPE->hStereoCng->cm_fx) / sizeof(hCPE->hStereoCng->cm_fx[0])); + floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - floatToFixed_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0])); - for (int ii = 0; ii < 2; ii++) + floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); + for ( int ii = 0; ii < 2; ii++ ) { - floatToFixed_arrL(&p_output[ii][0], &p_output_fix[ii][0], hCPE->hStereoDft->q_dft , (48000 / FRAMES_PER_SEC)); + floatToFixed_arrL( &p_output[ii][0], &p_output_fix[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } Word16 q = 11; IF( hCPE->hCoreCoder[0] != NULL ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k); - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k); - floatToFixed_arrL(&hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k); - floatToFixed_arrL(&hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k); - floatToFixed_arrL(&hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); + IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) + floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); + floatToFixed_arrL( &hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k ); IF( hCPE->hStereoDft != NULL ) - floatToFixed_arrL(&hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - floatToFixed_arrL(&hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); - floatToFixed_arrL(&hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); + floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); IF( hCPE->hCoreCoder[0] != NULL ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); IF( hCPE->hStereoDft != NULL ) - floatToFixed_arrL(&hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fix, output_frame, st_ivas->ivas_format == MC_FORMAT ); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact = fixedToFloat(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx, 15); - fixedToFloat_arrL(&hCPE->hStereoDft->res_gains_ind_fx[0][0], &hCPE->hStereoDft->res_gains_ind[0][0], Q26, sizeof(hCPE->hStereoDft->res_gains_ind_fx) / sizeof(hCPE->hStereoDft->res_gains_ind_fx[0][0])); - fixedToFloat_arrL(&hCPE->hStereoDft->res_pred_gain_fx[0], &hCPE->hStereoDft->res_pred_gain[0], Q31, sizeof(hCPE->hStereoDft->res_pred_gain_fx)/ sizeof(hCPE->hStereoDft->res_pred_gain_fx[0])); - fixedToFloat_arrL(&hCPE->hStereoDft->itd_fx[0], &hCPE->hStereoDft->itd[0], Q1, sizeof(hCPE->hStereoDft->itd_fx) / sizeof(hCPE->hStereoDft->itd_fx[0])); - fixedToFloat_arrL(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0])); - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) + st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); + st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx, 15 ); + fixedToFloat_arrL( &hCPE->hStereoDft->res_gains_ind_fx[0][0], &hCPE->hStereoDft->res_gains_ind[0][0], Q26, sizeof( hCPE->hStereoDft->res_gains_ind_fx ) / sizeof( hCPE->hStereoDft->res_gains_ind_fx[0][0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->res_pred_gain_fx[0], &hCPE->hStereoDft->res_pred_gain[0], Q31, sizeof( hCPE->hStereoDft->res_pred_gain_fx ) / sizeof( hCPE->hStereoDft->res_pred_gain_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->itd_fx[0], &hCPE->hStereoDft->itd[0], Q1, sizeof( hCPE->hStereoDft->itd_fx ) / sizeof( hCPE->hStereoDft->itd_fx[0] ) ); + fixedToFloat_arrL( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0] ) ); + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr[0] = ((float)hCPE->hStereoDft->hb_nrg_subr_fx[0] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr[0] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[0] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg[ii] = ((float)hCPE->hStereoDft->hb_nrg_fx[ii] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - fixedToFloat_arrL(&hCPE->hStereoDft->side_gain_fx[0], &hCPE->hStereoDft->side_gain[0], Q31,sizeof(hCPE->hStereoDft->side_gain_fx) / sizeof(hCPE->hStereoDft->side_gain_fx[0])); - fixedToFloat_arrL(&hCPE->hStereoDft->gipd_fx[0], &hCPE->hStereoDft->gipd[0], Q13, sizeof(hCPE->hStereoDft->gipd_fx) / sizeof(hCPE->hStereoDft->gipd_fx[0])); - fixedToFloat_arr(&hCPE->hStereoDft->g_state_fx[0], &hCPE->hStereoDft->g_state[0], Q15, sizeof(hCPE->hStereoDft->g_state_fx) / sizeof(hCPE->hStereoDft->g_state_fx[0])); - fixedToFloat_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0])); - IF (hCPE->hStereoCng != NULL) + fixedToFloat_arrL( &hCPE->hStereoDft->side_gain_fx[0], &hCPE->hStereoDft->side_gain[0], Q31, sizeof( hCPE->hStereoDft->side_gain_fx ) / sizeof( hCPE->hStereoDft->side_gain_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->gipd_fx[0], &hCPE->hStereoDft->gipd[0], Q13, sizeof( hCPE->hStereoDft->gipd_fx ) / sizeof( hCPE->hStereoDft->gipd_fx[0] ) ); + fixedToFloat_arr( &hCPE->hStereoDft->g_state_fx[0], &hCPE->hStereoDft->g_state[0], Q15, sizeof( hCPE->hStereoDft->g_state_fx ) / sizeof( hCPE->hStereoDft->g_state_fx[0] ) ); + fixedToFloat_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0] ) ); + IF( hCPE->hStereoCng != NULL ) { - fixedToFloat_arr(&hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof(hCPE->hStereoCng->cm_fx) / sizeof(hCPE->hStereoCng->cm_fx[0])); + fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - fixedToFloat_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0])); - fixedToFloat_arrL(&hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q15, sizeof(hCPE->hStereoDft->td_gain_fx) / sizeof(hCPE->hStereoDft->td_gain_fx[0])); - for (int ii = 0; ii < 2; ii++) + fixedToFloat_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q15, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + for ( int ii = 0; ii < 2; ii++ ) { - fixedToFloat_arrL(&p_output_fix[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, (48000 / FRAMES_PER_SEC)); + fixedToFloat_arrL( &p_output_fix[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } IF( hCPE->hCoreCoder[0] != NULL ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k); - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k); - fixedToFloat_arrL(&hCPE->input_mem_BPF_fx[0][0], &hCPE->input_mem_BPF[0][0], q, STEREO_DFT32MS_OVL_16k); - fixedToFloat_arrL(&hCPE->input_mem_fx[0][0], &hCPE->input_mem[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k); - fixedToFloat_arrL(&hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); + IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); + fixedToFloat_arrL( &hCPE->input_mem_BPF_fx[0][0], &hCPE->input_mem_BPF[0][0], q, STEREO_DFT32MS_OVL_16k ); + fixedToFloat_arrL( &hCPE->input_mem_fx[0][0], &hCPE->input_mem[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k ); + fixedToFloat_arrL( &hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k ); IF( hCPE->hStereoDft != NULL ) - fixedToFloat_arrL(&hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - fixedToFloat_arrL(&hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); - fixedToFloat_arrL(&hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); IF( hCPE->hCoreCoder[0] != NULL ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); IF( hCPE->hStereoDft != NULL ) - fixedToFloat_arrL(&hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); + fixedToFloat_arrL( &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); } #endif } @@ -1003,7 +1004,7 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED #if 1 - Word32* p_output_fx[12]; + Word32 *p_output_fx[12]; Word16 Q_sba = 31; FOR( Word16 lp = 0; lp < 12; lp++ ) { @@ -1021,10 +1022,10 @@ ivas_error ivas_jbm_dec_tc( floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif - nchan_remapped = ivas_sba_remapTCs_fx(p_output_fx, st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); FOR( Word16 i = 2; i <= 3; i++ ) { - fixedToFloat_arrL(p_output_fx[i], p_output[i], Q_sba, output_frame ); + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { @@ -1412,18 +1413,18 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for (int i = 0; i < output_frame; i++) - { - p_output_fix[i] = (Word32)(p_output[n][i] * (1 << 11)); - } - hp20_fix32(p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs); - for (int i = 0; i < output_frame; i++) - { - p_output[n][i] = (float)p_output_fix[i] / (1 << 11); - } + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } #else - hp20_flt(p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs); + hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED } @@ -1567,7 +1568,7 @@ ivas_error ivas_jbm_dec_tc( } } #endif - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ,&Q_mixer_mat); + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, &Q_mixer_mat ); #if 1 /*Fixed to float changes */ FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { @@ -1586,7 +1587,7 @@ ivas_error ivas_jbm_dec_tc( { FOR( j = 0; j < output_frame; j++ ) { - p_output[sba_ch_idx+c][j] = (float) output_fx[c][j]; + p_output[sba_ch_idx + c][j] = (float) output_fx[c][j]; } } FOR( Word16 c = 0; c < nchan_transport; c++ ) @@ -1699,7 +1700,7 @@ ivas_error ivas_jbm_dec_tc( #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED - } + } } if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) @@ -1709,9 +1710,9 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[12]; - FOR ( Word16 lp = 0; lp < 12; lp++ ) + FOR( Word16 lp = 0; lp < 12; lp++ ) { - IF ( p_output[lp] != NULL ) + IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } @@ -1728,13 +1729,13 @@ ivas_error ivas_jbm_dec_tc( #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); #if 1 - FOR ( i = 0; i < ( st_ivas->hIntSetup.ambisonics_order + 1 ) * ( st_ivas->hIntSetup.ambisonics_order + 1 ); i++ ) + FOR( i = 0; i < ( st_ivas->hIntSetup.ambisonics_order + 1 ) * ( st_ivas->hIntSetup.ambisonics_order + 1 ); i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { - IF ( p_output[lp] != NULL ) + IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } @@ -1826,7 +1827,7 @@ ivas_error ivas_jbm_dec_tc( #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED - } + } } /* Rendering */ @@ -1928,7 +1929,7 @@ ivas_error ivas_jbm_dec_tc( #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED - } + } /* Rendering */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) @@ -2245,7 +2246,7 @@ ivas_error ivas_jbm_dec_tc( #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED - } + } if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { @@ -2329,7 +2330,7 @@ ivas_error ivas_jbm_dec_tc( pop_wmops(); - + return IVAS_ERR_OK; } @@ -2676,7 +2677,7 @@ ivas_error ivas_jbm_dec_render( Word32 *p_output_fx[20]; FOR( Word16 lp = 0; lp < 20; lp++ ) { - IF ( p_output[lp] != NULL ) + IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } @@ -2693,9 +2694,9 @@ ivas_error ivas_jbm_dec_render( #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); #if 1 - FOR( i = 0; i < (st_ivas->hOutSetup.ambisonics_order + 1 ) * (st_ivas->hOutSetup.ambisonics_order + 1 ); i++ ) + FOR( i = 0; i < ( st_ivas->hOutSetup.ambisonics_order + 1 ) * ( st_ivas->hOutSetup.ambisonics_order + 1 ); i++ ) { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, *nSamplesRendered); + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, *nSamplesRendered ); } FOR( Word16 lp = 0; lp < 20; lp++ ) { @@ -2894,7 +2895,7 @@ ivas_error ivas_jbm_dec_render( for ( j = 0; j < *nSamplesRendered; j++ ) { - p_temp_fx[i][j] = (Word32)float_to_fixed( p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); + p_temp_fx[i][j] = (Word32) float_to_fixed( p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); } } if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_temp_fx, p_temp_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) @@ -3406,7 +3407,37 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER +#ifdef IVAS_FLOAT_FIXED + Word16 ch_idx; + exp = 16; + for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) + { + + p_output_fx[ch_idx] = tmp_buffer_fx[ch_idx]; + } + for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) + { + exp = s_min( exp , Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); + } + exp -= 2; + for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) + { + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] * ( 1 << exp ) ); + } + } + ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); + for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) + { + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); + } + } +#else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); + #endif #endif } } @@ -3804,7 +3835,39 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER +#ifdef IVAS_FLOAT_FIXED + Word16 ch_idx; + exp = 16; + for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) + { + + p_output_fx[ch_idx] = output_fx[ch_idx]; + } + for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) + { + exp = s_min( exp, Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); + } + exp -= 1; + for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) + { + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] *(1<< exp) ) ; + } + } + ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); + for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) + { + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output[ch_idx][j] = ( (float) p_output_fx[ch_idx][j] / ( 1 << exp ) ); + } + } +#else + ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); + +#endif #endif } } @@ -5411,51 +5474,51 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2; UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; - //nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; - tmp = BASOP_Util_Divide3216_Scale(st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &exp); - tmp = shr(tmp, -1 - exp ); - tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp); + // nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &exp ); + tmp = shr( tmp, -1 - exp ); + tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp ); nMaxSlotsPerSubframe = shr( tmp, ( 15 - exp ) ); - //nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - tmp = BASOP_Util_Divide1616_Scale(st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp); + // nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); nSlotsAvailable = shr( tmp, ( 15 - exp ) ); st_ivas->hTcBuffer->num_slots = nSlotsAvailable; move16(); - //st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; + // st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity ); nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); st_ivas->hTcBuffer->nb_subframes = 0; move16(); - IF ( nSlotsInFirstSubframe > 0 ) + IF( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; nSlotsAvailable -= nSlotsInFirstSubframe; } - //st_ivas->hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe ); - s1 = norm_s(nSlotsAvailable) - 1; - s2 = norm_s(nMaxSlotsPerSubframe); + // st_ivas->hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe ); + s1 = norm_s( nSlotsAvailable ) - 1; + s2 = norm_s( nMaxSlotsPerSubframe ); tmp1 = shl( nSlotsAvailable, s1 ); tmp2 = shl( nMaxSlotsPerSubframe, s2 ); - tmp = div_s(tmp1, tmp2); - st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16(tmp, ( 15 - ( s2 - s1 ) ) ) ); + tmp = div_s( tmp1, tmp2 ); + st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, ( 15 - ( s2 - s1 ) ) ) ); nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); - IF ( nSlotsInFirstSubframe > 0 ) + IF( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; move16(); } - IF ( nSlotsInLastSubframe > 0 ) + IF( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; move16(); @@ -5784,7 +5847,7 @@ ivas_error ivas_jbm_dec_metadata_open( #ifdef IVAS_FLOAT_FIXED { JBM_METADATA_HANDLE hJbmMetadata; - IF ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL ) + IF( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) ); } @@ -5825,7 +5888,6 @@ ivas_error ivas_jbm_dec_metadata_open( #endif - /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_masa_meta_to_buffer() * @@ -5844,13 +5906,13 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( hJbmMetadata = st_ivas->hJbmMetadata; extOutMeta = st_ivas->hMasa->data.extOutMeta; - FOR ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length; move16(); - FOR ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) { - FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band]; move16(); @@ -5859,7 +5921,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( } } - FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band]; hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band]; @@ -5908,7 +5970,6 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( #endif - /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_slot_map() * @@ -5918,7 +5979,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef IVAS_FLOAT_FIXED - const Word16 nCldfbTs /* i : number of CLDFB time slots */ + const Word16 nCldfbTs /* i : number of CLDFB time slots */ ) { Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME]; @@ -5935,7 +5996,7 @@ static void ivas_jbm_masa_sf_to_slot_map( /* Map input subframes to slots */ ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); - FOR ( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ ) { write_idx = ( add( hJbmMetadata->slot_write_idx, slot_idx ) ) % hJbmMetadata->slot_md_buffer_length; move16(); @@ -5954,7 +6015,7 @@ static void ivas_jbm_masa_sf_to_slot_map( return; } #else - const int16_t nCldfbTs /* i : number of CLDFB time slots */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ) { int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME]; @@ -6010,7 +6071,7 @@ void ivas_jbm_masa_sf_to_sf_map( extOutMeta = st_ivas->hMasa->data.extOutMeta; /* Map slots to subframes */ - FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { slot_read_idx = ( add( hJbmMetadata->slot_read_idx, 2 ) ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */ move16(); @@ -6021,14 +6082,14 @@ void ivas_jbm_masa_sf_to_sf_map( } /* Copy mapped metadata to the EXT meta buffer for writing */ - FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { sf_read_idx = sf_to_sf_map[sf_idx]; move16(); - FOR ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) { - FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band]; move16(); @@ -6037,7 +6098,7 @@ void ivas_jbm_masa_sf_to_sf_map( } } - FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band]; extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band]; @@ -6046,12 +6107,12 @@ void ivas_jbm_masa_sf_to_sf_map( /* Determine the number of directions for the frame to be written */ numberOfDirections = 0; - FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { sf_read_idx = sf_to_sf_map[sf_idx]; move16(); - IF ( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 ) + IF( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 ) { numberOfDirections = 1; BREAK; @@ -6062,7 +6123,7 @@ void ivas_jbm_masa_sf_to_sf_map( return; } -#else +#else { int16_t sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES]; JBM_METADATA_HANDLE hJbmMetadata; diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 1d6e3786b8702bd4d124a9e0ebd985340d902d14..0ac0e60cf6a8052aa8a1411b045d9b01f3856a42 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -160,21 +160,21 @@ static Word16 detect_strong_saturations_fx( ) { Word16 apply_strong_limiting; - Word32 compare_max_value_Mul_3, compare_max_value_Mul_10; + Word64 compare_max_value_Mul_3, compare_max_value_Mul_10; apply_strong_limiting = 0; - compare_max_value_Mul_3 = L_lshl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD - compare_max_value_Mul_10 = L_lshl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD + compare_max_value_Mul_3 = W_shl(98187,q_factor); // 3 * IVAS_LIMITER_THRESHOLD + compare_max_value_Mul_10 = W_shl( 327290, q_factor );//10 * IVAS_LIMITER_THRESHOLD IF ( BER_detect ) { *strong_saturation_cnt = 50; apply_strong_limiting = 1; } - ELSE IF( GT_32( max_val , compare_max_value_Mul_3) && GT_16(*strong_saturation_cnt , 0 )) + ELSE IF( GT_64( max_val, compare_max_value_Mul_3 ) && GT_16( *strong_saturation_cnt, 0 ) ) { apply_strong_limiting = 1; } - ELSE IF( GT_32 (max_val , compare_max_value_Mul_10) ) + ELSE IF( GT_64( max_val, compare_max_value_Mul_10 ) ) { *strong_saturation_cnt += 20; *strong_saturation_cnt = min( *strong_saturation_cnt, 50 ); @@ -371,6 +371,47 @@ void ivas_limiter_close( return; } #endif +#ifdef IVAS_FLOAT_FIXED +/*-------------------------------------------------------------------* + * ivas_limiter_dec() + * + * In-place saturation control for multichannel buffers with adaptive + * release time and special handling of bit errors + *-------------------------------------------------------------------*/ + +void ivas_limiter_dec_fx( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + const Word16 num_channels, /* i : number of channels to be processed */ + const Word16 output_frame, /* i : number of samples per channel in the buffer */ + const Word16 BER_detect, /* i : BER detect flag */ + Word16 q_factor +) +{ + Word16 c; + Word32 **channels; + + /* return early if given bad parameters */ + IF ( hLimiter == NULL || output == NULL || output_frame <= 0 ) + { + return; + } + + /* Update number of channels and prepare pointers to the beginning of each of them */ + assert( num_channels <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" ); + hLimiter->num_channels = min( num_channels, hLimiter->max_num_channels ); + channels = hLimiter->channel_ptrs_fx; + + FOR ( c = 0; c < num_channels; ++c ) + { + channels[c] = output[c]; + } + Word32 limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, q_factor ); + limiter_process_fx( hLimiter, output_frame, limiter_thresold, BER_detect, &hLimiter->strong_saturation_count, q_factor ); + + return; +} +#endif /*-------------------------------------------------------------------* * ivas_limiter_dec() @@ -410,7 +451,6 @@ void ivas_limiter_dec( return; } - #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * limiter_process() @@ -500,6 +540,7 @@ void limiter_process_fx( } releaseHeuristic = hLimiter->release_heuristic_fx; q_fact_gain = Q30; + IF (GT_32( max_val , threshold) ) { frame_gain = L_shl(divide3232( threshold, max_val ),15);//to q30 @@ -562,7 +603,7 @@ void limiter_process_fx( /*-----------------------------------------------------------------* * Apply limiting *-----------------------------------------------------------------*/ - + FOR ( i = 0; i < output_frame; i++ ) { /* Update gain */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 022c3279faf977c50d5e24754fb05ccc95f31932..bf8c6d0140579a4cb2cbc67f747c520015aaa6d7 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -119,7 +119,17 @@ void ivas_limiter_dec const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ ); - +#ifdef IVAS_FLOAT_FIXED +void ivas_limiter_dec_fx +( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + const Word16 num_channels, /* i : number of channels to be processed */ + const Word16 output_frame, /* i : number of samples per channel in the buffer */ + const Word16 BER_detect, /* i : BER detect flag */ + Word16 q_factor +); +#endif void limiter_process( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */