diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index efcc4b731c3781eb01a3f672c2f06bd3fa57f087..e3cf6f5e827df10d34e362f26860eb80c17b0e95 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -274,7 +274,11 @@ void tcx_arith_scale_envelope( tmp2 = BASOP_Util_Add_MantExp(negate(b), b_e, tmp, tmp2, &scale); scale = BASOP_Util_Divide1616_Scale(scale, round_fx(a), &tmp); +#ifdef BASOP_NOGLOB + scale = shl_o(scale, sub(sub(add(tmp, tmp2), a_e), 1), &Overflow); /* Q15 */ +#else scale = shl(scale, sub(sub(add(tmp, tmp2), a_e), 1)); /* Q15 */ +#endif /* iscale = 1.0f / scale; */ iscale_e = 0; diff --git a/lib_com/count.c b/lib_com/count.c index 2ee28cee4245744970c120e0806b48fe4ee2af58..664ebeef203d5f3a8e28c8cb5e5df15196d3ecb9 100644 --- a/lib_com/count.c +++ b/lib_com/count.c @@ -48,6 +48,7 @@ #include #include "stl.h" #include + #ifdef WMOPS static double frameRate = FRAME_RATE; /* default value : 10 ms */ #endif /* ifdef WMOPS */ @@ -854,9 +855,11 @@ void generic_WMOPS_output (Word16 dtx_mode, char *test_file_name) { /* FROM_EVS_DEV */ #define MAX_STACK 64 +#if WMOPS static int stack[MAX_STACK]; static int sptr; static int sum_stack[MAX_STACK]; +#endif /* jdr 20120117: add FLC similar functions */ void BASOP_frame_update(void) @@ -1062,6 +1065,7 @@ void BASOP_push_wmops (const char *label) #endif #endif /* if WMOPS */ + UNUSED_PARAM(label); } @@ -1115,7 +1119,9 @@ Word32 BASOP_get_wops (void) #define MILLION_CYCLES 1e6 #define FAC (FRAMES_PER_SECOND/MILLION_CYCLES) +#if WMOPS static Word32 prom_cnt = 0; +#endif void WMOPS_destroy(void) { @@ -1292,6 +1298,7 @@ void WMOPS_output_all(Word16 dtx_mode) WMOPS_destroy(); #endif /* if WMOPS */ + UNUSED_PARAM(dtx_mode); } void WMOPS_output_all_std(Word16 dtx_mode) { @@ -1392,6 +1399,7 @@ void WMOPS_output_all_std(Word16 dtx_mode) WMOPS_destroy(); #endif /* if WMOPS */ + UNUSED_PARAM(dtx_mode); } @@ -1431,6 +1439,8 @@ void BASOP_get_total_wmops(double *min, double *max, double *avg) *avg = (nbframe[0] == 0) ? 0 : ops_cnt / nbframe[0]; } #endif /* if WMOPS */ + UNUSED_PARAM(min); + UNUSED_PARAM(max); + UNUSED_PARAM(avg); } - /* end of file */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index a0150c20b5d2b3244c42e5c5c168458dfa93fa3f..5bfd30572e934e80f298bbed6780c63ec6438e11 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -258,8 +258,8 @@ void Inac_switch_ematch_ivas_fx( FOR(j = 0; j < 8; j++) { L_tmp = L_mult0(*pt_exc, ftmp); - L_tmp = L_shl(L_tmp, add(exp, 15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx(L_tmp); /*Q_exc - 1*/ + L_tmp = L_shl_sat(L_tmp, add(exp, 15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat(L_tmp); /*Q_exc - 1*/ pt_exc++; } } @@ -268,8 +268,8 @@ void Inac_switch_ematch_ivas_fx( FOR(j = 0; j < 16; j++) { L_tmp = L_mult0(*pt_exc,ftmp); - L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx(L_tmp); /*Q_exc - 1*/ + L_tmp = L_shl_sat(L_tmp, add(exp,15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat(L_tmp); /*Q_exc - 1*/ pt_exc++; } } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 42ef2c05f1dd8704b1d67e69def33182bb8cfb7a..290ef3f88013b93bf293f7b90f396e784870a223 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -6723,7 +6723,7 @@ void ivas_ls_setup_conversion_process_mdct( void ivas_ls_setup_conversion_process_mdct_param_mc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *x_fx[][NB_DIV], /* i/o: Fixed output synthesis signal */ - Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]/* i/o: Exponent for output synthesis signal */ + Word16 x_e[CPE_CHANNELS][NB_DIV]/* i/o: Exponent for output synthesis signal */ ); #endif // IVAS_FLOAT_FIXED @@ -7234,6 +7234,7 @@ void ivas_merge_masa_transports( const int16_t num_transport_channels /* i : Number of transport audio signals */ ); +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_omasa_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); @@ -7241,6 +7242,7 @@ ivas_error ivas_omasa_data_open( void ivas_omasa_data_close( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); +#endif ivas_error ivas_omasa_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4d63129c5f5d48addac2029e4a91d7d03f8e3f60..814fde0dda1b8c87a33cb33cdf5699214f2211d5 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1399,7 +1399,7 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ Word32 Aq_fx[CPE_CHANNELS][(NB_SUBFR16k + 1) * (M + 1)], /* o : LP coefficients */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - Word16 x_e[MAX_CICP_CHANNELS][NB_DIV] + Word16 x_e[CPE_CHANNELS][NB_DIV] ); void decoder_tcx_imdct_fx( @@ -2185,4 +2185,19 @@ void ivas_param_mc_dec_read_BS_fx( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: decoder ParamMC handle */ Word16 *nb_bits /* o : number of bits written */ ); + +ivas_error ivas_omasa_data_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); + +void ivas_omasa_data_close_fx( + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ +); + +ivas_error ivas_mc_dec_config_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 idx, /* i : LS config. index */ + UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ + Word16 *data /* o : output synthesis signal */ +); #endif diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 3b70fb63b7dbeae46e92d667aa46d403452ac603..dfe9942a518370cb359fbb794d64e4d98152fcaa 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -445,6 +445,12 @@ typedef struct ivas_masa_directional_spatial_meta_struct float elevation[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float spread_coherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#ifdef IVAS_FLOAT_FIXED + Word32 azimuth_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 elevation_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 spread_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#endif uint16_t spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_DIRECTIONAL_SPATIAL_META; @@ -453,6 +459,11 @@ typedef struct ivas_masa_common_spatial_meta_struct { float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float surround_coherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#ifdef IVAS_FLOAT_FIXED + Word32 diffuse_to_total_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 surround_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 remainder_to_total_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#endif float remainder_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_COMMON_SPATIAL_META; diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 453c686630a33388e7e77d4863e84cd181a705a1..abda175519b211b657276f96e9ba273978c7a518 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -195,7 +195,7 @@ static void lerp_proc_flt( * Local function prototypes *-------------------------------------------------------------*/ -static void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize); +static void lerp_proc(const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize); /*-------------------------------------------------------------* * procedure lerp() * @@ -203,7 +203,7 @@ static void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 buf * * *-------------------------------------------------------------*/ -void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) +void lerp(const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) { Word16 tmp1, tmp2, tmpexp; BASOP_Util_Divide_MantExp(bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp); @@ -267,7 +267,7 @@ void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) * * * * *-------------------------------------------------------------*/ -static void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) +static void lerp_proc(const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize) { Word16 i, idx, n; diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index b3535e585dc30143e1f96ac55092da30ff70e144..cedbc4b7d4c76e316f02454c333c33bf68c9fdd4 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -2247,7 +2247,7 @@ void ivas_synth_mem_updt2_fx( //lerp.c -void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize); +void lerp(const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize); void L_lerp_fx_q11( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ); diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index 5adb0348fd16c8f65f74e774a7be6464871a1a08..3351c99b726dfbfbcb13b91e61e98fff51c75678 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -160,7 +160,7 @@ void mdct_window_sine_IVAS_updated( } else { - lerp((Word16 *)window_table, temp, n, buf_in_size); + lerp(window_table, temp, n, buf_in_size); } for (int i = 0; i < n / 2; i++) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 7787b442081e6143dbf1f01bb6a2eaba46d711e9..ef617eed6d681b0196dfb5ccfd84c8d48725c7be 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1886,6 +1886,9 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif } } diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index f0afb5983b741723466be582615c49557320fa56..11e1fb89ae556a0d3ae5b09ae4f6cfef1328bbc3 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -130,6 +130,9 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif } IF( st->hBWE_FD != NULL ) @@ -450,6 +453,9 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif } IF( st->hBWE_FD != NULL ) @@ -501,6 +507,9 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( GT_32(st->output_Fs , 16000) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif } IF( st->hBWE_FD != NULL ) @@ -1940,7 +1949,9 @@ void ivas_bw_switching_pre_proc_fx( IF ( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q , st->L_frame ); + Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; + Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); + st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); } return; diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 3aece14b8f4d7b02b85ea69a7d15399ec66bfd18..22ae6ea998e66409cdfbb9815002b8dc4bbec608 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1760,7 +1760,10 @@ Word16 ApplyFdCng_ivas_fx( } s2 = s_max( s2, facTabExp[k] ); } - + IF(EQ_16(s2, -31)) + { + s2 = 0; move16(); + } FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) { s = sub( facTabExp[k], s2 ); @@ -1833,7 +1836,10 @@ Word16 ApplyFdCng_ivas_fx( } s2 = s_max( s2, facTabExp[k] ); } - + IF(EQ_16(s2, -31)) + { + s2 = 0; move16(); + } FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) { s = sub( facTabExp[k], s2 ); @@ -2705,27 +2711,40 @@ void perform_noise_estimation_dec_ivas_fx( Word16 scale; /* no updates during active frames except for significant energy drops */ enr_ratio = BASOP_Util_Divide3232_Scale( enr_tot, enr_tot0, &scale ); - IF( GE_16( scale, 0 ) ) + IF( LE_16( scale, 0 ) ) { - enr_ratio = shr( enr_ratio, scale ); + enr_ratio = shl( enr_ratio, scale ); + scale = 15; move16(); } ELSE { - enr_ratio = shr( enr_ratio, sub( 15, scale ) ); + scale = sub(15, scale); } - IF( LT_16( enr_ratio, ONE_IN_Q14 ) ) + IF( LT_16( enr_ratio, shl(1, sub(scale, 1)) ) ) { /* total energy significantly decreases during active frames -> downward update */ - wght = lin_interp_fx( enr_ratio, 0, 26214 /*0.8f in Q15*/, 16384 /*0.5f in Q15*/, 31130 /*0.95f in Q15*/, 32767 /*1 in Q15*/ ); - + wght = lin_interp_fx( enr_ratio, 0, shr(26214, sub(15, scale)) /*0.8f in Q15*/, shr(16384, sub(15, scale)) /*0.5f in Q15*/, shr(31130, sub(15, scale)) /*0.95f in Q15*/, shr(32767, sub(15, scale)) /*1 in Q15*/ ); + Word16 temp_q_msNoiseEst[NPART_SHAPING]; + Word16 min_q_msNoiseEst = MAX_16; + FOR(p = 0; p < NPART_SHAPING; p++) + { + temp_q_msNoiseEst[p] = hFdCngDec->msNoiseEst_exp; move16(); + } FOR( p = 0; p < npart; p++ ) { L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) ); IF( LT_32( L_tmp, msNoiseEst[p] ) ) { - msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( ONE_IN_Q15, wght ) ) ); + msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( shr(MAX_16, sub(15, scale)), wght ) ) ); + temp_q_msNoiseEst[p] = sub(add(hFdCngDec->msNoiseEst_exp, scale), 15); } + min_q_msNoiseEst = s_min(temp_q_msNoiseEst[p], min_q_msNoiseEst); + } + FOR(p = 0; p < NPART_SHAPING; p++) + { + msNoiseEst[p] = L_shl(msNoiseEst[p], sub(min_q_msNoiseEst, temp_q_msNoiseEst[p])); } + hFdCngDec->msNoiseEst_exp = min_q_msNoiseEst; move16(); } ELSE { diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 6c4c75e86bf5532a64197cf5f71576157e487c7e..f1f010f5bb1bfe476937b2dcf3778409ee9b1e40 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -91,7 +91,8 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } - + h_dirac_output_synthesis_params->proto_matrix_len = nchan_out * nchan_in; + move16(); /* cov buffers */ for ( idx = 0; idx < num_param_bands; idx++ ) { @@ -209,11 +210,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( /* cov buffers */ for ( idx = 0; idx < num_param_bands; idx++ ) { - if ( ( h_dirac_output_synthesis_state->mixing_matrix_old[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } - set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) { @@ -223,18 +219,11 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( } for ( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - h_dirac_output_synthesis_state->mixing_matrix_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; } for ( idx = 0; idx < num_param_bands_residual; idx++ ) { - if ( ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } - set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); - if ( ( h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); @@ -243,7 +232,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( } for ( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix_res[idx] = NULL; } @@ -471,13 +459,11 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( #if 1/*TODO: To be removed :Floating point initializations*/ FOR ( idx = 0; idx < n_param_bands; idx++ ) { - set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); } FOR ( idx = 0; idx < n_param_bands_res; idx++ ) { - set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); } #endif @@ -655,19 +641,6 @@ void ivas_dirac_dec_output_synthesis_cov_close_fx( /* free cov buffers */ FOR ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - - IF ( h_dirac_output_synthesis_state->mixing_matrix_old[idx] != NULL ) - { - free( h_dirac_output_synthesis_state->mixing_matrix_old[idx] ); - h_dirac_output_synthesis_state->mixing_matrix_old[idx] = NULL; - } - - IF ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] != NULL ) - { - free( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] ); - h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; - } - IF ( h_dirac_output_synthesis_state->mixing_matrix[idx] != NULL ) { free( h_dirac_output_synthesis_state->mixing_matrix[idx] ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ac39d5247f3b6b896a81d4ce9075ba4886c7409e..e875c9dce67d12d75fb928af85bc3fda532ae7d0 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -241,14 +241,6 @@ ivas_error ivas_dec_setup( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -294,16 +286,6 @@ ivas_error ivas_dec_setup( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ } } - // fix2float (to be cleaned) - IF((LT_32(hDecoderConfig->ivas_total_brate, IVAS_24k4)) && ((EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2)) || (EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3)))) - { - fixedToFloat_arr(hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS); - FOR(Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) - { - fixedToFloat_arrL(hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); - } - } - // fix2float end FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) { IF(st_ivas->cldfbSynDec[out_ch]) @@ -591,10 +573,52 @@ ivas_error ivas_dec_setup( num_bits_read = add(num_bits_read, MC_LS_SETUP_BITS); /* select MC format mode; reconfigure the MC format decoder */ + +#ifndef IVAS_FLOAT_FIXED IF ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } +#else +#if 1 /*TODO: To be removed(Float to fixed conversion)*/ + IF(st_ivas->hTcBuffer) + FOR ( int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) + { + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); + } + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + if ( st_ivas->hParamMC ) + { + if ( st_ivas->hParamMC->diff_proto_info ) + FOR( Word16 i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + floatToFixed_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac[i], st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], Q26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); + } + } + } +#endif + IF ( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + if ( st_ivas->hParamMC ) + { + fixedToFloat_arrL( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len ); + IF( st_ivas->hParamMC->diff_proto_info ) + FOR( Word16 i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + fixedToFloat_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], st_ivas->hParamMC->diff_proto_info->proto_fac[i], 26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); + } + if ( st_ivas->hParamMC->hoa_encoder_fx ) + fixedToFloat_arrL( st_ivas->hParamMC->hoa_encoder_fx, st_ivas->hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); + } + } +#endif +#endif } /*-------------------------------------------------------------------* @@ -1829,7 +1853,7 @@ ivas_error ivas_init_decoder_fx( return error; } - IF ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1956,6 +1980,8 @@ ivas_error ivas_init_decoder_fx( { return error; } + + st_ivas->hParamMC->proto_matrix_int_e = 0; #if 1/*Fixed to float conversions*/ PARAM_MC_DEC_HANDLE hParamMC; hParamMC = st_ivas->hParamMC; @@ -1982,19 +2008,6 @@ ivas_error ivas_init_decoder_fx( { fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); } - //if ( st_ivas->hLsSetUpConversion ) - //{ - // for ( k = 0; k < nchan_transport; k++ ) - // { - // for ( i = 0; i < nchan_out_cov; i++ ) - // { - // st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); - // } - // } - //} - fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, s_min(hParamMC->proto_matrix_int_len, nchan_out_transport * nchan_transport) ); - //if ( hParamMC->ls_conv_dmx_matrix ) - // fixedToFloat_arrL( hParamMC->ls_conv_dmx_matrix_fx, hParamMC->ls_conv_dmx_matrix, Q30, nchan_out_transport * nchan_out_cov ); if ( hParamMC->hoa_encoder_fx ) fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); } @@ -2462,7 +2475,6 @@ ivas_error ivas_init_decoder_fx( return error; } - set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN ); set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k ); @@ -4182,7 +4194,11 @@ void ivas_destroy_dec( #endif /* OMASA structure */ +#ifdef IVAS_FLOAT_FIXED + ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); +#else ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3e52052fafeace6013d76eb4766d24a43413dcf8..6eade55534d97e3cb6bc4fd6f332fa7885971f1e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3919,9 +3919,14 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_out_cov = nchan_out_transport; } f2me_buf(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport); - f2me_buf(st_ivas->hParamMC->proto_matrix_int, st_ivas->hParamMC->proto_matrix_int_fx, &st_ivas->hParamMC->proto_matrix_int_e, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_transport * nchan_out_transport)); + + scale_sig32(st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1); + st_ivas->hParamMC->proto_matrix_int_e = 1; ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, (Word32 **)p_data_f_fx, in_q ); + + scale_sig32(st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1); + Word16 shift; FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++) { @@ -4760,16 +4765,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -4841,14 +4836,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -4890,16 +4877,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5042,14 +5019,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5077,16 +5046,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5132,14 +5091,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5167,16 +5118,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5221,14 +5162,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5256,14 +5189,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -5734,7 +5659,6 @@ ivas_error ivas_jbm_dec_render( IF(st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr) { f2me_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], &st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], nchan_out_cov * nchan_out_cov); - f2me_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], &st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx], nchan_out_cov * nchan_out_cov); } } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 64f125f309534eecfdd6b34e642516c77f46bd39..4d13c40493701de8694302f4da7f8222adc90131 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -394,10 +394,6 @@ ivas_error ivas_param_mc_dec_open_fx( } Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, nchan_transport * nchan_out_transport );/*Q31*/ - if ( ( hParamMC->proto_matrix_int = (float *) malloc( nchan_out_transport * nchan_transport * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } hParamMC->proto_matrix_int_len = nchan_out_transport * nchan_transport; move16(); @@ -1467,13 +1463,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( IF ( NE_16(nchan_transport_old , nchan_transport) ) { -#if 1 - free( hParamMC->proto_matrix_int ); - IF ( ( hParamMC->proto_matrix_int = (float *) malloc( nchan_out_transport * nchan_transport * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif free( hParamMC->proto_matrix_int_fx ); IF ( ( hParamMC->proto_matrix_int_fx = (Word32 *) malloc( nchan_out_transport * nchan_transport * sizeof(Word32) ) ) == NULL ) { @@ -2475,13 +2464,6 @@ void ivas_param_mc_dec_close_fx( hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */ - - IF( hParamMC->proto_matrix_int != NULL ) - { - free( hParamMC->proto_matrix_int ); - hParamMC->proto_matrix_int = NULL; - } - IF( hParamMC->proto_frame_f != NULL ) { free( hParamMC->proto_frame_f ); @@ -2492,11 +2474,6 @@ void ivas_param_mc_dec_close_fx( free( hParamMC->proto_frame_dec_f ); hParamMC->proto_frame_dec_f = NULL; } - //IF( hParamMC->ls_conv_dmx_matrix != NULL ) - //{ - // free( hParamMC->ls_conv_dmx_matrix ); - // hParamMC->ls_conv_dmx_matrix = NULL; - //} IF( hParamMC->hoa_encoder != NULL ) { free( hParamMC->hoa_encoder ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a4bf16d6c3798cb56105781c331825eed77509ab..039e42cfab5b832f6744b0b3b9b4aa40085cb135 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1324,11 +1324,12 @@ void ivas_mct_dec_close( *-------------------------------------------------------------------------*/ /*! r : MC format mode */ -ivas_error ivas_mc_dec_config( +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_mc_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t idx, /* i : LS config. index */ - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ + const Word16 idx, /* i : LS config. index */ + UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ + Word16 *data /* o : output synthesis signal */ ) { AUDIO_CONFIG signaled_config; @@ -1338,12 +1339,12 @@ ivas_error ivas_mc_dec_config( /* store last frame MC mode */ last_mc_mode = st_ivas->mc_mode; - if ( !st_ivas->bfi ) + IF ( EQ_16(st_ivas->bfi, 0) ) { /* set transported MC LS setup */ signaled_config = ivas_mc_map_ls_setup_to_output_config( idx ); - if ( st_ivas->ini_frame == 0 ) + IF ( EQ_16(st_ivas->ini_frame, 0) ) { st_ivas->transport_config = signaled_config; } @@ -1352,107 +1353,10 @@ ivas_error ivas_mc_dec_config( st_ivas->mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate ); /* MC format switching */ - if ( st_ivas->ini_frame != 0 ) + IF ( st_ivas->ini_frame != 0 ) { - if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) + IF ( NE_32(st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate) || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*TODO: To be removed(Float to fixed conversion)*/ - //DECODER_TC_BUFFER_HANDLE hTcBuffer; - //hTcBuffer = st_ivas->hTcBuffer; - //RENDERER_TYPE renderer_type_old; - //renderer_type_old = st_ivas->renderer_type; - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } - //SPAR_DEC_HANDLE hSpar; - //hSpar = st_ivas->hSpar; - Word16 nchan_transport_old = st_ivas->nchan_transport; - //uint16_t nchan_internal; - Word32 ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - //nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - //DECODER_CONFIG_HANDLE hDecoderConfig; - //hDecoderConfig = st_ivas->hDecoderConfig; - - Word16 n_tc; - n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - for ( int ch = 0; ch < n_tc; ch++ ) - { - floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); - } - Word16 mmo_e = 0, mmro_e = 0; - PARAM_MC_DEC_HANDLE hParamMC; - hParamMC = st_ivas->hParamMC; - Word16 nchan_out_transport, nchan_out_cov; - MC_LS_SETUP mc_ls_setup; - Word16 nchan_transport; - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); - nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - if ( st_ivas->hParamMC ) - { - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - } - else - { - nchan_out_cov = nchan_out_transport; - } - Word32 max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; - float max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) - { - for ( int j = 0; j < nchan_transport_old * nchan_out_cov; j++ ) - max_mix_matrix_old = max( max_mix_matrix_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i][j] ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) - max_mix_matrix_res_old = max( max_mix_matrix_res_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i][j] ); - } - } - f2me( max_mix_matrix_old, &max_mix_matrix_old_fx, &mmo_e ); - f2me( max_mix_matrix_res_old, &max_mix_matrix_res_old_fx, &mmro_e ); - if ( mmo_e < 0 ) - mmo_e = 0; - if ( mmro_e < 0 ) - mmro_e = 0; - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) - { - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); - } - } - floatToFixed_arrL( hParamMC->proto_matrix_int, hParamMC->proto_matrix_int_fx, Q31, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_out_transport * nchan_transport) ); - FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - if ( hParamMC->diff_proto_info ) - floatToFixed_arrL( hParamMC->diff_proto_info->proto_fac[i], hParamMC->diff_proto_info->proto_fac_fx[i], Q26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - } - } -#endif IF ( st_ivas->hRenderConfig ) { FOR( Word16 i = 0; i < 4; i++ ) @@ -1460,7 +1364,7 @@ ivas_error ivas_mc_dec_config( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); } } - if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -1471,59 +1375,52 @@ ivas_error ivas_mc_dec_config( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shr( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); } } -#if 1 - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - hParamMC = st_ivas->hParamMC; - mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); - st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - } - else - { - nchan_out_cov = nchan_out_transport; - } - if ( hParamMC ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); - IF( hParamMC->diff_proto_info ) - FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_out_transport * nchan_transport) ); - if ( last_mc_mode == MC_MODE_PARAMMC ) - { - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); - } - } - } - if ( hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - } - } -#endif + } + } + + st_ivas->transport_config = signaled_config; + } + + return IVAS_ERR_OK; +} #else +ivas_error ivas_mc_dec_config( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t idx, /* i : LS config. index */ + uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ + int16_t *data /* o : output synthesis signal */ +) +{ + AUDIO_CONFIG signaled_config; + MC_MODE last_mc_mode; + ivas_error error; + + /* store last frame MC mode */ + last_mc_mode = st_ivas->mc_mode; + + if ( !st_ivas->bfi ) + { + /* set transported MC LS setup */ + signaled_config = ivas_mc_map_ls_setup_to_output_config( idx ); + + if ( st_ivas->ini_frame == 0 ) + { + st_ivas->transport_config = signaled_config; + } + + /* select MC format mode */ + st_ivas->mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate ); + + /* MC format switching */ + if ( st_ivas->ini_frame != 0 ) + { + if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) + { if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { return error; } -#endif // IVAS_FLOAT_FIXED } } @@ -1532,7 +1429,7 @@ ivas_error ivas_mc_dec_config( return IVAS_ERR_OK; } - +#endif /*------------------------------------------------------------------------- * ivas_mc_dec_reconfig() diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 16008fb1fbde5ccc6a8d3bb31350905712948a84..732bca24d5dd92d254f5fe98473930b4c54168c6 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -2297,7 +2297,7 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - Word16 x_e[MAX_CICP_CHANNELS][NB_DIV] + Word16 x_e[CPE_CHANNELS][NB_DIV] ) { Word16 ch, k, bfi; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index b3980c49c8053173dac87e7bd10c3858a027c47c..7ee3f1e7e2a91d2ab5f8354ac651dd0735de7e0d 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -88,9 +88,6 @@ ivas_error ivas_omasa_data_open( hMasaIsmData->objectsMoved = 0; hMasaIsmData->delayBuffer = NULL; -#ifdef IVAS_FLOAT_FIXED - hMasaIsmData->delayBuffer_fx = NULL; -#endif for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { @@ -106,9 +103,6 @@ ivas_error ivas_omasa_data_open( for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf], 0, CLDFB_NO_CHANNELS_MAX ); -#endif } } set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); @@ -119,47 +113,55 @@ ivas_error ivas_omasa_data_open( return IVAS_ERR_OK; } #else -ivas_error ivas_omasa_data_open( +ivas_error ivas_omasa_data_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { MASA_ISM_DATA_HANDLE hMasaIsmData; - int16_t ch, bin; - int16_t sf, obj_idx; + Word16 ch, bin; + Word16 sf, obj_idx; - IF ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) + IF( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } - FOR ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) + FOR( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { - FOR ( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < 2; ch++ ) { - hMasaIsmData->ismPreprocMatrix_fx[ch][ch][bin] = 32767; + hMasaIsmData->ismPreprocMatrix_fx[ch][ch][bin] = 32767; /* 1.0f in Q15 */ + move16(); hMasaIsmData->ismPreprocMatrix_fx[1 - ch][ch][bin] = 0; + move16(); hMasaIsmData->eneMoveIIR_fx[ch][bin] = 0; + move32(); hMasaIsmData->enePreserveIIR_fx[ch][bin] = 0; + move32(); } hMasaIsmData->preprocEneTarget_fx[bin] = 0; + move32(); hMasaIsmData->preprocEneRealized_fx[bin] = 0; + move32(); } hMasaIsmData->objectsMoved = 0; hMasaIsmData->delayBuffer_fx = NULL; - for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) + FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { hMasaIsmData->ism_is_edited[ch] = 0; hMasaIsmData->q_elevation_old_fx[ch] = 0; + move32(); hMasaIsmData->q_azimuth_old_fx[ch] = 0; + move32(); } - for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) + FOR( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { - set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) + set16_fx( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { // To be removed later ///////////////////////////////////////////////////////////////////////// set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); @@ -167,24 +169,8 @@ ivas_error ivas_omasa_data_open( set32_fx( hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf], 0, CLDFB_NO_CHANNELS_MAX ); } } - set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - - // to be removed later //////////////////////////////////////////////////////////////////////////////////// - FOR ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) - { - FOR ( ch = 0; ch < 2; ch++ ) - { - hMasaIsmData->ismPreprocMatrix[ch][ch][bin] = 1.0f; - hMasaIsmData->ismPreprocMatrix[1 - ch][ch][bin] = 0.0f; - hMasaIsmData->eneMoveIIR[ch][bin] = 0.0f; - hMasaIsmData->enePreserveIIR[ch][bin] = 0.0f; - } - hMasaIsmData->preprocEneTarget[bin] = 0.0f; - hMasaIsmData->preprocEneRealized[bin] = 0.0f; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + set16_fx( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set16_fx( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); st_ivas->hMasaIsmData = hMasaIsmData; @@ -221,38 +207,27 @@ void ivas_omasa_data_close( ( *hMasaIsmData )->delayBuffer = NULL; } -#ifdef IVAS_FLOAT_FIXED - IF ( ( *hMasaIsmData )->delayBuffer_fx != NULL ) - { - FOR ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) - { - free( ( *hMasaIsmData )->delayBuffer_fx[i] ); - } - free( ( *hMasaIsmData )->delayBuffer_fx ); - ( *hMasaIsmData )->delayBuffer_fx = NULL; - } -#endif - free( *hMasaIsmData ); *hMasaIsmData = NULL; return; } #else -void ivas_omasa_data_close( +void ivas_omasa_data_close_fx( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ) { Word16 i; - IF ( hMasaIsmData == NULL || *hMasaIsmData == NULL ) + test(); + IF( hMasaIsmData == NULL || *hMasaIsmData == NULL ) { return; } - IF ( ( *hMasaIsmData )->delayBuffer_fx != NULL ) + IF( ( *hMasaIsmData )->delayBuffer_fx != NULL ) { - FOR ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) + FOR( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) { free( ( *hMasaIsmData )->delayBuffer_fx[i] ); } @@ -389,14 +364,6 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * (1LL << (Q11))); } } - if ((hDecoderConfig->ivas_total_brate < IVAS_24k4) && ((hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2) || (hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3))) - { - for (Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) - { - floatToFixed_arrL(hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); - } - floatToFixed_arr(hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS); - } FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) { IF(st_ivas->cldfbSynDec[out_ch]) @@ -438,16 +405,6 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ } } - // fix2float (to be cleaned) - IF((LT_32(hDecoderConfig->ivas_total_brate, IVAS_24k4)) && ((EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2)) || (EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3)))) - { - fixedToFloat_arr(hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS); - FOR(Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) - { - fixedToFloat_arrL(hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); - } - } - // fix2float end FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) { IF(st_ivas->cldfbSynDec[out_ch]) @@ -477,7 +434,7 @@ ivas_error ivas_omasa_dec_config_fx( test(); IF( st_ivas->hMasaIsmData == NULL && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - IF( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -691,7 +648,6 @@ ivas_error ivas_omasa_dec_config_fx( return IVAS_ERR_OK; } #else - ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ @@ -765,17 +721,11 @@ ivas_error ivas_omasa_dec_config( ivas_set_omasa_TC( st_ivas->ism_mode, st_ivas->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); /* re-configure hp20 memories */ -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) { return error; } -#endif + /* reconfigure core-coders for ISMs */ k = 0; while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] ) @@ -788,17 +738,10 @@ ivas_error ivas_omasa_dec_config( ism_total_brate += sep_object_brate[k - 2][st_ivas->nSCE - 1]; } -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, 1, 2, 0, st_ivas->nSCE > 0 ? sep_object_brate[k - 2][st_ivas->nSCE - 1] : 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, 1, 2, 0, st_ivas->nSCE > 0 ? sep_object_brate[k - 2][st_ivas->nSCE - 1] : 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED if ( ism_mode_old != st_ivas->ism_mode ) { @@ -811,11 +754,7 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->hIsmMetaData[0] == NULL ) { -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -827,11 +766,7 @@ ivas_error ivas_omasa_dec_config( ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -877,7 +812,7 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ - if ((error = ivas_td_binaural_open(st_ivas)) != IVAS_ERR_OK) + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -892,7 +827,6 @@ ivas_error ivas_omasa_dec_config( { /* TD renderer handle */ ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - st_ivas->hHrtfTD = NULL; /* ISM renderer handle + ISM data handle */ @@ -902,11 +836,7 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->renderer_type == RENDERER_DIRAC ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -942,6 +872,7 @@ ivas_error ivas_omasa_dec_config( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ + if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; @@ -952,7 +883,6 @@ ivas_error ivas_omasa_dec_config( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; @@ -964,6 +894,7 @@ ivas_error ivas_omasa_dec_config( } #endif + /*--------------------------------------------------------------------------* * ivas_set_surplus_brate_dec() * diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 09bef1197db89429d17beee9184b41daaada94b4..3ea7685a73760d022d7125f9c78ac563ec1f3993 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -412,14 +412,6 @@ ivas_error ivas_osba_render_sf_fx( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( int i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -444,16 +436,6 @@ ivas_error ivas_osba_render_sf_fx( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( int i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index dea30f1e857f3268a6ae04ccefc3e75d4372d228..7b3202d6a2bad3a05487a03c2802a819aa325f3c 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1729,7 +1729,7 @@ void ivas_ls_setup_conversion_process_mdct( void ivas_ls_setup_conversion_process_mdct_param_mc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *x_fx[][NB_DIV], - Word16 x_e[MAX_CICP_CHANNELS][NB_DIV] /* i/o: Exponent for output synthesis signal */ + Word16 x_e[CPE_CHANNELS][NB_DIV] /* i/o: Exponent for output synthesis signal */ ) { Word32 targetEnergy_fx[MAX_SFB + 2], dmxEnergy_fx[MAX_SFB + 2]; diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index 7267195a817da45778c6358748893c58a5bcbb76..f058777e0a4986eaf8bd268bdabd880c00be1b01 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -320,14 +320,12 @@ void stereo_dft_dec_core_switching_fx( st->last_core = st->last_core_bfi; } +#ifndef MSAN_FIX IF( st->p_bpf_noise_buf_32 ) { -#ifdef MSAN_FIX - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); -#else Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, sub( *q, Q11 ) ); -#endif } +#endif IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE || ( st->bfi == 1 && st->core == ACELP_CORE && st->con_tcx == 1 ) ) { @@ -339,6 +337,9 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 && st->core != HQ_CORE ) { +#ifdef MSAN_FIX + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); +#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 2, 0, q, q_DFT ); } /* st->p_bpf_noise_buf not updated FOR HQ core -> skip analysis and set input memory to zero */ @@ -478,6 +479,9 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { +#ifdef MSAN_FIX + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); +#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } } @@ -503,6 +507,9 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { +#ifdef MSAN_FIX + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); +#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } @@ -568,6 +575,9 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { +#ifdef MSAN_FIX + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); +#endif stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT ); } @@ -702,14 +712,12 @@ void stereo_dft_dec_core_switching_fx( } } +#ifndef MSAN_FIX IF( st->p_bpf_noise_buf_32 ) { -#ifdef MSAN_FIX - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, negate( sub( *q, Q11 ) ) ); -#else Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, negate( sub( *q, Q11 ) ) ); -#endif } +#endif return; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 7b1a6c44279436a61e0a0c126e3e708959de84c4..561335d8669b35fe962a878da90a7a3d4e92abda 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1083,14 +1083,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) @@ -1141,16 +1133,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( } } }*/ - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5af8a70b8ba92f498cf43eb6ca86bae66351b616..63c16aa1dfc9fdee04d744db39f65dd4bdf985dc 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -330,8 +330,6 @@ ivas_error ivas_spar_md_dec_matrix_open_fx( } } } - hMdDec->mix_mat_dim_0_1 = num_channels; - hMdDec->mix_mat_dim_2 = num_md_sub_frames * IVAS_MAX_NUM_BANDS; if ( ( hMdDec->spar_coeffs.C_re_fx = (Word32 ***) malloc( num_channels * sizeof(Word32 ** ) ) ) == NULL ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 49b4b3b22e5176892169bb405fa50901acbe1425..04f2452d776ed3bbc6b140ebf8430c7cbdb3140a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -782,9 +782,9 @@ typedef struct dirac_output_synthesis_cov_state_structure #ifndef IVAS_FLOAT_FIXED float *cx_old[CLDFB_NO_CHANNELS_MAX]; float *cy_old[CLDFB_NO_CHANNELS_MAX]; -#endif float *mixing_matrix_old[CLDFB_NO_CHANNELS_MAX]; float *mixing_matrix_res_old[CLDFB_NO_CHANNELS_MAX]; +#endif float *mixing_matrix[CLDFB_NO_CHANNELS_MAX]; float *mixing_matrix_res[CLDFB_NO_CHANNELS_MAX]; #ifdef IVAS_FLOAT_FIXED @@ -883,8 +883,8 @@ typedef struct ivas_param_mc_dec_data_structure int16_t max_param_band_abs_cov; #ifndef IVAS_FLOAT_FIXED float *ls_conv_dmx_matrix; -#endif float *proto_matrix_int; +#endif #ifdef IVAS_FLOAT_FIXED Word16 q_proto_frame_f; Word32 *ls_conv_dmx_matrix_fx; @@ -978,6 +978,10 @@ typedef struct ivas_spar_md_dec_state_t #ifndef IVAS_FLOAT_FIXED float ***mixer_mat; float mixer_mat_prev[MAX_PARAM_SPATIAL_SUBFRAMES + 1][IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS]; +#else + Word32 ***mixer_mat_fx; /* Q(Q_mixer_mat) */ + Word32 mixer_mat_prev_fx[MAX_PARAM_SPATIAL_SUBFRAMES + 1][IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ + Word16 Q_mixer_mat; #endif ivas_spar_md_com_cfg spar_md_cfg; ivas_arith_coeffs_t arith_coeffs; @@ -987,28 +991,18 @@ typedef struct ivas_spar_md_dec_state_t int16_t spar_hoa_md_flag; int16_t spar_hoa_dirac2spar_md_flag; int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]; - +#ifndef IVAS_FLOAT_FIXED float smooth_buf[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1]; float smooth_fac[IVAS_MAX_NUM_BANDS]; -#ifdef IVAS_FLOAT_FIXED - Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1]; - Word16 smooth_fac_fx[IVAS_MAX_NUM_BANDS]; -#endif -#ifndef IVAS_FLOAT_FIXED float mixer_mat_prev2[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; +#else + Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q0 */ + Word16 smooth_fac_fx[IVAS_MAX_NUM_BANDS]; /* Q15 */ + Word32 mixer_mat_prev2_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ #endif int16_t first_valid_frame; ivas_band_coeffs_t *band_coeffs_prev; int16_t base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; - -#ifdef IVAS_FLOAT_FIXED - Word32 ***mixer_mat_fx; - Word32 mixer_mat_prev_fx[MAX_PARAM_SPATIAL_SUBFRAMES + 1][IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS]; - Word16 mix_mat_dim_0_1; - Word16 mix_mat_dim_2; - Word32 mixer_mat_prev2_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; - Word16 Q_mixer_mat; -#endif } ivas_spar_md_dec_state_t; @@ -1039,17 +1033,19 @@ typedef struct #ifndef IVAS_FLOAT_FIXED float prev_ql[IVAS_PCA_INTERP]; float prev_qr[IVAS_PCA_INTERP]; +#else + Word16 prev_ql_fx[IVAS_PCA_INTERP]; + Word16 prev_qr_fx[IVAS_PCA_INTERP]; #endif int16_t prev_pca_bypass; #ifndef IVAS_FLOAT_FIXED float mem_eigVec_interp[IVAS_PCA_LEN_INTERP_EIG_DEC]; +#else + Word16 mem_eigVec_interp_fx[IVAS_PCA_LEN_INTERP_EIG_DEC]; #endif /* parser output: */ int16_t pca_bypass; int32_t index[2]; - Word16 prev_ql_fx[IVAS_PCA_INTERP]; - Word16 prev_qr_fx[IVAS_PCA_INTERP]; - Word16 mem_eigVec_interp_fx[IVAS_PCA_LEN_INTERP_EIG_DEC]; } PCA_DEC_STATE; @@ -1245,8 +1241,8 @@ typedef struct ivas_lfe_dec_data_structure Word32 prior_out_buffer_fx[L_FRAME48k]; /* Q9 */ #endif - float prevsynth_buf[LFE_PLC_BUFLEN]; #ifndef IVAS_FLOAT_FIXED + float prevsynth_buf[LFE_PLC_BUFLEN]; float *lfe_delay_buf; #else Word32 prevsynth_buf_fx[LFE_PLC_BUFLEN]; /* Q9 */ @@ -1305,7 +1301,11 @@ typedef struct ivas_binaural_rendering_struct #endif /* Variables related to reverberator module */ +#ifndef IVAS_FLOAT_FIXED float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; +#else + Word32 earlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; +#endif REVERB_STRUCT_HANDLE hReverb; } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; @@ -1379,25 +1379,29 @@ typedef struct ivas_masa_ism_data_structure Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ #endif +#ifndef IVAS_FLOAT_FIXED float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; +#else + Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ +#endif uint8_t objectsMoved; +#ifndef IVAS_FLOAT_FIXED float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; - -#ifndef IVAS_FLOAT_FIXED - float **delayBuffer; -#endif -#ifdef IVAS_FLOAT_FIXED - Word32 **delayBuffer_fx; /* Q11 */ - Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; +#else Word32 eneMoveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; Word32 enePreserveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; Word32 preprocEneTarget_fx[CLDFB_NO_CHANNELS_MAX]; Word32 preprocEneRealized_fx[CLDFB_NO_CHANNELS_MAX]; #endif +#ifndef IVAS_FLOAT_FIXED + float **delayBuffer; +#else + Word32 **delayBuffer_fx; /* Q11 */ +#endif int16_t delayBuffer_size; int16_t delayBuffer_nchan; diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index e730824c57cfc7741ba08fa07bd67c36a3261476..5215ba636e14bb399bde44374f8f40783447d89d 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -54,7 +54,7 @@ static void apply_dmx_weights_fx( CPE_DEC_HANDLE hCPE, Word32 *x[CPE_CHANNELS][N static void apply_dmx_weights( CPE_DEC_HANDLE hCPE, float *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] ); #endif -static void run_min_stats_fx( Decoder_State **sts, Word32 *x[CPE_CHANNELS][NB_DIV], Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]); +static void run_min_stats_fx( Decoder_State **sts, Word32 *x[CPE_CHANNELS][NB_DIV], Word16 x_e[CPE_CHANNELS][NB_DIV]); /*-------------------------------------------------------------------* * stereo_mdct_dec_stereo() @@ -957,7 +957,7 @@ static void apply_dmx_weights_fx( static void run_min_stats_fx( Decoder_State **sts, Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: MDCT Spectrum */ - Word16 x_e[MAX_CICP_CHANNELS][NB_DIV] + Word16 x_e[CPE_CHANNELS][NB_DIV] ) { int16_t ch, will_estimate_noise_on_channel[CPE_CHANNELS], save_VAD[CPE_CHANNELS]; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 6ba9a2653277f3fc1e6233457de58224b75887be..36689712de0b314c9b58ae32ca42a4541be81c8b 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -386,6 +386,9 @@ static ivas_error allocate_CoreCoder_fx( } hf_synth_init_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif } IF ( st->cldfbAna == NULL ) @@ -3150,7 +3153,7 @@ void stereo_switching_dec( sts[1]->last_L_frame = sts[0]->last_L_frame; - Copy( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC ); + Copy_Scale_sig( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC, sub( sts[1]->Q_exc, sts[0]->Q_exc ) ); Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); IF( hCPE->element_mode == IVAS_CPE_MDCT ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6f38cbe7735a41a58a9b48b47a6c339bb430bed4..7fe92402c0fd5351a25d1752fa23b1cef230defe 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1466,9 +1466,27 @@ ivas_error IVAS_DEC_FeedHeadTrackData( } #ifdef IVAS_FLOAT_FIXED - IF((error = ivas_orient_trk_Process_fx(hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx])) != IVAS_ERR_OK) + Word32 updateRate_fx = 1677721600; // value is 200 in Q23 + orientation.w_fx = L_shl( orientation.w_fx, Q29 - orientation.q_fact ); + orientation.x_fx = L_shl( orientation.x_fx, Q29 - orientation.q_fact ); + orientation.y_fx = L_shl( orientation.y_fx, Q29 - orientation.q_fact ); + orientation.z_fx = L_shl( orientation.z_fx, Q29 - orientation.q_fact ); + hHeadTrackData->OrientationTracker->refRot.w_fx = L_shl( hHeadTrackData->OrientationTracker->refRot.w_fx, Q29 - hHeadTrackData->OrientationTracker->refRot.q_fact ); + hHeadTrackData->OrientationTracker->refRot.x_fx = L_shl( hHeadTrackData->OrientationTracker->refRot.x_fx, Q29 - hHeadTrackData->OrientationTracker->refRot.q_fact ); + hHeadTrackData->OrientationTracker->refRot.y_fx = L_shl( hHeadTrackData->OrientationTracker->refRot.y_fx, Q29 - hHeadTrackData->OrientationTracker->refRot.q_fact ); + hHeadTrackData->OrientationTracker->refRot.z_fx = L_shl( hHeadTrackData->OrientationTracker->refRot.z_fx, Q29 - hHeadTrackData->OrientationTracker->refRot.q_fact ); + hHeadTrackData->OrientationTracker->absAvgRot.w_fx = L_shl( hHeadTrackData->OrientationTracker->absAvgRot.w_fx, Q29 - hHeadTrackData->OrientationTracker->absAvgRot.q_fact ); + hHeadTrackData->OrientationTracker->absAvgRot.x_fx = L_shl( hHeadTrackData->OrientationTracker->absAvgRot.x_fx, Q29 - hHeadTrackData->OrientationTracker->absAvgRot.q_fact ); + hHeadTrackData->OrientationTracker->absAvgRot.y_fx = L_shl( hHeadTrackData->OrientationTracker->absAvgRot.y_fx, Q29 - hHeadTrackData->OrientationTracker->absAvgRot.q_fact ); + hHeadTrackData->OrientationTracker->absAvgRot.z_fx = L_shl( hHeadTrackData->OrientationTracker->absAvgRot.z_fx, Q29 - hHeadTrackData->OrientationTracker->absAvgRot.q_fact ); + + orientation.q_fact = Q29; + hHeadTrackData->OrientationTracker->refRot.q_fact = Q29; + hHeadTrackData->OrientationTracker->absAvgRot.q_fact = Q29; + + IF( ( error = ivas_orient_trk_Process_fx( hHeadTrackData->OrientationTracker, orientation, updateRate_fx, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) { - return error; + return error; } #else IF( ( error = ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index a4e8bc3f9b6de832bb2ef3fa49f51a05f1e379d9..5773b3010b12fd52351b41e7dcb65fb9b28c28e1 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -386,7 +386,7 @@ Word16 ivas_wb_bwe_dec_fx( { /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( (Word16 *)output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); + lerp( output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); wtda_fx( ysynth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); *Qpost = sub( new_input_fx_exp, 15 ); diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 39ad250b5ad027388e1d6799830b9c53ee00d112..7bffed0bff4c393e6021a5aa2814464ec1317717 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -317,7 +317,7 @@ void gp_clip_test_gain_pit_fx( * - target energy drops by 6 dB AND a good pitch prediction (lp_gp>1.0) *-------------------------------------------------------------------*/ Word16 Mode2_gp_clip( - const Word16 voicing[3], /* i : normalized correlations from OL pitch Q15 */ + const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ const Word16 i_subfr, /* i : subframe index */ const Word16 coder_type, /* i : type of coder */ const Word16 xn[], /* i : target vector Q_xn */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 9fa5649ace5242378f1e5b0a376ea829256f80dc..743fafd61a4ab50825d5f17eb84fd6dbaf887eef 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2169,7 +2169,7 @@ void spec_center_fx( void spec_flatness_fx(Word32 *spec_amp, /*(i) spectral amplitude*/ Word32 smooth_spec_amp[], /*(i) smoothed spectral amplitude*/ - Word16 sSFM[5] /*(o) spectral flatness rate*/ + Word16 sSFM[SFM_NUM] /*(o) spectral flatness rate*/ ); void SetModeIndex_fx( diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index 115e865454db70456db775adcee4c74ef130aa9a..03b9201074c702e9ad5a0a0dc9373edf228fcf28 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -21,7 +21,7 @@ void spec_flatness_fx( Word32 *spec_amp, /* i : spectral amplitude*/ Word32 smooth_spec_amp[], /* i : smoothed spectral amplitude*/ - Word16 sSFM[ ] /* o : spectral flatness rate*/ + Word16 sSFM[SFM_NUM] /* o : spectral flatness rate*/ ) { Word32 i; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 9dc46a56e1dc5fc9766960fe7ef687e77275e592..39d7df4e58b0a68e4f8b048f14d30fd0d5d52a8f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -5415,7 +5415,7 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( return; } -#endif +#else /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForMovedObjects() * @@ -5509,45 +5509,25 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( { float panGainsOut[2]; float panGainsIn[2]; -#ifdef IVAS_FLOAT_FIXED - Word16 panGainsOut_fx[2]; - Word16 panGainsIn_fx[2]; -#endif - float ratio_float; + float ratio; float panEnesOut[2]; float panEnesIn[2]; float centeringFactor; - ratio_float = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; - ismRatioAcc += ratio_float; + ismRatioAcc += ratio; /* Get input and output panning gains */ -#ifdef IVAS_FLOAT_FIXED - ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], - hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], - panGainsIn_fx ); - panGainsIn[0] = (float) panGainsIn_fx[0] / 32767; - panGainsIn[1] = (float) panGainsIn_fx[1] / 32767; -#else ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], panGainsIn ); -#endif if ( hMasaIsmData->ism_is_edited[ismDirIndex] ) { -#ifdef IVAS_FLOAT_FIXED - ivas_get_stereo_panning_gains_fx( hMasaIsmData->azimuth_ism_edited[ismDirIndex], - hMasaIsmData->elevation_ism_edited[ismDirIndex], - panGainsOut_fx ); - panGainsOut[0] = (float) panGainsOut_fx[0] / 32767; - panGainsOut[1] = (float) panGainsOut_fx[1] / 32767; -#else ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism_edited[ismDirIndex], hMasaIsmData->elevation_ism_edited[ismDirIndex], panGainsOut ); -#endif } else { @@ -5582,11 +5562,11 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( eneMoveThis = fmaxf( 0.0f, panEnesIn[ch] - panEnesOut[ch] ); enePreserveThis = panEnesIn[ch] - eneMoveThis; - eneMove[ch] += ratio_float * eneMoveThis; - enePreserve[ch] += ratio_float * enePreserveThis; + eneMove[ch] += ratio * eneMoveThis; + enePreserve[ch] += ratio * enePreserveThis; /* Subtract object parts from normEnes */ - normEnes[ch] -= panEnesIn[ch] * ratio_float; + normEnes[ch] -= panEnesIn[ch] * ratio; } } @@ -5660,6 +5640,8 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( return; } +#endif + #ifndef IVAS_FLOAT_FIXED static void ivas_masa_ext_rend_parambin_internal( @@ -5680,14 +5662,6 @@ static void ivas_masa_ext_rend_parambin_internal( int16_t i, j; int16_t nchan_transport; -#ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[MAX_OUTPUT_CHANNELS]; - Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Rmat_fx[3][3]; -#endif - hDiracDecBin = hMasaExtRend->hDiracDecBin; assert( hDiracDecBin ); hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; @@ -5708,28 +5682,7 @@ static void ivas_masa_ext_rend_parambin_internal( /* The input channel number at this processing function (not nchan_transport) */ numInChannels = BINAURAL_CHANNELS; -#ifdef IVAS_FLOAT_FIXED - Rmat_fx[0][0] = ONE_IN_Q31; - move32(); - Rmat_fx[0][1] = 0; - move32(); - Rmat_fx[0][2] = 0; - move32(); - - Rmat_fx[1][0] = 0; - move32(); - Rmat_fx[1][1] = ONE_IN_Q31; - move32(); - Rmat_fx[1][2] = 0; - move32(); - Rmat_fx[2][0] = 0; - move32(); - Rmat_fx[2][1] = 0; - move32(); - Rmat_fx[2][2] = ONE_IN_Q31; - move32(); -#endif Rmat[0][0] = 1.0f; Rmat[0][1] = 0.0f; Rmat[0][2] = 0.0f; @@ -5774,221 +5727,32 @@ static void ivas_masa_ext_rend_parambin_internal( { for ( j = 0; j < 3; j++ ) { -#ifdef IVAS_FLOAT_FIXED - Rmat_fx[i][j] = hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx][i][j]; // Q30// -#endif Rmat[i][j] = hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i][j]; } } - IF( EQ_16( nchan_transport, 2 ) ) + if ( nchan_transport == 2 ) { -#ifdef IVAS_FLOAT_FIXED - Word16 q_inp = Q6; - FOR( Word16 cha = 0; cha < 2; cha++ ) - FOR( slot = 0; slot < 4; slot++ ) - FOR( Word16 ind = 0; ind < 60; ind++ ) - { - Cldfb_RealBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_RealBuffer_in[cha][slot][ind], q_inp ); - Cldfb_ImagBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_ImagBuffer_in[cha][slot][ind], q_inp ); - } - adaptTransportSignalsHeadtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); - - ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); - FOR( Word16 cha = 0; cha < 2; cha++ ) - FOR( slot = 0; slot < 4; slot++ ) - FOR( Word16 ind = 0; ind < 60; ind++ ) - { - Cldfb_RealBuffer_in[cha][slot][ind] = fix_to_float( Cldfb_RealBuffer_in_fx[cha][slot][ind], q_inp ); - Cldfb_ImagBuffer_in[cha][slot][ind] = fix_to_float( Cldfb_ImagBuffer_in_fx[cha][slot][ind], q_inp ); - } -#else adaptTransportSignalsHeadtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); -#endif - } - } - -#ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 q_earlyPartEneCorrection = Q_factor_arrL( hDiracDecBin->earlyPartEneCorrection, hSpatParamRendCom->num_freq_bands ); - hDiracDecBin->q_earlyPartEneCorrection = q_earlyPartEneCorrection; - floatToFixed_arr32( hDiracDecBin->earlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection_fx, q_earlyPartEneCorrection, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherence, hDiracDecBin->diffuseFieldCoherence_fx, Q31, hSpatParamRendCom->num_freq_bands ); - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - f2me( hDiracDecBin->ChCrossRePrev[j], &hDiracDecBin->ChCrossRePrev_fx[j], &hDiracDecBin->ChCrossRePrev_e[j] ); - f2me( hDiracDecBin->ChCrossImPrev[j], &hDiracDecBin->ChCrossImPrev_fx[j], &hDiracDecBin->ChCrossImPrev_e[j] ); - f2me( hDiracDecBin->ChCrossReOutPrev[j], &hDiracDecBin->ChCrossReOutPrev_fx[j], &hDiracDecBin->ChCrossReOutPrev_e[j] ); - f2me( hDiracDecBin->ChCrossImOutPrev[j], &hDiracDecBin->ChCrossImOutPrev_fx[j], &hDiracDecBin->ChCrossImOutPrev_e[j] ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - f2me( hDiracDecBin->ChEnePrev[i][j], &hDiracDecBin->ChEnePrev_fx[i][j], &hDiracDecBin->ChEnePrev_e[i][j] ); - f2me( hDiracDecBin->ChEneOutPrev[i][j], &hDiracDecBin->ChEneOutPrev_fx[i][j], &hDiracDecBin->ChEneOutPrev_e[i][j] ); - } - } - FOR( i = 0; i < hSpatParamRendCom->dirac_md_buffer_length; i++ ) - { - IF( hSpatParamRendCom->energy_ratio1 ) - floatToFixed_arrL32( hSpatParamRendCom->energy_ratio1[i], hSpatParamRendCom->energy_ratio1_fx[i], Q30, hSpatParamRendCom->num_freq_bands ); - IF( hSpatParamRendCom->energy_ratio2 ) - floatToFixed_arrL32( hSpatParamRendCom->energy_ratio2[i], hSpatParamRendCom->energy_ratio2_fx[i], Q30, hSpatParamRendCom->num_freq_bands ); - } - floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherence, hDiracDecBin->diffuseFieldCoherence_fx, 31, hSpatParamRendCom->num_freq_bands ); - IF( hDiracDecBin->hDiffuseDist ) - { - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioX, hDiracDecBin->hDiffuseDist->diffuseRatioX_fx, 31, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceX, hDiracDecBin->diffuseFieldCoherenceX_fx, 31, 9 ); - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioY, hDiracDecBin->hDiffuseDist->diffuseRatioY_fx, 31, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceY, hDiracDecBin->diffuseFieldCoherenceY_fx, 31, 9 ); - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioZ, hDiracDecBin->hDiffuseDist->diffuseRatioZ_fx, 31, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceZ, hDiracDecBin->diffuseFieldCoherenceZ_fx, 31, 9 ); - } - config_data.qualityBasedSmFactor_fx = (Word32) ( config_data.qualityBasedSmFactor * ONE_IN_Q31 ); -#endif - Word16 shift = 31; - Word32 Cldfb_RealBuffer_inTmp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Cldfb_ImagBuffer_inTmp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - shift = s_min(shift, getScaleFactor32(Cldfb_RealBuffer_in_fx[i][j], CLDFB_NO_CHANNELS_MAX)); - shift = s_min(shift, getScaleFactor32(Cldfb_ImagBuffer_in_fx[i][j], CLDFB_NO_CHANNELS_MAX)); - } - } - - Word16 q = q_inp + shift; - - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - FOR( Word16 k = 0; k < 60; k++ ) - { - Cldfb_RealBuffer_inTmp_fx[i][j][k] = L_shl( Cldfb_RealBuffer_in_fx[i][j][k], shift ); - Cldfb_ImagBuffer_inTmp_fx[i][j][k] = L_shl( Cldfb_ImagBuffer_in_fx[i][j][k], shift ); - } } } - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL, q ); -#if 1 - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - hDiracDecBin->ChEnePrev[i][j] = me2f( hDiracDecBin->ChEnePrev_fx[i][j], hDiracDecBin->ChEnePrev_e[i][j] ); - hDiracDecBin->ChEne[i][j] = me2f( hDiracDecBin->ChEne_fx[i][j], hDiracDecBin->ChEne_e[i][j] ); - hDiracDecBin->ChEneOut[i][j] = me2f( hDiracDecBin->ChEneOut_fx[i][j], hDiracDecBin->ChEneOut_e[i][j] ); - hDiracDecBin->ChEneOutPrev[i][j] = me2f( hDiracDecBin->ChEneOutPrev_fx[i][j], hDiracDecBin->ChEneOutPrev_e[i][j] ); - } - } - - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - hDiracDecBin->ChCrossRePrev[j] = me2f( hDiracDecBin->ChCrossRePrev_fx[j], hDiracDecBin->ChCrossRePrev_e[j] ); - hDiracDecBin->ChCrossImPrev[j] = me2f( hDiracDecBin->ChCrossImPrev_fx[j], hDiracDecBin->ChCrossImPrev_e[j] ); - hDiracDecBin->ChCrossRe[j] = me2f( hDiracDecBin->ChCrossRe_fx[j], hDiracDecBin->ChCrossRe_e[j] ); - hDiracDecBin->ChCrossIm[j] = me2f( hDiracDecBin->ChCrossIm_fx[j], hDiracDecBin->ChCrossIm_e[j] ); - hDiracDecBin->ChCrossReOut[j] = me2f( hDiracDecBin->ChCrossReOut_fx[j], hDiracDecBin->ChCrossReOut_e[j] ); - hDiracDecBin->ChCrossImOut[j] = me2f( hDiracDecBin->ChCrossImOut_fx[j], hDiracDecBin->ChCrossImOut_e[j] ); - hDiracDecBin->ChCrossReOutPrev[j] = me2f( hDiracDecBin->ChCrossReOutPrev_fx[j], hDiracDecBin->ChCrossReOutPrev_e[j] ); - hDiracDecBin->ChCrossImOutPrev[j] = me2f( hDiracDecBin->ChCrossImOutPrev_fx[j], hDiracDecBin->ChCrossImOutPrev_e[j] ); - } - fixedToFloat_arrL( hDiracDecBin->frameMeanDiffuseness_fx, hDiracDecBin->frameMeanDiffuseness, 29, CLDFB_NO_CHANNELS_MAX ); - -#endif -#else ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL ); -#endif + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL ); + /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; - ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, - 0, NULL ); - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef IVAS_FLOAT_FIXED - Word16 q_out; - Word16 q_mat = 15; - q_inp = Q6; - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - output_fx[ch] = output_fx_buff[ch]; - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) - { - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRe[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecIm[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRePrev[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecImPrev[ch][slot], nBins ) ); - } - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - FOR( slot = 0; slot < numInChannels; slot++ ) - { - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRe[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxIm[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRePrev[ch][slot], nBins ) ); - q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxImPrev[ch][slot], nBins ) ); - } - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - output_fx[ch] = output_fx_buff[ch]; - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) - { - floatToFixed_arr16( hDiracDecBin->processMtxDecRe[ch][slot], hDiracDecBin->processMtxDecRe_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecIm[ch][slot], hDiracDecBin->processMtxDecIm_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecRePrev[ch][slot], hDiracDecBin->processMtxDecRePrev_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecImPrev[ch][slot], hDiracDecBin->processMtxDecImPrev_fx[ch][slot], q_mat, nBins ); - } - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - FOR( slot = 0; slot < numInChannels; slot++ ) - { - floatToFixed_arr16( hDiracDecBin->processMtxRe[ch][slot], hDiracDecBin->processMtxRe_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxIm[ch][slot], hDiracDecBin->processMtxIm_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxRePrev[ch][slot], hDiracDecBin->processMtxRePrev_fx[ch][slot], q_mat, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxImPrev[ch][slot], hDiracDecBin->processMtxImPrev_fx[ch][slot], q_mat, nBins ); - } - floatToFixed_arrL( hMasaExtRend->cldfbSynRend[ch]->cldfb_state, hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, Q11, hMasaExtRend->cldfbSynRend[ch]->p_filter_length ); - hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; - } - FOR( Word16 cha = 0; cha < 6; cha++ ) - FOR( slot = 0; slot < 4; slot++ ) - FOR( Word16 ind = 0; ind < 60; ind++ ) - { - Cldfb_RealBuffer_in_fx[cha][slot][ind] = floatToFixed( Cldfb_RealBuffer_in[cha][slot][ind], Q6 ); - Cldfb_ImagBuffer_in_fx[cha][slot][ind] = floatToFixed( Cldfb_ImagBuffer_in[cha][slot][ind], Q6 ); - } - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + 0, NULL ); - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, nBins * hSpatParamRendCom->subframe_nbslots[subframe] ); - fixedToFloat_arrL32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_state, hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state, hMasaExtRend->cldfbSynRend[ch]->p_filter_length ); - } -#else ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe ); -#endif - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - hDiracDecBin->hDiffuseDist = NULL; @@ -5996,7 +5760,7 @@ static void ivas_masa_ext_rend_parambin_internal( hSpatParamRendCom->subframes_rendered++; return; - } +} #else static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, @@ -6045,11 +5809,8 @@ static void ivas_masa_ext_rend_parambin_internal( floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherence, hDiracDecBin->diffuseFieldCoherence_fx, 31, hSpatParamRendCom->num_freq_bands ); IF( hDiracDecBin->hDiffuseDist ) { - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioX, hDiracDecBin->hDiffuseDist->diffuseRatioX_fx, 31, hSpatParamRendCom->num_freq_bands ); floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceX, hDiracDecBin->diffuseFieldCoherenceX_fx, 31, 9 ); - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioY, hDiracDecBin->hDiffuseDist->diffuseRatioY_fx, 31, hSpatParamRendCom->num_freq_bands ); floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceY, hDiracDecBin->diffuseFieldCoherenceY_fx, 31, 9 ); - floatToFixed_arr32( hDiracDecBin->hDiffuseDist->diffuseRatioZ, hDiracDecBin->hDiffuseDist->diffuseRatioZ_fx, 31, hSpatParamRendCom->num_freq_bands ); floatToFixed_arr32( hDiracDecBin->diffuseFieldCoherenceZ, hDiracDecBin->diffuseFieldCoherenceZ_fx, 31, 9 ); } FOR( ch = 0; ch < 2; ch++) diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 44c665e1b17db544ca7d666e8597c5ede64c5c19..172c4d30c4f570288646091998c237917d1ac030 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -65,6 +65,7 @@ * *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static IVAS_QUATERNION IdentityQuaternion( void ) { @@ -75,8 +76,7 @@ static IVAS_QUATERNION IdentityQuaternion( return q; } - -#ifdef IVAS_FLOAT_FIXED +#else static IVAS_QUATERNION IdentityQuaternion_fx( void ) { @@ -96,6 +96,7 @@ static IVAS_QUATERNION IdentityQuaternion_fx( * Quaternion product *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void QuaternionProduct( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, @@ -111,8 +112,7 @@ void QuaternionProduct( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void QuaternionProduct_fx( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, @@ -138,14 +138,14 @@ void QuaternionProduct_fx( * Quaternion dot product *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static float QuaternionDotProduct( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2 ) { return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; } - -#ifdef IVAS_FLOAT_FIXED +#else static Word32 QuaternionDotProduct_fx( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, @@ -168,6 +168,7 @@ static Word32 QuaternionDotProduct_fx( * Divides a quaternion by a scalar *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void QuaternionDivision( const IVAS_QUATERNION q, const float d, @@ -180,8 +181,7 @@ static void QuaternionDivision( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void QuaternionDivision_fx( const IVAS_QUATERNION q, const Word32 d, @@ -223,6 +223,7 @@ static void QuaternionDivision_fx( * Normalizes a quaternion *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void QuaternionNormalize( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) @@ -232,8 +233,7 @@ static void QuaternionNormalize( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void QuaternionNormalize_fx( const IVAS_QUATERNION q_fx, IVAS_QUATERNION *const r_fx ) @@ -419,6 +419,7 @@ void QuaternionSlerp_fx( * Computes a quaternion conjugate *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void QuaternionConjugate( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) @@ -430,8 +431,7 @@ static void QuaternionConjugate( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void QuaternionConjugate_fx( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) @@ -466,9 +466,7 @@ static float QuaternionAngle( return angle; } -#endif - -#ifdef IVAS_FLOAT_FIXED +#else static Word32 QuaternionAngle_fx( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2 ) @@ -533,6 +531,7 @@ static Word32 QuaternionAngle_fx( * Computes an inverse quaternion *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void QuaternionInverse( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) @@ -545,8 +544,7 @@ void QuaternionInverse( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void QuaternionInverse_fx( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) @@ -568,6 +566,7 @@ void QuaternionInverse_fx( * Computes the difference of two vectors *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static IVAS_VECTOR3 VectorSubtract( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) @@ -580,8 +579,7 @@ static IVAS_VECTOR3 VectorSubtract( return result; } - -#ifdef IVAS_FLOAT_FIXED +#else static IVAS_VECTOR3 VectorSubtract_fx( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) @@ -614,6 +612,7 @@ static IVAS_VECTOR3 VectorSubtract_fx( * Computes the cross product of two vectors *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static IVAS_VECTOR3 VectorCrossProduct( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) @@ -625,8 +624,7 @@ static IVAS_VECTOR3 VectorCrossProduct( return result; } - -#ifdef IVAS_FLOAT_FIXED +#else static IVAS_VECTOR3 VectorCrossProduct_fx( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) @@ -648,14 +646,14 @@ static IVAS_VECTOR3 VectorCrossProduct_fx( * Computes the dot product of two vectors *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static float VectorDotProduct( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) { return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z; } - -#ifdef IVAS_FLOAT_FIXED +#else static Word32 VectorDotProduct_fx( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2, @@ -676,13 +674,13 @@ static Word32 VectorDotProduct_fx( * Computes the length of a vector *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static float VectorLength( const IVAS_VECTOR3 p ) { return sqrtf( p.x * p.x + p.y * p.y + p.z * p.z ); } - -#ifdef IVAS_FLOAT_FIXED +#else static Word32 VectorLength_fx( IVAS_VECTOR3 p, Word16 *q_fact ) @@ -701,6 +699,7 @@ static Word32 VectorLength_fx( * Normalizes a vector *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static IVAS_VECTOR3 VectorNormalize( const IVAS_VECTOR3 p ) { @@ -714,8 +713,7 @@ static IVAS_VECTOR3 VectorNormalize( return result; } - -#ifdef IVAS_FLOAT_FIXED +#else static IVAS_VECTOR3 VectorNormalize_fx( const IVAS_VECTOR3 p ) { @@ -749,6 +747,7 @@ static IVAS_VECTOR3 VectorNormalize_fx( * Computes a quaternion representing the rotation from vector p1 to vector p2 *------------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void VectorRotationToQuaternion( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2, @@ -761,7 +760,6 @@ static void VectorRotationToQuaternion( p2_normalized = VectorNormalize( p2 ); cross_product = VectorCrossProduct( p1_normalized, p2_normalized ); dot_product = VectorDotProduct( p1_normalized, p2_normalized ); - if ( dot_product < -0.999999 ) { /* happens when the p1 vector is parallel to p2, but direction is flipped */ @@ -783,8 +781,7 @@ static void VectorRotationToQuaternion( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void VectorRotationToQuaternion_fx( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2, @@ -800,9 +797,8 @@ static void VectorRotationToQuaternion_fx( dot_product_fx = VectorDotProduct_fx( p1_normalized_fx, p2_normalized_fx, &q_dot ); // dot & cross product are same q// - Word32 comp_fx = 0; - Word16 comp_e, check_flag; - f2me( -0.999999f, &comp_fx, &comp_e ); + Word32 comp_fx = -2147481472;//-0.999999f in Q31 + Word16 comp_e = 0, check_flag; IF( GT_32( dot_product_fx, 0 ) ) { check_flag = 0; @@ -884,12 +880,10 @@ ivas_error ivas_orient_trk_Init_fx( { IVAS_QUATERNION identity_fx; - //===================Remove float code once caller function is converted to fixed=================// IF ( pOTR == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - identity_fx.w_fx = ONE_IN_Q31; identity_fx.x_fx = identity_fx.y_fx = identity_fx.z_fx = 0; identity_fx.q_fact = Q31; @@ -905,6 +899,7 @@ ivas_error ivas_orient_trk_Init_fx( /* initial adaptivity filter coefficient, will be auto-adapted */ // pOTR->alpha = sinf( PI2 * pOTR->offCenterAdaptationRate / OTR_UPDATE_RATE ); /* start adaptation at off-center rate = fastest rate */ pOTR->alpha_fx = 33731208; // Q31 + pOTR->Q_alpha = Q31; pOTR->trkRot = identity_fx; pOTR->absAvgRot = identity_fx; /* Use frontal and horiontal orientation as reference orientation, unless/until overridden */ @@ -913,12 +908,6 @@ ivas_error ivas_orient_trk_Init_fx( // this part still float// /* set safe default tracking mode */ pOTR->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; - pOTR->alpha = me2f(pOTR->alpha_fx, 0 ); - pOTR->refRot.w = pOTR->absAvgRot.w = pOTR->trkRot.w = fix_to_float(pOTR->trkRot.w_fx, pOTR->trkRot.q_fact); - pOTR->refRot.x = pOTR->absAvgRot.x = pOTR->trkRot.x = fix_to_float(pOTR->trkRot.x_fx, pOTR->trkRot.q_fact); - pOTR->refRot.y = pOTR->absAvgRot.y = pOTR->trkRot.y = fix_to_float(pOTR->trkRot.y_fx, pOTR->trkRot.q_fact); - pOTR->refRot.z = pOTR->absAvgRot.z = pOTR->trkRot.z = fix_to_float(pOTR->trkRot.z_fx, pOTR->trkRot.q_fact); - return IVAS_ERR_OK; } #endif @@ -1019,6 +1008,7 @@ ivas_error ivas_orient_trk_SetReferenceRotation( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_orient_trk_GetMainOrientation( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION *pOrientation /* i/o: average/reference orientation */ @@ -1046,8 +1036,7 @@ ivas_error ivas_orient_trk_GetMainOrientation( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_orient_trk_GetMainOrientation_fx( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION *pOrientation /* i/o: average/reference orientation */ @@ -1122,6 +1111,7 @@ ivas_error ivas_orient_trk_GetTrackedRotation_fx( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_orient_trk_SetReferenceVector( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ const IVAS_VECTOR3 listenerPos, /* i : Listener position */ @@ -1173,8 +1163,7 @@ ivas_error ivas_orient_trk_SetReferenceVector( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_orient_trk_SetReferenceVector_fx( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ const IVAS_VECTOR3 listenerPos, /* i : Listener position */ @@ -1339,43 +1328,23 @@ ivas_error ivas_orient_trk_Process( ivas_error ivas_orient_trk_Process_fx( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ + Word32 updateRate_fx, /* i : rotation update rate [Hz] */ IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ ) { - //===================Remove float code once caller function is converted to fixed=================// - float alpha = pOTR->alpha; ivas_error result; - Word32 updateRate_fx; Word32 rateRange_fx; Word32 cutoffFrequency_fx, cutoff_prod; Word16 q_cutoff_prod = 0; - Word32 alpha_fx = float_to_fix( alpha, Q30 ); - pOTR->refRot.q_fact = Q29; - absRot.q_fact = Q29; - pOTR->absAvgRot.q_fact = Q29; - updateRate_fx = float_to_fix( updateRate, Q23 ); // value is 200// - absRot.w_fx = float_to_fix( absRot.w, absRot.q_fact); - absRot.x_fx = float_to_fix( absRot.x, absRot.q_fact); - absRot.y_fx = float_to_fix( absRot.y, absRot.q_fact); - absRot.z_fx = float_to_fix( absRot.z, absRot.q_fact); - pOTR->refRot.w_fx = float_to_fix( pOTR->refRot.w, pOTR->refRot.q_fact); - pOTR->refRot.x_fx = float_to_fix( pOTR->refRot.x, pOTR->refRot.q_fact); - pOTR->refRot.y_fx = float_to_fix( pOTR->refRot.y, pOTR->refRot.q_fact); - pOTR->refRot.z_fx = float_to_fix( pOTR->refRot.z, pOTR->refRot.q_fact); - pOTR->absAvgRot.w_fx = float_to_fix( pOTR->absAvgRot.w, pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.x_fx = float_to_fix( pOTR->absAvgRot.x, pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.y_fx = float_to_fix( pOTR->absAvgRot.y, pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.z_fx = float_to_fix( pOTR->absAvgRot.z, pOTR->absAvgRot.q_fact); - - IF ( pOTR == NULL || pTrkRot == NULL ) + Word32 alpha_fx = L_shl( pOTR->alpha_fx, Q30 - pOTR->Q_alpha ); + IF( pOTR == NULL || pTrkRot == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } result = IVAS_ERR_OK; - SWITCH ( pOTR->orientation_tracking ) + SWITCH( pOTR->orientation_tracking ) { case IVAS_HEAD_ORIENT_TRK_NONE: pOTR->trkRot = absRot; @@ -1396,7 +1365,6 @@ ivas_error ivas_orient_trk_Process_fx( /* Compute relative orientation = (absolute orientation) - (reference orientation) */ QuaternionInverse_fx( pOTR->refRot, &pOTR->trkRot ); QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot ); - ; BREAK; case IVAS_HEAD_ORIENT_TRK_AVG: @@ -1411,8 +1379,8 @@ ivas_error ivas_orient_trk_Process_fx( Word16 result_e = 0; Word16 temp_result = BASOP_Util_Divide3232_Scale( angle_fx, pOTR->adaptationAngle_fx, &result_e ); relativeOrientationRate_fx = L_deposit_h( temp_result ); - Word32 one_fx; - Word16 temp = result_e; + Word32 one_fx = 1073741824; + Word16 temp = 1; f2me( 1.0, &one_fx, &temp ); IF( GT_32( relativeOrientationRate_fx, one_fx ) ) { @@ -1446,26 +1414,17 @@ ivas_error ivas_orient_trk_Process_fx( temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e ); result_e = result_e + ( 23 - q_cutoff_prod ); pOTR->alpha_fx = L_deposit_h( temp_result ); - pOTR->alpha = me2f( pOTR->alpha_fx, result_e ); // Remove this floating code// + pOTR->Q_alpha = Q31 - result_e; BREAK; default: result = IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Non-supported orientation tracking adaptation type" ); BREAK; } - IF ( result == IVAS_ERR_OK ) + if ( result == IVAS_ERR_OK ) { - pOTR->trkRot.w = me2f( pOTR->trkRot.w_fx, 31 - pOTR->trkRot.q_fact ); - pOTR->trkRot.x = me2f( pOTR->trkRot.x_fx, 31 - pOTR->trkRot.q_fact); - pOTR->trkRot.y = me2f( pOTR->trkRot.y_fx, 31 - pOTR->trkRot.q_fact); - pOTR->trkRot.z = me2f( pOTR->trkRot.z_fx, 31 - pOTR->trkRot.q_fact); - pOTR->absAvgRot.w = me2f( pOTR->absAvgRot.w_fx, 31 - pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.x = me2f( pOTR->absAvgRot.x_fx, 31 - pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.y = me2f( pOTR->absAvgRot.y_fx, 31 - pOTR->absAvgRot.q_fact); - pOTR->absAvgRot.z = me2f( pOTR->absAvgRot.z_fx, 31 - pOTR->absAvgRot.q_fact); *pTrkRot = pOTR->trkRot; } - return result; } #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index ea57f5e9e5c08b1a7197281d9d8894bcbe5b9ee0..491286d4cf34ac72776c720d64c3bc81298f40cf 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2503,19 +2503,13 @@ ivas_error ivas_render_config_init_from_rom( * Quaternion operations *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void QuaternionProduct( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, IVAS_QUATERNION *const r ); -#ifdef IVAS_FLOAT_FIXED -void QuaternionProduct_fx( - const IVAS_QUATERNION q1, - const IVAS_QUATERNION q2, - IVAS_QUATERNION *const r); -#endif - void QuaternionInverse( const IVAS_QUATERNION q, IVAS_QUATERNION *const r @@ -2527,8 +2521,13 @@ void QuaternionSlerp( const float t, IVAS_QUATERNION *const r ); +#else +void QuaternionProduct_fx( + const IVAS_QUATERNION q1, + const IVAS_QUATERNION q2, + IVAS_QUATERNION *const r +); -#ifdef IVAS_FLOAT_FIXED void QuaternionInverse_fx( const IVAS_QUATERNION q, IVAS_QUATERNION *const r @@ -2560,6 +2559,7 @@ ivas_error ivas_orient_trk_SetReferenceRotation( const IVAS_QUATERNION refRot /* i : reference rotation */ ); +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_orient_trk_SetReferenceVector( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ const IVAS_VECTOR3 listenerPos, /* i : Listener position */ @@ -2570,6 +2570,7 @@ ivas_error ivas_orient_trk_GetMainOrientation( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION *pOrientation /* i/o: average/reference orientation */ ); +#endif ivas_error ivas_orient_trk_GetTrackedRotation( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ @@ -2618,7 +2619,7 @@ ivas_error ivas_orient_trk_GetTrackedRotation_fx( ivas_error ivas_orient_trk_Process_fx( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ + Word32 updateRate_fx, /* i : rotation update rate [Hz] */ IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ ); #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index fef1c9987118edba48f38ac3a329a94e1935d7fb..2f3ad8378bacf0bacbf2b7e6cb34b360a721833d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -345,6 +345,7 @@ typedef struct dirac_output_synthesis_params_structure #ifdef IVAS_FLOAT_FIXED Word32 *proto_matrix_fx; Word16 proto_matrix_e; + Word16 proto_matrix_len; Word32 diffuse_compensation_factor_fx; // Q27 Word32 diffuse_compensation_factor_decorr_fx; // Q29 #endif @@ -804,14 +805,15 @@ typedef struct ivas_binaural_reverb_struct /* Diffuse sound directional distribution data structure */ typedef struct ivas_diffuse_distribution_data_structure { +#ifndef IVAS_FLOAT_FIXED float diffuseRatioX[CLDFB_NO_CHANNELS_MAX]; float diffuseRatioY[CLDFB_NO_CHANNELS_MAX]; float diffuseRatioZ[CLDFB_NO_CHANNELS_MAX]; - - Word32 diffuseRatioX_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 diffuseRatioY_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 diffuseRatioZ_fx[CLDFB_NO_CHANNELS_MAX]; - +#else + Word32 diffuseRatioX_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 diffuseRatioY_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 diffuseRatioZ_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif } DIFFUSE_DISTRIBUTION_DATA, *DIFFUSE_DISTRIBUTION_HANDLE; @@ -1044,9 +1046,9 @@ typedef struct ivas_orient_trk_state_t float centerAdaptationRate; float offCenterAdaptationRate; float adaptationAngle; + float alpha; #endif - float alpha; #ifdef IVAS_FLOAT_FIXED Word32 centerAdaptationRate_fx; /* Q31 */ Word32 offCenterAdaptationRate_fx; /* Q31 */ @@ -1054,6 +1056,7 @@ typedef struct ivas_orient_trk_state_t #endif Word32 alpha_fx; + Word16 Q_alpha; IVAS_QUATERNION absAvgRot; /* average absolute orientation */ IVAS_QUATERNION refRot; /* reference orientation */ IVAS_QUATERNION trkRot; /* tracked rotation */ @@ -2506,7 +2509,7 @@ typedef struct ivas_masa_prerend_data_structure float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; #ifdef IVAS_FLOAT_FIXED Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1d745cfb7eb1400ae309f91153d7930f85afbc36..eb7a591bda5c4724ba3ac89a3bdec3b9b0026c40 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2297,7 +2297,6 @@ static ivas_error setRendInputActiveIsm( inputIsm->crendWrapper = NULL; inputIsm->hReverb = NULL; inputIsm->tdRendWrapper = defaultTdRendWrapper(); - #ifndef IVAS_FLOAT_FIXED initRotMatrix( inputIsm->rot_mat_prev ); #else @@ -3743,7 +3742,7 @@ static ivas_error initMcBinauralRendering( const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, - uint8_t reconfigureFlag) + uint8_t reconfigureFlag ) { ivas_error error; int32_t binauralDelayNs; @@ -3753,49 +3752,49 @@ static ivas_error initMcBinauralRendering( /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) or planar MC layouts with headrotation, CREND for the rest */ useTDRend = FALSE; - if (outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) + if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { - if (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) + if ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { useTDRend = TRUE; } - else if ((inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1) && - (inputMc->base.ctx.pHeadRotData->headRotEnabled)) + else if ( ( inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1 ) && + ( inputMc->base.ctx.pHeadRotData->headRotEnabled ) ) { useTDRend = TRUE; } } /* if TD renderer was open and we need to use CREND, close it */ - if (!reconfigureFlag || (!useTDRend && inputMc->tdRendWrapper.hBinRendererTd != NULL)) + if ( !reconfigureFlag || ( !useTDRend && inputMc->tdRendWrapper.hBinRendererTd != NULL ) ) { - ivas_td_binaural_close_fx(&inputMc->tdRendWrapper.hBinRendererTd); + ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); inputMc->tdRendWrapper.hHrtfTD = NULL; } /* if we need to use TD renderer and CREND was open, close it */ - if (useTDRend) + if ( useTDRend ) { - ivas_rend_closeCrend(&inputMc->crendWrapper); + ivas_rend_closeCrend( &inputMc->crendWrapper ); } - if (!reconfigureFlag || (!useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL)) + if ( !reconfigureFlag || ( !useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL ) ) { - ivas_reverb_close(&inputMc->hReverb); + ivas_reverb_close( &inputMc->hReverb ); } - if (!reconfigureFlag || (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && !inputMc->base.ctx.pHeadRotData->headRotEnabled)) + if ( !reconfigureFlag || ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && !inputMc->base.ctx.pHeadRotData->headRotEnabled ) ) { - if (inputMc->efapInWrapper.hEfap != NULL) + if ( inputMc->efapInWrapper.hEfap != NULL ) { - efap_free_data(&inputMc->efapInWrapper.hEfap); + efap_free_data( &inputMc->efapInWrapper.hEfap ); } } outSampleRate = *inputMc->base.ctx.pOutSampleRate; - if (useTDRend && inputMc->tdRendWrapper.hBinRendererTd == NULL) + if ( useTDRend && inputMc->tdRendWrapper.hBinRendererTd == NULL ) { #ifdef IVAS_FLOAT_FIXED Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; @@ -3835,73 +3834,73 @@ static ivas_error initMcBinauralRendering( return error; } #endif - if (outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL) + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { #ifdef IVAS_FLOAT_FIXED - if ((error = ivas_reverb_open_fx(&(inputMc->hReverb), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate)) != IVAS_ERR_OK) + if ( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } #else - if ((error = ivas_reverb_open(&(inputMc->hReverb), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate)) != IVAS_ERR_OK) + if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } #endif } } - else if (!useTDRend && inputMc->crendWrapper == NULL) + else if ( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ #ifdef IVAS_FLOAT_FIXED /*Cleanup changes: float to fixed*/ - IF(hRendCfg) + IF( hRendCfg ) { - hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed(hRendCfg->roomAcoustics.acousticPreDelay, 27); - FOR(int i = 0; i < 60; i++) + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) { - hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32)(hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16); - hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32)((hRendCfg->roomAcoustics.pAcoustic_rt60[i]) * ONE_IN_Q26); - hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32)(hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30); + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); } - hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32)(hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27); - hRendCfg->roomAcoustics.dimensions.x_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.x * 4194304); // Q10.22, min value:1, max :999.0 - hRendCfg->roomAcoustics.dimensions.y_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.y * 4194304); // Q10.22 - hRendCfg->roomAcoustics.dimensions.z_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.z * 4194304); // Q10.22 + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 - FOR(int ii = 0; ii < 6; ii++) + FOR( int ii = 0; ii < 6; ii++ ) { - hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32)(hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824); // Q2.30 min :0 max 1 + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 } - hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304); //( 2147483648 >> 2 ); - hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.y * (4194304)); - hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.z * (4194304)); + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); } #endif // 1 - if ((error = ivas_rend_openCrend(&inputMc->crendWrapper, (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate)) != IVAS_ERR_OK) + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } } /* Initialise the EFAP handle for rotation on input layout */ - if (inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL) + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) { - if ((error = initEfap(&inputMc->efapInWrapper, inConfig, NULL)) != IVAS_ERR_OK) + if ( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ) != IVAS_ERR_OK ) { return error; } } /* determine binaural delay ( used for aligning LFE to output signal ) */ - binauralDelayNs = max((inputMc->crendWrapper != NULL) ? inputMc->crendWrapper->binaural_latency_ns : 0, inputMc->tdRendWrapper.binaural_latency_ns); - inputMc->binauralDelaySmp = (int16_t)roundf((float)binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f); + binauralDelayNs = max( ( inputMc->crendWrapper != NULL ) ? inputMc->crendWrapper->binaural_latency_ns : 0, inputMc->tdRendWrapper.binaural_latency_ns ); + inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); - if (inputMc->binauralDelaySmp > MAX_BIN_DELAY_SAMPLES) + if ( inputMc->binauralDelaySmp > MAX_BIN_DELAY_SAMPLES ) { - return IVAS_ERROR(IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)"); + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); } return IVAS_ERR_OK; @@ -3994,7 +3993,6 @@ static ivas_error initMcBinauralRendering( FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { fixedToFloat_arrL( Src_p->SrcSpatial_p->Pos_p_fx + nC * 3, Src_p->SrcSpatial_p->Pos_p + nC * 3, Q31, 3 ); - } Src_p->SrcSpatial_p->q_Pos_p = Q31; } @@ -4072,26 +4070,26 @@ static ivas_error initMcBinauralRendering( static ivas_error initMcMasaRendering( input_mc *inputMc, const AUDIO_CONFIG inConfig, - const Word32 inSampleRate) + const Word32 inSampleRate ) { ivas_error error; - IF (inputMc->tdRendWrapper.hBinRendererTd != NULL) + IF( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { - ivas_td_binaural_close_fx(&inputMc->tdRendWrapper.hBinRendererTd); + ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); inputMc->tdRendWrapper.hHrtfTD = NULL; } - ivas_rend_closeCrend(&inputMc->crendWrapper); + ivas_rend_closeCrend( &inputMc->crendWrapper ); - ivas_reverb_close(&inputMc->hReverb); + ivas_reverb_close( &inputMc->hReverb ); - IF (inputMc->efapInWrapper.hEfap != NULL) + IF( inputMc->efapInWrapper.hEfap != NULL ) { - efap_free_data(&inputMc->efapInWrapper.hEfap); + efap_free_data( &inputMc->efapInWrapper.hEfap ); } - IF ((error = ivas_mcmasa_ana_open(&inputMc->hMcMasa, inConfig, inSampleRate)) != IVAS_ERR_OK) + IF( ( error = ivas_mcmasa_ana_open( &inputMc->hMcMasa, inConfig, inSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -4130,7 +4128,7 @@ static ivas_error initMcMasaRendering( return error; } #ifdef IVAS_FLOAT_FIXED -#if 0 /*Fixed to float conversion for ivas_mcmasa_ana_open (to be removed later)*/ +#if 0 /*Fixed to float conversion for ivas_mcmasa_ana_open (to be removed later)*/ MCMASA_ANA_HANDLE hMcMasa = inputMc->hMcMasa; Word16 i, j; //fixedToFloat_arrL( hMcMasa->ls_azimuth_fx, hMcMasa->ls_azimuth, Q22, MCMASA_MAX_ANA_CHANS ); @@ -4285,21 +4283,21 @@ static ivas_error setRendInputActiveMc( rendCtx = inputMc->base.ctx; outConfig = *rendCtx.pOutConfig; - IF ( !isIoConfigPairSupported( inConfig, outConfig ) ) + IF( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } - IF ( ( error = allocateMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) + IF( ( error = allocateMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) { return error; } - IF((error = allocateInputBaseBufferData(&inputMc->bufferData, MAX_BUFFER_LENGTH)) != IVAS_ERR_OK) + IF( ( error = allocateInputBaseBufferData( &inputMc->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } - initRendInputBase(&inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH); + initRendInputBase( &inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH ); - IF ( ( error = allocateInputBaseBufferData_fx( &inputMc->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + IF( ( error = allocateInputBaseBufferData_fx( &inputMc->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } @@ -4320,23 +4318,23 @@ static ivas_error setRendInputActiveMc( set_val_Word32( inputMc->lfeDelayBuffer_fx, 0, MAX_BIN_DELAY_SAMPLES ); inputMc->binauralDelaySmp = 0; - IF (EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) + IF( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) { return error; } } - IF ( EQ_16(outConfig , IVAS_AUDIO_CONFIG_MASA1) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_MASA2 )) + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) { - IF ( ( error = initMcMasaRendering( inputMc, inConfig, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + IF( ( error = initMcMasaRendering( inputMc, inConfig, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = updateMcPanGains( inputMc, outConfig ) ) != IVAS_ERR_OK ) + IF( ( error = updateMcPanGains( inputMc, outConfig ) ) != IVAS_ERR_OK ) { return error; } @@ -4424,7 +4422,7 @@ static void clearInputMc( initRendInputBase_fx( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ - IF ( inputMc->efapInWrapper.hEfap != NULL ) + IF( inputMc->efapInWrapper.hEfap != NULL ) { efap_free_data( &inputMc->efapInWrapper.hEfap ); } @@ -4433,7 +4431,7 @@ static void clearInputMc( ivas_reverb_close( &inputMc->hReverb ); - IF ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) + IF( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); inputMc->tdRendWrapper.hHrtfTD = NULL; @@ -4800,13 +4798,13 @@ static ivas_error updateSbaPanGains( #ifdef IVAS_FLOAT_FIXED static ivas_error initSbaMasaRendering( input_sba *inputSba, - Word32 inSampleRate) + Word32 inSampleRate ) { ivas_error error; - ivas_rend_closeCrend(&inputSba->crendWrapper); + ivas_rend_closeCrend( &inputSba->crendWrapper ); - IF((error = ivas_dirac_ana_open_fx(&inputSba->hDirAC, inSampleRate)) != IVAS_ERR_OK) + IF( ( error = ivas_dirac_ana_open_fx( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -5049,50 +5047,50 @@ static ivas_error setRendInputActiveMasa( outConfig = *rendCtx.pOutConfig; (void) hRendCfg; /* Suppress warning */ - IF ( !isIoConfigPairSupported( inConfig, outConfig ) ) + IF( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } - IF ( ( error = allocateInputBaseBufferData_fx( &inputMasa->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + IF( ( error = allocateInputBaseBufferData_fx( &inputMasa->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } -#if 1/*To be removed later:(contains malloc for inputMasa->bufferData)*/ - IF ( ( error = allocateInputBaseBufferData( &inputMasa->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) +#if 1 /*To be removed later:(contains malloc for inputMasa->bufferData)*/ + IF( ( error = allocateInputBaseBufferData( &inputMasa->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } #endif initRendInputBase_fx( &inputMasa->base, inConfig, id, rendCtx, inputMasa->bufferData_fx, MAX_BUFFER_LENGTH ); - IF ( ( error = getAudioConfigNumChannels( inConfig, &numInChannels ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( inConfig, &numInChannels ) ) != IVAS_ERR_OK ) { return error; } - IF ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) + IF( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) { inputMasa->metadataHasBeenFed = false; - IF ( ( error = masaPrerendOpen_fx( &inputMasa->hMasaPrerend, EQ_16(inputMasa->base.inConfig , IVAS_AUDIO_CONFIG_MASA1) ? 1 : 2, *( inputMasa->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + IF( ( error = masaPrerendOpen_fx( &inputMasa->hMasaPrerend, EQ_16( inputMasa->base.inConfig, IVAS_AUDIO_CONFIG_MASA1 ) ? 1 : 2, *( inputMasa->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) { return error; } } ELSE { - IF ( ( error = initMasaExtRenderer( inputMasa, outConfig ) ) != IVAS_ERR_OK ) + IF( ( error = initMasaExtRenderer( inputMasa, outConfig ) ) != IVAS_ERR_OK ) { return error; } inputMasa->metadataHasBeenFed = false; } -#if 1 /*TODO: To be removed later(fixed to float)*/ +#if 1 /*TODO: To be removed later(fixed to float)*/ IF( inputMasa->hMasaExtRend ) { DIRAC_REND_HANDLE hDirACRend = inputMasa->hMasaExtRend->hDirACRend; - IF ( hDirACRend ) + IF( hDirACRend ) { FOR( int i = 0; i < hDirACRend->num_outputs_dir; i++ ) { @@ -5101,8 +5099,8 @@ static ivas_error setRendInputActiveMasa( IF( hDirACRend->hoa_encoder_fx ) fixedToFloat_arrL( hDirACRend->hoa_encoder_fx, hDirACRend->hoa_encoder, Q29, hDirACRend->hoa_encoder_len ); } - IF ( inputMasa->hMasaExtRend->hDiracDecBin ) - fixedToFloat_arrL( inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection_fx, inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection, (Word16) Q28 /*1.0f Q28*/, (Word16) CLDFB_NO_CHANNELS_MAX ); + IF( inputMasa->hMasaExtRend->hDiracDecBin ) + fixedToFloat_arrL( inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection_fx, inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection, (Word16) Q28 /*1.0f Q28*/, (Word16) CLDFB_NO_CHANNELS_MAX ); } inputMasa->base.inputBuffer.data = inputMasa->bufferData; fixedToFloat_arrL( inputMasa->base.inputBuffer.data_fx, inputMasa->base.inputBuffer.data, 0, MAX_BUFFER_LENGTH ); /*fixed to float only for set zero(that's why q0)*/ @@ -6864,43 +6862,43 @@ ivas_error IVAS_REND_FeedInputAudio_fx( Word16 numInputChannels; /* Validate function arguments */ - IF ( hIvasRend == NULL || inputAudio.data == NULL ) + IF( hIvasRend == NULL || inputAudio.data == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IF (LE_16( inputAudio.config.numSamplesPerChannel , 0 )|| LT_16(MAX_BUFFER_LENGTH_PER_CHANNEL , inputAudio.config.numSamplesPerChannel) ) + IF( LE_16( inputAudio.config.numSamplesPerChannel, 0 ) || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } - IF ( LE_16(inputAudio.config.numChannels , 0) ||LT_16( MAX_INPUT_CHANNELS , inputAudio.config.numChannels) ) + IF( LE_16( inputAudio.config.numChannels, 0 ) || LT_16( MAX_INPUT_CHANNELS, inputAudio.config.numChannels ) ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } - IF ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && - inputAudio.config.numSamplesPerChannel * 1000 != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + IF( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + inputAudio.config.numSamplesPerChannel * 1000 != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } - IF ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = getRendInputNumChannels( inputBase, &numInputChannels ) ) != IVAS_ERR_OK ) + IF( ( error = getRendInputNumChannels( inputBase, &numInputChannels ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA2 ) && inputBase->inConfig == IVAS_AUDIO_CONFIG_OBA ) + IF( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA2 ) && inputBase->inConfig == IVAS_AUDIO_CONFIG_OBA ) { numInputChannels = (Word16) hIvasRend->inputsIsm[0].total_num_objects; } - IF (NE_16( numInputChannels , inputAudio.config.numChannels )) + IF( NE_16( numInputChannels, inputAudio.config.numChannels ) ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } @@ -6913,6 +6911,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_OK; } + #endif /*-------------------------------------------------------------------* * IVAS_REND_FeedInputAudio() @@ -6973,7 +6972,10 @@ ivas_error IVAS_REND_FeedInputAudio( } inputBase->inputBuffer.config = inputAudio.config; +#ifdef IVAS_FLOAT_FIXED + mvr2r_Word32( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); +#endif mvr2r( inputAudio.data, inputBase->inputBuffer.data, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel; @@ -7434,8 +7436,25 @@ ivas_error IVAS_REND_SetHeadRotation( { rotQuat = headRot; } + Word32 updateRate_fx = 1677721600; // value is 200 in Q23 + rotQuat.w_fx = L_shl( rotQuat.w_fx, Q29 - rotQuat.q_fact ); + rotQuat.x_fx = L_shl( rotQuat.x_fx, Q29 - rotQuat.q_fact ); + rotQuat.y_fx = L_shl( rotQuat.y_fx, Q29 - rotQuat.q_fact ); + rotQuat.z_fx = L_shl( rotQuat.z_fx, Q29 - rotQuat.q_fact ); + hIvasRend->headRotData.hOrientationTracker->refRot.w_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->refRot.w_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->refRot.x_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->refRot.x_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->refRot.y_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->refRot.y_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->refRot.z_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->refRot.z_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.w_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->absAvgRot.w_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.x_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->absAvgRot.x_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.y_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->absAvgRot.y_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact ); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.z_fx = L_shl( hIvasRend->headRotData.hOrientationTracker->absAvgRot.z_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact ); + + hIvasRend->headRotData.hOrientationTracker->refRot.q_fact = Q29; + hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact = Q29; + rotQuat.q_fact = Q29; - IF( ( error = ivas_orient_trk_Process_fx( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[sf_idx] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_orient_trk_Process_fx( hIvasRend->headRotData.hOrientationTracker, rotQuat, updateRate_fx, &hIvasRend->headRotData.headPositions[sf_idx] ) ) != IVAS_ERR_OK ) { return error; } @@ -7543,7 +7562,7 @@ ivas_error IVAS_REND_SetReferenceRotation( ivas_error error; /* Validate function arguments */ - IF ( hIvasRend == NULL ) + IF( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -7552,7 +7571,7 @@ ivas_error IVAS_REND_SetReferenceRotation( error = ivas_orient_trk_SetReferenceRotation_fx( hIvasRend->headRotData.hOrientationTracker, refRot ); - IF ( error != IVAS_ERR_OK ) + IF( error != IVAS_ERR_OK ) { return error; @@ -7625,7 +7644,6 @@ ivas_error IVAS_REND_GetTrackedRotation( } #endif - /*---------------------------------------------------------------------* * IVAS_REND_SetReferenceVector( ) * @@ -7633,6 +7651,21 @@ ivas_error IVAS_REND_GetTrackedRotation( * available in OTR_TRACKING_REF_VEC and OTR_TRACKING_REF_VEC_LEV modes. *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_SetReferenceVector( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ +) +{ + IF( hIvasRend == NULL || hIvasRend->headRotData.hOrientationTracker == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + return ivas_orient_trk_SetReferenceVector_fx( hIvasRend->headRotData.hOrientationTracker, listenerPos, refPos ); +} +#else ivas_error IVAS_REND_SetReferenceVector( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_VECTOR3 listenerPos, /* i : Listener position */ @@ -7646,7 +7679,7 @@ ivas_error IVAS_REND_SetReferenceVector( return ivas_orient_trk_SetReferenceVector( hIvasRend->headRotData.hOrientationTracker, listenerPos, refPos ); } - +#endif /*---------------------------------------------------------------------* * IVAS_REND_SetExternalOrientation() @@ -7654,6 +7687,40 @@ ivas_error IVAS_REND_SetReferenceVector( * *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_SetExternalOrientation( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_QUATERNION *orientation, /* i : external orientation data */ + Word8 enableHeadRotation, /* i : flag to enable head rotation for this frame */ + Word8 enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + Word8 enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + Word16 numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const Word16 sf_idx /* i : subframe index */ +) +{ + /* Validate function arguments */ + IF (hIvasRend == NULL || hIvasRend->hExternalOrientationData == NULL) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF (orientation == NULL) + { + hIvasRend->hExternalOrientationData->enableExternalOrientation[sf_idx] = 0; + } + ELSE + { + QuaternionInverse_fx(*orientation, &hIvasRend->hExternalOrientationData->Quaternions[sf_idx]); + + hIvasRend->hExternalOrientationData->enableHeadRotation[sf_idx] = enableHeadRotation; + hIvasRend->hExternalOrientationData->enableExternalOrientation[sf_idx] = enableExternalOrientation; + hIvasRend->hExternalOrientationData->enableRotationInterpolation[sf_idx] = enableRotationInterpolation; + hIvasRend->hExternalOrientationData->numFramesToTargetOrientation[sf_idx] = numFramesToTargetOrientation; + } + + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *orientation, /* i : external orientation data */ @@ -7686,7 +7753,7 @@ ivas_error IVAS_REND_SetExternalOrientation( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * IVAS_REND_CombineHeadAndExternalOrientation() @@ -7698,7 +7765,7 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { - IF ( hIvasRend == NULL ) + IF( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -7855,7 +7922,7 @@ static void renderBufferChannelLerp_fx( /* Set output pointer to first output channel sample */ outSmpl = getSmplPtr_fx( outAudio, outChnlIdx, 0 ); - IF( gainsPrev == NULL || LE_32( abs( L_sub( L_shr(previousGain,1), L_shr(currentGain,1) ) ), EPSILON_FX ) ) + IF( gainsPrev == NULL || LE_32( abs( L_sub( L_shr( previousGain, 1 ), L_shr( currentGain, 1 ) ) ), EPSILON_FX ) ) { /* If no interpolation from previous frame, apply current gain */ DO @@ -8955,18 +9022,18 @@ static ivas_error renderIsmToMc( ismInput->previousPos.elevation_fx = L_shl( L_shr( L_add( ismInput->previousPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); - IF ( *ismInput->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_STEREO ) + IF( *ismInput->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_STEREO ) { - IF ( ismInput->nonDiegeticPan ) + IF( ismInput->nonDiegeticPan ) { - currentPanGains_fx[0] = L_add(L_shr(ismInput->nonDiegeticPanGain_fx,1),ONE_IN_Q30); - currentPanGains_fx[1] = L_sub(ONE_IN_Q31, currentPanGains_fx[0]); - ismInput->prev_pan_gains_fx[0] = currentPanGains_fx[0]; //Q31 - ismInput->prev_pan_gains_fx[1] = currentPanGains_fx[1]; //Q31 + currentPanGains_fx[0] = L_add( L_shr( ismInput->nonDiegeticPanGain_fx, 1 ), ONE_IN_Q30 ); + currentPanGains_fx[1] = L_sub( ONE_IN_Q31, currentPanGains_fx[0] ); + ismInput->prev_pan_gains_fx[0] = currentPanGains_fx[0]; // Q31 + ismInput->prev_pan_gains_fx[1] = currentPanGains_fx[1]; // Q31 } ELSE { - set32_fx( currentPanGains_fx, 0,MAX_OUTPUT_CHANNELS ); + set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); Word16 gains_fx[2]; Word16 azimuth_tmp, elevation_tmp; @@ -8975,28 +9042,28 @@ static ivas_error renderIsmToMc( elevation_tmp = extract_l( L_shr( ismInput->currentPos.elevation_fx, Q22 ) ); ivas_ism_get_stereo_gains_fx( azimuth_tmp, elevation_tmp, &gains_fx[0], &gains_fx[1] ); - currentPanGains_fx[0] = L_deposit_h( gains_fx[0] ); //Q31 - currentPanGains_fx[1] = L_deposit_h( gains_fx[1] ); //Q31 + currentPanGains_fx[0] = L_deposit_h( gains_fx[0] ); // Q31 + currentPanGains_fx[1] = L_deposit_h( gains_fx[1] ); // Q31 azimuth_tmp = extract_l( L_shr( ismInput->previousPos.azimuth_fx, Q22 ) ); elevation_tmp = extract_l( L_shr( ismInput->previousPos.elevation_fx, Q22 ) ); set32_fx( ismInput->prev_pan_gains_fx, 0, MAX_OUTPUT_CHANNELS ); ivas_ism_get_stereo_gains_fx( azimuth_tmp, elevation_tmp, &gains_fx[0], &gains_fx[1] ); - ismInput->prev_pan_gains_fx[0] = L_deposit_h( gains_fx[0] ); //Q31 - ismInput->prev_pan_gains_fx[1] = L_deposit_h( gains_fx[1] ); //Q31 + ismInput->prev_pan_gains_fx[0] = L_deposit_h( gains_fx[0] ); // Q31 + ismInput->prev_pan_gains_fx[1] = L_deposit_h( gains_fx[1] ); // Q31 } } ELSE { /* compute gains only if position changed */ - IF ( position_changed ) + IF( position_changed ) { // TODO tmu review when #215 is resolved - IF ( ( error = getEfapGains_fx( *ismInput->base.ctx.pEfapOutWrapper, - ismInput->currentPos.azimuth_fx, - ismInput->currentPos.elevation_fx, - currentPanGains_fx ) ) != IVAS_ERR_OK ) + IF( ( error = getEfapGains_fx( *ismInput->base.ctx.pEfapOutWrapper, + ismInput->currentPos.azimuth_fx, + ismInput->currentPos.elevation_fx, + currentPanGains_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -9007,9 +9074,9 @@ static ivas_error renderIsmToMc( { // TODO tmu review when #215 is resolved IF( ( error = getEfapGains_fx( *ismInput->base.ctx.pEfapOutWrapper, - ismInput->previousPos.azimuth_fx, - ismInput->previousPos.elevation_fx, - ismInput->prev_pan_gains_fx ) ) != IVAS_ERR_OK ) + ismInput->previousPos.azimuth_fx, + ismInput->previousPos.elevation_fx, + ismInput->prev_pan_gains_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -9020,9 +9087,9 @@ static ivas_error renderIsmToMc( /* Assume num channels in audio buffer to be 1. * This should have been validated in IVAS_REND_FeedInputAudio() */ renderBufferChannelLerp_fx( ismInput->base.inputBuffer, 0, - position_changed ? currentPanGains_fx : ismInput->prev_pan_gains_fx, - position_changed ? ismInput->prev_pan_gains_fx : NULL, - outAudio ); + position_changed ? currentPanGains_fx : ismInput->prev_pan_gains_fx, + position_changed ? ismInput->prev_pan_gains_fx : NULL, + outAudio ); IF( position_changed ) { @@ -9124,19 +9191,19 @@ static ivas_error renderIsmToSba( ivas_error error; error = IVAS_ERR_OK; - ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); + ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->currentPos.elevation_fx = L_shl( L_shr( L_add( ismInput->currentPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->previousPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->previousPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->previousPos.elevation_fx = L_shl( L_shr( L_add( ismInput->previousPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); push_wmops( "renderIsmToSba" ); - IF ( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = getAmbisonicsOrder( outConfig, &ambiOrderOut ) ) != IVAS_ERR_OK ) + IF( ( error = getAmbisonicsOrder( outConfig, &ambiOrderOut ) ) != IVAS_ERR_OK ) { return error; } @@ -9145,16 +9212,16 @@ static ivas_error renderIsmToSba( /* set previous gains if this is the first frame */ Word16 azimuth_tmp, elevation_tmp; - IF ( !ismInput->firstFrameRendered ) + IF( !ismInput->firstFrameRendered ) { // TODO tmu review when #215 is resolved - azimuth_tmp = extract_l(L_shr( ismInput->previousPos.azimuth_fx, Q22 )); - elevation_tmp = extract_l(L_shr( ismInput->previousPos.elevation_fx, Q22 )); + azimuth_tmp = extract_l( L_shr( ismInput->previousPos.azimuth_fx, Q22 ) ); + elevation_tmp = extract_l( L_shr( ismInput->previousPos.elevation_fx, Q22 ) ); ivas_dirac_dec_get_response_fixed( azimuth_tmp, elevation_tmp, ismInput->prev_pan_gains_fx, ambiOrderOut ); - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { ismInput->prev_pan_gains_fx[i] = L_shl_sat( ismInput->prev_pan_gains_fx[i], Q2 ); } @@ -9164,8 +9231,8 @@ static ivas_error renderIsmToSba( IF( position_changed ) { // TODO tmu review when #215 is resolved - azimuth_tmp = extract_l(L_shr( ismInput->currentPos.azimuth_fx, Q22 )); - elevation_tmp = extract_l(L_shr( ismInput->currentPos.elevation_fx, Q22 )); + azimuth_tmp = extract_l( L_shr( ismInput->currentPos.azimuth_fx, Q22 ) ); + elevation_tmp = extract_l( L_shr( ismInput->currentPos.elevation_fx, Q22 ) ); ivas_dirac_dec_get_response_fixed( azimuth_tmp, elevation_tmp, currentPanGains_fx, @@ -9179,14 +9246,14 @@ static ivas_error renderIsmToSba( /* Assume num channels in audio buffer to be 1. * This should have been validated in IVAS_REND_FeedInputAudio() */ renderBufferChannelLerp_fx( ismInput->base.inputBuffer, 0, - position_changed ? currentPanGains_fx : ismInput->prev_pan_gains_fx, - position_changed ? ismInput->prev_pan_gains_fx : NULL, - outAudio ); + position_changed ? currentPanGains_fx : ismInput->prev_pan_gains_fx, + position_changed ? ismInput->prev_pan_gains_fx : NULL, + outAudio ); - IF ( position_changed ) + IF( position_changed ) { Copy32( currentPanGains_fx, ismInput->prev_pan_gains_fx, MAX_OUTPUT_CHANNELS ); - //mvr2r( currentPanGains, ismInput->prev_pan_gains, MAX_OUTPUT_CHANNELS ); + // mvr2r( currentPanGains, ismInput->prev_pan_gains, MAX_OUTPUT_CHANNELS ); } pop_wmops(); @@ -9279,6 +9346,7 @@ static void renderIsmToMasa( Word16 guard_bits = find_guarded_bits_fx( L_FRAME48k ); max_e = input_e[0]; + FOR( i = 1; i < MAX_NUM_OBJECTS; i++ ) { IF( max_e < input_e[0] ) @@ -9300,7 +9368,7 @@ static void renderIsmToMasa( ivas_omasa_ana_fx( ismInput->hOMasa, tmpRendBuffer_fx, &q_fact, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels ); - *exp = q_fact; + *exp = q_fact; accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); @@ -9370,7 +9438,7 @@ static ivas_error renderInputIsm( ismInput->currentPos.elevation_fx = (Word32) ( ismInput->currentPos.elevation * ONE_IN_Q22 ); move32(); - fixedToFloat_arrL(ismInput->base.inputBuffer.data_fx, ismInput->base.inputBuffer.data,Q8, ismInput->base.inputBuffer.config.numSamplesPerChannel*ismInput->base.inputBuffer.config.numChannels); + fixedToFloat_arrL( ismInput->base.inputBuffer.data_fx, ismInput->base.inputBuffer.data, Q8, ismInput->base.inputBuffer.config.numSamplesPerChannel * ismInput->base.inputBuffer.config.numChannels ); floatToFixed_arrL( ismInput->prev_pan_gains, ismInput->prev_pan_gains_fx, Q31, MAX_OUTPUT_CHANNELS ); ismInput->nonDiegeticPanGain_fx = floatToFixed_32( ismInput->nonDiegeticPanGain, Q31 ); @@ -9454,7 +9522,7 @@ static ivas_error renderInputIsm( #else renderIsmToMasa( ismInput, outAudio ); #endif - break; + break; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } @@ -10392,7 +10460,7 @@ static ivas_error renderInputMc( inAudio = mcInput->base.inputBuffer; - IF ( NE_32(mcInput->base.numNewSamplesPerChannel , outAudio.config.numSamplesPerChannel) ) + IF( NE_32( mcInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -10403,7 +10471,7 @@ static ivas_error renderInputMc( /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); - SWITCH ( getAudioConfigType( outConfig ) ) + SWITCH( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: renderMcToMc( mcInput, outAudio ); @@ -10412,21 +10480,20 @@ static ivas_error renderInputMc( renderMcToSba( mcInput, outAudio ); BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: - SWITCH ( outConfig ) + SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: error = renderMcToBinaural( mcInput, outConfig, outAudio ); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: - IF ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); } ELSE { error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); - } BREAK; default: @@ -10512,13 +10579,13 @@ static ivas_error renderActiveInputsMc( ivas_error error; for ( i = 0, pCurrentInput = hIvasRend->inputsMc; i < RENDERER_MAX_MC_INPUTS; ++i, ++pCurrentInput ) { - IF ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + IF( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) { /* Skip inactive inputs */ CONTINUE; } - IF ( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) + IF( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; } @@ -11182,8 +11249,77 @@ static ivas_error renderActiveInputsSba( return IVAS_ERR_OK; } +#endif +#ifdef IVAS_FLOAT_FIXED +static void copyMasaMetadataToDiracRenderer_fx( + MASA_METADATA_FRAME *meta, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + const int16_t maxBin ) +{ + Word16 band, sf, bin; + Word16 meta_write_index; + + hSpatParamRendCom->numParametricDirections = meta->descriptive_meta.numberOfDirections + 1; + hSpatParamRendCom->numSimultaneousDirections = meta->descriptive_meta.numberOfDirections + 1; + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + meta_write_index = ( hSpatParamRendCom->dirac_bs_md_write_idx + sf ) % hSpatParamRendCom->dirac_md_buffer_length; + + FOR( band = 0; band < MASA_MAXIMUM_CODING_SUBBANDS; band++ ) + { + FOR( bin = MASA_band_grouping_24[band]; bin < MASA_band_grouping_24[band + 1] && bin < maxBin; bin++ ) + { + // hSpatParamRendCom->azimuth[meta_write_index][bin] = (Word16) L_shr( meta->directional_meta[0].azimuth_fx[sf][band], Q22 ); + // hSpatParamRendCom->elevation[meta_write_index][bin] = (Word16) L_shr( meta->directional_meta[0].elevation_fx[sf][band], Q22 ); + hSpatParamRendCom->energy_ratio1_fx[meta_write_index][bin] = meta->directional_meta[0].energy_ratio_fx[sf][band]; + hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][bin] = L_sub( ONE_IN_Q30, meta->directional_meta[0].energy_ratio_fx[sf][band] ); + hSpatParamRendCom->spreadCoherence_fx[meta_write_index][bin] = meta->directional_meta[0].spread_coherence_fx[sf][band]; + hSpatParamRendCom->surroundingCoherence_fx[meta_write_index][bin] = meta->common_meta.surround_coherence_fx[sf][band]; +#if 0 // Tobe removed after masa the path is complete + hSpatParamRendCom->energy_ratio1[meta_write_index][bin] = (float) hSpatParamRendCom->energy_ratio1_fx[meta_write_index][bin] / ONE_IN_Q30; + hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] = (float) hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][bin] / ONE_IN_Q30; + hSpatParamRendCom->spreadCoherence[meta_write_index][bin] = (float) hSpatParamRendCom->spreadCoherence_fx[meta_write_index][bin] / ONE_IN_Q15; + hSpatParamRendCom->surroundingCoherence[meta_write_index][bin] = (float) hSpatParamRendCom->surroundingCoherence_fx[meta_write_index][bin] / ONE_IN_Q15; +#else + hSpatParamRendCom->azimuth[meta_write_index][bin] = (int16_t) meta->directional_meta[0].azimuth[sf][band]; + hSpatParamRendCom->elevation[meta_write_index][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band]; + hSpatParamRendCom->energy_ratio1[meta_write_index][bin] = meta->directional_meta[0].energy_ratio[sf][band]; + hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band]; + hSpatParamRendCom->spreadCoherence[meta_write_index][bin] = meta->directional_meta[0].spread_coherence[sf][band]; + hSpatParamRendCom->surroundingCoherence[meta_write_index][bin] = meta->common_meta.surround_coherence[sf][band]; + #endif + IF( hSpatParamRendCom->numSimultaneousDirections == 2 ) + { + // hSpatParamRendCom->azimuth2[meta_write_index][bin] = (Word16) L_shr( meta->directional_meta[1].azimuth_fx[sf][band], Q22 ); + // hSpatParamRendCom->elevation2[meta_write_index][bin] = (Word16) L_shr( meta->directional_meta[1].elevation[sf][band], Q22 ); + hSpatParamRendCom->energy_ratio2_fx[meta_write_index][bin] = meta->directional_meta[1].energy_ratio_fx[sf][band]; + hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][bin] = L_sub( hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][bin], meta->directional_meta[1].energy_ratio_fx[sf][band] ); + hSpatParamRendCom->spreadCoherence2_fx[meta_write_index][bin] = meta->directional_meta[1].spread_coherence_fx[sf][band]; +#if 0 // Tobe removed after the masa path is complete + hSpatParamRendCom->energy_ratio2[meta_write_index][bin] = (float) hSpatParamRendCom->energy_ratio2_fx[meta_write_index][bin] / ONE_IN_Q30; + hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] = (float) hSpatParamRendCom->diffuseness_vector_fx[meta_write_index][bin] / ONE_IN_Q30; + hSpatParamRendCom->spreadCoherence2[meta_write_index][bin] = (float) hSpatParamRendCom->spreadCoherence2_fx[meta_write_index][bin] / ONE_IN_Q15; +#else + hSpatParamRendCom->azimuth2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].azimuth[sf][band]; + hSpatParamRendCom->elevation2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band]; + hSpatParamRendCom->energy_ratio2[meta_write_index][bin] = meta->directional_meta[1].energy_ratio[sf][band]; + hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] -= meta->directional_meta[1].energy_ratio[sf][band]; + hSpatParamRendCom->spreadCoherence2[meta_write_index][bin] = meta->directional_meta[1].spread_coherence[sf][band]; + +#endif + } + } + } + } + + hSpatParamRendCom->dirac_bs_md_write_idx = ( hSpatParamRendCom->dirac_bs_md_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hSpatParamRendCom->dirac_md_buffer_length; + + return; +} +#else static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -11226,8 +11362,178 @@ static void copyMasaMetadataToDiracRenderer( return; } +#endif +#ifdef IVAS_FLOAT_FIXED +static void renderMasaToMasa( + input_masa *masaInput, + IVAS_REND_AudioBuffer outAudio ) +{ + Word16 sf, band, dir, numDirs; + Word32 ratioSum_fx; + MASA_DECODER_EXT_OUT_META_HANDLE outMeta; + MASA_METADATA_FRAME *inMeta; + Word32 tmpBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word16 ts, i, j, l_ts; + Word32 Chan_RealBuffer_fx[MASA_MAX_TRANSPORT_CHANNELS][CLDFB_NO_CHANNELS_MAX]; + Word32 Chan_ImagBuffer_fx[MASA_MAX_TRANSPORT_CHANNELS][CLDFB_NO_CHANNELS_MAX]; + Word16 band_m_idx, block_m_idx; + Word16 mrange[2]; + Word16 brange[2]; + Word16 numAnalysisChannels; + Word16 tmp_energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_fx ); + Word16 q_cldfb = *outAudio.pq_fact; + Word16 q_cldfb_out = *outAudio.pq_fact; + Word16 scale_factor = 31; + move16(); + /* Calculate energy */ + l_ts = masaInput->base.inputBuffer.config.numSamplesPerChannel / CLDFB_NO_COL_MAX; + numAnalysisChannels = masaInput->hMasaPrerend->num_Cldfb_instances; + /* do processing over all CLDFB time slots */ + FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) + { + mrange[0] = DirAC_block_grouping[block_m_idx]; + mrange[1] = DirAC_block_grouping[block_m_idx + 1]; + + set_zero_fx( masaInput->hMasaPrerend->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS ); + + FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) + { + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_factor = 31; + move16(); + masaInput->hMasaPrerend->cldfbAnaEnc[i]->Q_cldfb_state = q_cldfb; + q_cldfb_out = q_cldfb; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( tmpBuffer_fx[i][l_ts * ts] ), Chan_RealBuffer_fx[i], Chan_ImagBuffer_fx[i], l_ts, masaInput->hMasaPrerend->cldfbAnaEnc[i], &q_cldfb_out ); + scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ) ); + scale_factor = sub( scale_factor, 1 ); + scale_sig32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); // Q17 + scale_sig32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); // Q17 + } + + Word16 q_add = sub(31 , add( scale_factor , q_cldfb_out )); + /* Compute channel energy for metadata processing */ + FOR( band_m_idx = 0; band_m_idx < MASA_FREQUENCY_BANDS; band_m_idx++ ) + { + brange[0] = MASA_band_grouping_24[band_m_idx]; + move16(); + brange[1] = MASA_band_grouping_24[band_m_idx + 1]; + move16(); + FOR( j = brange[0]; j < brange[1]; j++ ) + { + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + Word32 temp = L_add( Mult_32_32( Chan_RealBuffer_fx[0][j], Chan_RealBuffer_fx[0][j] ), Mult_32_32( Chan_ImagBuffer_fx[0][j], Chan_ImagBuffer_fx[0][j] ) ); + masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], tmp_energy_e[block_m_idx][band_m_idx], temp, ( 2 * q_add ), &tmp_energy_e[block_m_idx][band_m_idx] ); + } + } + } + } + } + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + Word16 max_e = MIN_16; + move16(); + FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) + { + + max_e = s_max( max_e, tmp_energy_e[i][j] ); + } + masaInput->hMasaPrerend->energy_e[i] = max_e; + move16(); + FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) + { + + masaInput->hMasaPrerend->energy_fx[i][j] = L_shr( masaInput->hMasaPrerend->energy_fx[i][j], sub( max_e, tmp_energy_e[i][j] ) ); + } + } + /* Copy audio channels if mismatch in number of transports */ + IF( masaInput->base.inputBuffer.config.numChannels == 1 && outAudio.config.numChannels == 2 ) + { + mvr2r_Word32( tmpBuffer_fx[0], tmpBuffer_fx[1], masaInput->base.inputBuffer.config.numSamplesPerChannel ); + } + ELSE IF( masaInput->base.inputBuffer.config.numChannels == 2 && outAudio.config.numChannels == 1 ) + { + // v_add( tmpBuffer[0], tmpBuffer[1], tmpBuffer[0], masaInput->base.inputBuffer.config.numSamplesPerChannel ); + v_add_fixed( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel, 0 ); + } + + /* Copy metadata */ + outMeta = masaInput->hMasaPrerend->hMasaOut; + inMeta = &masaInput->masaMetadata; + numDirs = inMeta->descriptive_meta.numberOfDirections + 1; + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + /* Remainder is always set to zero and energy removal is compensated in following steps + * to other ratios. */ + // inMeta->common_meta.remainder_to_total_ratio[sf][band] = 0.0f; + inMeta->common_meta.remainder_to_total_ratio_fx[sf][band] = 0; + move32(); + ratioSum_fx = 0; + move32(); + FOR( dir = 0; dir < numDirs; dir++ ) + { + ratioSum_fx = L_add( ratioSum_fx, inMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); + } + ratioSum_fx = L_add( ratioSum_fx, inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); + IF( EQ_32(ratioSum_fx , 0 )) + { + FOR( dir = 0; dir < numDirs; dir++ ) + { + inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = 0; + } + inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; + } + ELSE IF( NE_32(ratioSum_fx , ONE_IN_Q30) ) + { + Word16 tmp_e = 0; + move16(); + Word32 tmp = 0; + move32(); + FOR( dir = 0; dir < numDirs; dir++ ) + { + tmp = BASOP_Util_Divide3232_Scale_cadence( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); + inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, tmp_e - 1 ); // Q30 + } + tmp_e = 0; + move16(); + tmp = 0; + move32(); + tmp = BASOP_Util_Divide3232_Scale_cadence( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); + inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, tmp_e - 1 ); // Q30 + } + } + } + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + outMeta->diffuseToTotalRatio[sf][band] = UINT8_MAX; + FOR( dir = 0; dir < numDirs; dir++ ) + { + outMeta->directionIndex[dir][sf][band] = index_theta_phi_16_fx( &inMeta->directional_meta[dir].elevation_fx[sf][band], &inMeta->directional_meta[dir].azimuth_fx[sf][band], masaInput->hMasaPrerend->sph_grid16 ); + outMeta->directToTotalRatio[dir][sf][band] = (UWord8) L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], 22 ); + outMeta->diffuseToTotalRatio[sf][band] -= outMeta->directToTotalRatio[dir][sf][band]; + outMeta->spreadCoherence[dir][sf][band] = (UWord8) shr( inMeta->directional_meta[dir].spread_coherence_fx[sf][band], Q7 ); + } + outMeta->surroundCoherence[sf][band] = (UWord8) shr( inMeta->common_meta.surround_coherence_fx[sf][band], Q7 ); + } + } + + copy_masa_descriptive_meta( &( outMeta->descriptiveMeta ), &( inMeta->descriptive_meta ) ); + + accumulate2dArrayToBuffer_fx( tmpBuffer_fx, &outAudio ); + + return; +} +#else static void renderMasaToMasa( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) @@ -11353,7 +11659,7 @@ static void renderMasaToMasa( return; } - +#endif static ivas_error renderInputMasa( input_masa *masaInput, @@ -11365,7 +11671,10 @@ static ivas_error renderInputMasa( int16_t maxBin; float *tmpBuffer[MAX_OUTPUT_CHANNELS]; float tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - +#ifndef IVAS_FLOAT_FIXED + Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; + Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; +#endif if ( !masaInput->metadataHasBeenFed ) { return IVAS_ERR_MISSING_METADATA; @@ -11380,7 +11689,11 @@ static ivas_error renderInputMasa( #ifdef IVAS_FLOAT_FIXED masaInput->base.gain = fix_to_float( masaInput->base.gain_fx, Q30 ); -#endif // IVAS_FLOAT_FIXED + *outAudio.pq_fact = outAudio.q_factor; + /* Apply input gain to new audio */ + v_multc_fixed( inAudio.data_fx, masaInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + *outAudio.pq_fact -= 1; // to compensate for the qfactor reduction in gain multiplication. +#endif // IVAS_FLOAT_FIXED /* Apply input gain to new audio */ v_multc( inAudio.data, masaInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); @@ -11394,6 +11707,10 @@ static ivas_error renderInputMasa( { /* MASA prerendering path for MASA -> MASA */ renderMasaToMasa( masaInput, outAudio ); + for ( Word16 i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) + { + outAudio.data[i] = (float) outAudio.data_fx[i] / ( 1 << *outAudio.pq_fact ); + } } else { @@ -11403,7 +11720,13 @@ static ivas_error renderInputMasa( { tmpBuffer[ch] = tmpBuffer_buff[ch]; } - +#ifndef IVAS_FLOAT_FIXED + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBuffer_fx[ch] = tmpBuffer_buff_fx[ch]; + } + copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); +#endif copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); @@ -11411,13 +11734,13 @@ static ivas_error renderInputMasa( switch ( masaInput->hMasaExtRend->renderer_type ) { case RENDERER_DIRAC: - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); ivas_masa_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer, num_subframes ); break; case RENDERER_STEREO_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes ); break; case RENDERER_DISABLE: @@ -11460,16 +11783,17 @@ static ivas_error renderActiveInputsMasa( { return error; } - } #ifdef IVAS_FLOAT_FIXED - if ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) - { - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) + if ( ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) && ( getAudioConfigType( hIvasRend->outputConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { - outAudio.data_fx[i] = (Word32) outAudio.data[i] * ( 1 << *outAudio.pq_fact ); + for ( Word16 k = 0; k < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; k++ ) + { + outAudio.data_fx[k] = (Word32) outAudio.data[k] * ( 1 << *outAudio.pq_fact ); + } } - } #endif + } + return IVAS_ERR_OK; } @@ -11567,8 +11891,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( #endif Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 *inEne1_e; - Word16 *inEne2_e; + Word16 *inEne1_e; + Word16 *inEne2_e; if ( hIvasRend == NULL ) { @@ -11581,14 +11905,14 @@ ivas_error IVAS_REND_MergeMasaMetadata( *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne1 = &( hIvasRend->inputsIsm->hOMasa->energy ); #ifdef IVAS_FLOAT_FIXED - inEne1_fx = &(hIvasRend->inputsIsm->hOMasa->energy_fx); - inEne1_e = (hIvasRend->inputsIsm->hOMasa->energy_e); + inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); + inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) - { - f2me_buf(hIvasRend->inputsIsm->hOMasa->energy[i], hIvasRend->inputsIsm->hOMasa->energy_fx[i], &hIvasRend->inputsIsm->hOMasa->energy_e[i], MASA_FREQUENCY_BANDS); - } + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + f2me_buf( hIvasRend->inputsIsm->hOMasa->energy[i], hIvasRend->inputsIsm->hOMasa->energy_fx[i], &hIvasRend->inputsIsm->hOMasa->energy_e[i], MASA_FREQUENCY_BANDS ); + } #endif } else if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) @@ -11597,12 +11921,12 @@ ivas_error IVAS_REND_MergeMasaMetadata( inEne1 = &( hIvasRend->inputsMc->hMcMasa->energy ); #ifdef IVAS_FLOAT_FIXED inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne1_e = (hIvasRend->inputsMc->hMcMasa->energy_exp); + inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) - { - f2me_buf(hIvasRend->inputsMc->hMcMasa->energy[i], hIvasRend->inputsMc->hMcMasa->energy_fx[i], &hIvasRend->inputsMc->hMcMasa->energy_exp[i], MASA_FREQUENCY_BANDS); - } + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + f2me_buf( hIvasRend->inputsMc->hMcMasa->energy[i], hIvasRend->inputsMc->hMcMasa->energy_fx[i], &hIvasRend->inputsMc->hMcMasa->energy_exp[i], MASA_FREQUENCY_BANDS ); + } #endif } else if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) @@ -11610,12 +11934,12 @@ ivas_error IVAS_REND_MergeMasaMetadata( *hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne1 = &( hIvasRend->inputsSba->hDirAC->energy ); #ifdef IVAS_FLOAT_FIXED - inEne1_fx = &(hIvasRend->inputsSba->hDirAC->energy_fx); - inEne1_e = (hIvasRend->inputsSba->hDirAC->energy_exp); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) - { - f2me_buf(hIvasRend->inputsSba->hDirAC->energy[i], hIvasRend->inputsSba->hDirAC->energy_fx[i], &hIvasRend->inputsSba->hDirAC->energy_exp[i], MASA_FREQUENCY_BANDS); - } + inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); + inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + f2me_buf( hIvasRend->inputsSba->hDirAC->energy[i], hIvasRend->inputsSba->hDirAC->energy_fx[i], &hIvasRend->inputsSba->hDirAC->energy_exp[i], MASA_FREQUENCY_BANDS ); + } #endif } @@ -11625,10 +11949,10 @@ ivas_error IVAS_REND_MergeMasaMetadata( inEne1 = &( hIvasRend->inputsMasa->hMasaPrerend->energy ); #ifdef IVAS_FLOAT_FIXED inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne1_e = (hIvasRend->inputsMasa->hMasaPrerend->energy_e); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - f2me_buf(hIvasRend->inputsMasa->hMasaPrerend->energy[i], hIvasRend->inputsMasa->hMasaPrerend->energy_fx[i], &hIvasRend->inputsMasa->hMasaPrerend->energy_e[i], MASA_FREQUENCY_BANDS); + f2me_buf( hIvasRend->inputsMasa->hMasaPrerend->energy[i], hIvasRend->inputsMasa->hMasaPrerend->energy_fx[i], &hIvasRend->inputsMasa->hMasaPrerend->energy_e[i], MASA_FREQUENCY_BANDS ); } #endif } @@ -11645,12 +11969,12 @@ ivas_error IVAS_REND_MergeMasaMetadata( inEne2 = &( hIvasRend->inputsIsm->hOMasa->energy ); #endif #ifdef IVAS_FLOAT_FIXED - inEne2_fx = &(hIvasRend->inputsIsm->hOMasa->energy_fx); - inEne2_e = (hIvasRend->inputsIsm->hOMasa->energy_e); + inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); + inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - f2me_buf(hIvasRend->inputsIsm->hOMasa->energy[i], hIvasRend->inputsIsm->hOMasa->energy_fx[i], &hIvasRend->inputsIsm->hOMasa->energy_e[i], MASA_FREQUENCY_BANDS); + f2me_buf( hIvasRend->inputsIsm->hOMasa->energy[i], hIvasRend->inputsIsm->hOMasa->energy_fx[i], &hIvasRend->inputsIsm->hOMasa->energy_e[i], MASA_FREQUENCY_BANDS ); } #endif @@ -11663,10 +11987,10 @@ ivas_error IVAS_REND_MergeMasaMetadata( #endif #ifdef IVAS_FLOAT_FIXED inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne2_e = (hIvasRend->inputsMc->hMcMasa->energy_exp); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - f2me_buf(hIvasRend->inputsMc->hMcMasa->energy[i], hIvasRend->inputsMc->hMcMasa->energy_fx[i], &hIvasRend->inputsMc->hMcMasa->energy_exp[i], MASA_FREQUENCY_BANDS); + f2me_buf( hIvasRend->inputsMc->hMcMasa->energy[i], hIvasRend->inputsMc->hMcMasa->energy_fx[i], &hIvasRend->inputsMc->hMcMasa->energy_exp[i], MASA_FREQUENCY_BANDS ); } #endif } @@ -11678,10 +12002,10 @@ ivas_error IVAS_REND_MergeMasaMetadata( #endif #ifdef IVAS_FLOAT_FIXED inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne2_e = (hIvasRend->inputsSba->hDirAC->energy_exp); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - f2me_buf(hIvasRend->inputsSba->hDirAC->energy[i], hIvasRend->inputsSba->hDirAC->energy_fx[i], &hIvasRend->inputsSba->hDirAC->energy_exp[i], MASA_FREQUENCY_BANDS); + f2me_buf( hIvasRend->inputsSba->hDirAC->energy[i], hIvasRend->inputsSba->hDirAC->energy_fx[i], &hIvasRend->inputsSba->hDirAC->energy_exp[i], MASA_FREQUENCY_BANDS ); } #endif } @@ -11693,10 +12017,10 @@ ivas_error IVAS_REND_MergeMasaMetadata( #endif #ifdef IVAS_FLOAT_FIXED inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne2_e = (hIvasRend->inputsMasa->hMasaPrerend->energy_e); - for (Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - f2me_buf(hIvasRend->inputsMasa->hMasaPrerend->energy[i], hIvasRend->inputsMasa->hMasaPrerend->energy_fx[i], &hIvasRend->inputsMasa->hMasaPrerend->energy_e[i], MASA_FREQUENCY_BANDS); + f2me_buf( hIvasRend->inputsMasa->hMasaPrerend->energy[i], hIvasRend->inputsMasa->hMasaPrerend->energy_fx[i], &hIvasRend->inputsMasa->hMasaPrerend->energy_e[i], MASA_FREQUENCY_BANDS ); } #endif @@ -11710,16 +12034,16 @@ ivas_error IVAS_REND_MergeMasaMetadata( #ifdef IVAS_FLOAT_FIXED ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e ); - FOR(Word32 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++) + FOR( Word32 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - me2f_buf((*inEne1_fx)[i], inEne1_e[i], (*inEne1)[i], MASA_FREQUENCY_BANDS); + me2f_buf( ( *inEne1_fx )[i], inEne1_e[i], ( *inEne1 )[i], MASA_FREQUENCY_BANDS ); } #else ivas_prerend_merge_masa_metadata( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1, inMeta2, inputType2, *inEne2 ); ( *hMasaExtOutMeta )->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 ? 0u : 1u; #endif - (*hMasaExtOutMeta)->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 ? 0u : 1u; + ( *hMasaExtOutMeta )->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 ? 0u : 1u; return IVAS_ERR_OK; } @@ -12114,8 +12438,8 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( Word16 nchan_out_woLFE; Word16 nchan_transport; UWord16 i, j, k; - Word32 ls_azimuth_fx[MAX_OUTPUT_CHANNELS];/*Q22*/ - Word32 ls_elevation_fx[MAX_OUTPUT_CHANNELS];/*Q22*/ + Word32 ls_azimuth_fx[MAX_OUTPUT_CHANNELS]; /*Q22*/ + Word32 ls_elevation_fx[MAX_OUTPUT_CHANNELS]; /*Q22*/ Word32 output_Fs; ivas_error error; DIRAC_REND_HANDLE hDirACRend; @@ -12133,12 +12457,12 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( * prepare library opening *-----------------------------------------------------------------*/ - IF ( ( hDirACRend = (DIRAC_REND_HANDLE) malloc( sizeof( DIRAC_REND_DATA ) ) ) == NULL ) + IF( ( hDirACRend = (DIRAC_REND_HANDLE) malloc( sizeof( DIRAC_REND_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC renderer\n" ) ); } - nchan_transport = EQ_16(inputMasa->base.inConfig , IVAS_AUDIO_CONFIG_MASA2) ? 2 : 1; + nchan_transport = EQ_16( inputMasa->base.inConfig, IVAS_AUDIO_CONFIG_MASA2 ) ? 2 : 1; /*-----------------------------------------------------------------* * output setup: for parametric binaural renderer, use output setup, otherwise internal setup @@ -12146,12 +12470,12 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( ivas_output_init( &hDirACRend->hOutSetup, *inputMasa->base.ctx.pOutConfig ); - IF ( EQ_16(hDirACRend->hOutSetup.output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) ) + IF( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { /* Copy from ivas_ls_custom_setup */ hDirACRend->hOutSetup.nchan_out_woLFE = inputMasa->base.ctx.pCustomLsOut->num_spk; move16(); -#if 1/*TODO: To be removed later(floating buffer init)*/ +#if 1 /*TODO: To be removed later(floating buffer init)*/ hDirACRend->hOutSetup.ls_azimuth = inputMasa->base.ctx.pCustomLsOut->ls_azimuth; hDirACRend->hOutSetup.ls_elevation = inputMasa->base.ctx.pCustomLsOut->ls_elevation; #endif @@ -12172,23 +12496,23 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( nchan_out_woLFE = hDirACRend->hOutSetup.nchan_out_woLFE; move16(); - IF ( hDirACRend->hOutSetup.ls_azimuth != NULL && hDirACRend->hOutSetup.ls_elevation != NULL ) + IF( hDirACRend->hOutSetup.ls_azimuth != NULL && hDirACRend->hOutSetup.ls_elevation != NULL ) { Copy32( hDirACRend->hOutSetup.ls_azimuth_fx, ls_azimuth_fx, nchan_out_woLFE ); Copy32( hDirACRend->hOutSetup.ls_elevation_fx, ls_elevation_fx, nchan_out_woLFE ); } - IF ( EQ_16(hDirACRend->hOutSetup.ambisonics_order , -1) ) + IF( EQ_16( hDirACRend->hOutSetup.ambisonics_order, -1 ) ) { hDirACRend->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; /* Order 3 is used by default in DirAC for SHD processing */ move16(); - IF ( EQ_16(hDirACRend->hOutSetup.output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(hDirACRend->hOutSetup.output_config , IVAS_AUDIO_CONFIG_STEREO) ) + IF( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { hDirACRend->hOutSetup.ambisonics_order = SBA_FOA_ORDER; move16(); } } - ELSE IF ( GE_16(hDirACRend->hOutSetup.ambisonics_order , SBA_FOA_ORDER) ) + ELSE IF( GE_16( hDirACRend->hOutSetup.ambisonics_order, SBA_FOA_ORDER ) ) { Copy32( ls_azimuth_4d4_fx, ls_azimuth_fx, DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS ); Copy32( ls_elevation_4d4_fx, ls_elevation_fx, DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS ); @@ -12198,19 +12522,19 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( * set input parameters *-----------------------------------------------------------------*/ - IF ( EQ_16(hDirACRend->hOutSetup.output_config , IVAS_AUDIO_CONFIG_MONO) ) + IF( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_MONO ) ) { hDirACRend->synthesisConf = DIRAC_SYNTHESIS_MONO; hDirACRend->panningConf = DIRAC_PANNING_HOA3; nchan_out_woLFE = 1; move16(); } - ELSE IF ( hDirACRend->hOutSetup.is_loudspeaker_setup ) + ELSE IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { hDirACRend->synthesisConf = DIRAC_SYNTHESIS_PSD_LS; hDirACRend->panningConf = DIRAC_PANNING_VBAP; } - ELSE IF ( !hDirACRend->hOutSetup.is_loudspeaker_setup && GT_16(nchan_transport , 1) ) + ELSE IF( !hDirACRend->hOutSetup.is_loudspeaker_setup && GT_16( nchan_transport, 1 ) ) { hDirACRend->synthesisConf = DIRAC_SYNTHESIS_PSD_SHD; hDirACRend->panningConf = DIRAC_PANNING_HOA3; @@ -12221,8 +12545,8 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( hDirACRend->panningConf = DIRAC_PANNING_HOA3; } -#if 1/*TODO: To be removed later(floating buffer malloc and init)*/ - IF ( ( hDirACRend->frequency_axis = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) +#if 1 /*TODO: To be removed later(floating buffer malloc and init)*/ + IF( ( hDirACRend->frequency_axis = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } @@ -12237,9 +12561,9 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( ivas_dirac_dec_get_frequency_axis_fx( hDirACRend->frequency_axis_fx, output_Fs, hSpatParamRendCom->num_freq_bands ); - IF ( EQ_16(hDirACRend->panningConf , DIRAC_PANNING_HOA3) && EQ_16(nchan_transport , 2) ) + IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_HOA3 ) && EQ_16( nchan_transport, 2 ) ) { - IF ( ( hDirACRend->masa_stereo_type_detect = (MASA_STEREO_TYPE_DETECT *) malloc( sizeof( MASA_STEREO_TYPE_DETECT ) ) ) == NULL ) + IF( ( hDirACRend->masa_stereo_type_detect = (MASA_STEREO_TYPE_DETECT *) malloc( sizeof( MASA_STEREO_TYPE_DETECT ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } @@ -12259,25 +12583,25 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* prototype signal computation */ /* allocate output setup related arrays */ - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_LS) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) { /* Directional and diffuses components in output LS format */ hDirACRend->num_outputs_diff = nchan_out_woLFE; hDirACRend->num_outputs_dir = nchan_out_woLFE; } - ELSE IF (EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_GAIN_SHD) ) + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { /* Directional and diffuses components in SHD */ /* Diffuseness components up to 1st order */ hDirACRend->num_outputs_diff = ( min( hDirACRend->hOutSetup.ambisonics_order, 1 ) + 1 ) * ( min( hDirACRend->hOutSetup.ambisonics_order, 1 ) + 1 ); hDirACRend->num_outputs_dir = ivas_sba_get_nchan( hDirACRend->hOutSetup.ambisonics_order, 0 ); } - ELSE IF (EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_SHD) ) + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { hDirACRend->num_outputs_diff = DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS; hDirACRend->num_outputs_dir = nchan_out_woLFE; } - ELSE IF (EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_MONO) ) + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { hDirACRend->num_outputs_diff = 1; /* There is one output channel in mono */ hDirACRend->num_outputs_dir = 2; /* Two channels are pre-rendered for stereo type detection */ @@ -12289,12 +12613,12 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); move16(); - IF ( ( hDirACRend->proto_index_dir = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_dir ) ) == NULL ) + IF( ( hDirACRend->proto_index_dir = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } - IF ( ( hDirACRend->proto_index_diff = (Word16 *) malloc( sizeof(Word16) * hDirACRend->num_outputs_diff ) ) == NULL ) + IF( ( hDirACRend->proto_index_diff = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_diff ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } @@ -12304,7 +12628,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( hDirACRend->sba_map_tc = sba_map_tc; - IF ( EQ_16(nchan_transport , 1) ) + IF( EQ_16( nchan_transport, 1 ) ) { hDirACRend->num_protos_ambi = 1; hDirACRend->num_protos_dir = 1; @@ -12313,9 +12637,9 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); move16(); } - ELSE IF ( EQ_16(nchan_transport , 2) ) + ELSE IF( EQ_16( nchan_transport, 2 ) ) { - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_GAIN_SHD) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->num_protos_ambi = 2; hDirACRend->num_protos_diff = 1; @@ -12326,7 +12650,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); move16(); } - ELSE IF (EQ_16(hDirACRend->hOutSetup.output_config , IVAS_AUDIO_CONFIG_MONO) ) + ELSE IF( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_MONO ) ) { /* Following the foa rendering for code compatibility */ hDirACRend->num_protos_ambi = 2; @@ -12347,13 +12671,13 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); move16(); - FOR ( k = 0; k < hDirACRend->num_outputs_diff; k++ ) + FOR( k = 0; k < hDirACRend->num_outputs_diff; k++ ) { - IF ( GT_32(ls_azimuth_fx[k] , 0) ) + IF( GT_32( ls_azimuth_fx[k], 0 ) ) { hDirACRend->proto_index_diff[k] = 1; } - ELSE IF ( LT_32(ls_azimuth_fx[k] , 0) ) + ELSE IF( LT_32( ls_azimuth_fx[k], 0 ) ) { hDirACRend->proto_index_diff[k] = 2; } @@ -12364,7 +12688,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); } - IF ( hDirACRend->hOutSetup.is_loudspeaker_setup ) + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { hDirACRend->num_protos_dir = 3; move16(); @@ -12386,14 +12710,14 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } -#if 1/*TODO: To be removed later (Float buffer malloc)*/ +#if 1 /*TODO: To be removed later (Float buffer malloc)*/ if ( ( hDirACRend->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirACRend->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } #endif - IF ( EQ_16( hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf , DIRAC_SYNTHESIS_MONO ) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { initDiffuseResponses_fx( hDirACRend->diffuse_response_function_fx, nchan_out_woLFE, hDirACRend->hOutSetup.output_config, hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); @@ -12404,20 +12728,20 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); } -#if 1/*TODO: To be removed later(after dependecny on float buffer hoa_encoder is removed)*/ +#if 1 /*TODO: To be removed later(after dependecny on float buffer hoa_encoder is removed)*/ hDirACRend->hoa_encoder = NULL; #endif hDirACRend->hoa_encoder_fx = NULL; - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_SHD) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { - IF ( ( hDirACRend->hoa_encoder_fx = (Word32 *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) + IF( ( hDirACRend->hoa_encoder_fx = (Word32 *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } set32_fx( hDirACRend->hoa_encoder_fx, 0, nchan_out_woLFE * hDirACRend->num_outputs_diff ); - hDirACRend->hoa_encoder_len = imult1616(nchan_out_woLFE , hDirACRend->num_outputs_diff); -#if 1/*TODO: To be removed later(float buffer malloc and init)*/ + hDirACRend->hoa_encoder_len = imult1616( nchan_out_woLFE, hDirACRend->num_outputs_diff ); +#if 1 /*TODO: To be removed later(float buffer malloc and init)*/ if ( ( hDirACRend->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); @@ -12431,7 +12755,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* VBAP */ inputMasa->hMasaExtRend->hVBAPdata = NULL; - IF ( EQ_16(hDirACRend->panningConf , DIRAC_PANNING_VBAP) ) + IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) { IF( ( error = vbap_init_data_fx( &( inputMasa->hMasaExtRend->hVBAPdata ), ls_azimuth_fx, ls_elevation_fx, nchan_out_woLFE, MASA_FORMAT ) ) != IVAS_ERR_OK ) { @@ -12441,11 +12765,11 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* HOA panning/dec */ hDirACRend->hoa_decoder = NULL; - IF ( EQ_16(hDirACRend->panningConf , DIRAC_PANNING_HOA3) ) + IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_HOA3 ) ) { - IF ( hDirACRend->hOutSetup.is_loudspeaker_setup ) + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { - IF ( ( error = ivas_sba_get_hoa_dec_matrix_fx( hDirACRend->hOutSetup, &inputMasa->hMasaExtRend->hoa_dec_mtx, hDirACRend->hOutSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sba_get_hoa_dec_matrix_fx( hDirACRend->hOutSetup, &inputMasa->hMasaExtRend->hoa_dec_mtx, hDirACRend->hOutSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } @@ -12456,37 +12780,36 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* decorrelation */ hDirACRend->proto_signal_decorr_on = 1; - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_MONO) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { hDirACRend->proto_signal_decorr_on = 0; } - IF ( hDirACRend->proto_signal_decorr_on ) + IF( hDirACRend->proto_signal_decorr_on ) { - IF ( ( error = ivas_dirac_dec_decorr_open_fx( &( hDirACRend->h_freq_domain_decorr_ap_params ), - &( hDirACRend->h_freq_domain_decorr_ap_state ), - hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - hDirACRend->frequency_axis_fx, - nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hDirACRend->h_freq_domain_decorr_ap_params ), + &( hDirACRend->h_freq_domain_decorr_ap_state ), + hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + hDirACRend->frequency_axis_fx, + nchan_transport, + output_Fs ) ) != IVAS_ERR_OK ) { return error; } - } /* output synthesis */ - IF ( ( ivas_dirac_dec_output_synthesis_open_fx( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) + IF( ( ivas_dirac_dec_output_synthesis_open_fx( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) { return error; } hDirACRend->h_output_synthesis_psd_params.use_onset_filters = hDirACRend->proto_signal_decorr_on; move16(); - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_PSD_SHD) || EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_GAIN_SHD) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->h_output_synthesis_psd_params.use_onset_filters = 0; move16(); @@ -12496,32 +12819,32 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( * memory allocation *-----------------------------------------------------------------*/ - IF ( EQ_16(hDirACRend->synthesisConf , DIRAC_SYNTHESIS_GAIN_SHD) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->proto_frame_f = NULL; } ELSE { -#if 1/*TODO: To be removed later(after dependency on proto_frame_f is completely removed)*/ - IF ( ( hDirACRend->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) +#if 1 /*TODO: To be removed later(after dependency on proto_frame_f is completely removed)*/ + IF( ( hDirACRend->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } #endif - IF( ( hDirACRend->proto_frame_f_fx = (Word32 *) malloc( sizeof(Word32) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) + IF( ( hDirACRend->proto_frame_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } } -#if 1/*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ +#if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ hDirACRend->buffer_energy = NULL; #endif - FOR ( i = 0; i < DIRAC_NUM_DIMS; i++ ) + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { - FOR ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { #if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ hDirACRend->buffer_intensity_real[i][j] = NULL; @@ -12534,7 +12857,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( ivas_dirac_dec_output_synthesis_init_fx( hSpatParamRendCom, hDirACRend, nchan_out_woLFE, 0 ); /* Allocate stack memory */ - IF ( ( error = ivas_dirac_alloc_mem( hDirACRend, RENDERER_DIRAC, hSpatParamRendCom->num_freq_bands, &( hDirACRend->stack_mem ), 0 ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_alloc_mem( hDirACRend, RENDERER_DIRAC, hSpatParamRendCom->num_freq_bands, &( hDirACRend->stack_mem ), 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -13090,7 +13413,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin; /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ - IF ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); } @@ -13103,35 +13426,35 @@ static ivas_error ivas_masa_ext_rend_parambin_init( hDiracDecBin->useTdDecorr = 0; /* Always use frequency domain decorrelator in external renderer */ move16(); - FOR ( j = 0; j < BINAURAL_CHANNELS; j++ ) + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { - FOR ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) { -#if 1/*To be removed later(floating buffer init)*/ +#if 1 /*To be removed later(floating buffer init)*/ set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); #endif - set16_fx( hDiracDecBin->processMtxRe_fx[j][k],0, nBins ); - set16_fx( hDiracDecBin->processMtxIm_fx[j][k],0, nBins ); + set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins ); } - FOR ( k = 0; k < BINAURAL_CHANNELS; k++ ) + FOR( k = 0; k < BINAURAL_CHANNELS; k++ ) { -#if 1/*To be removed later(floating buffer init)*/ +#if 1 /*To be removed later(floating buffer init)*/ set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); #endif - set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k],0, nBins ); - set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k],0, nBins ); + set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins ); } -#if 1/*TODO:To be removed later(floating buffer init)*/ +#if 1 /*TODO:To be removed later(floating buffer init)*/ set_zero( hDiracDecBin->ChEnePrev[j], nBins ); set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); #endif set_zero_fx( hDiracDecBin->ChEnePrev_fx[j], nBins ); set_zero_fx( hDiracDecBin->ChEneOutPrev_fx[j], nBins ); } -#if 1/*TODO:To be removed later(floating buffer init)*/ +#if 1 /*TODO:To be removed later(floating buffer init)*/ set_zero( hDiracDecBin->ChCrossRePrev, nBins ); set_zero( hDiracDecBin->ChCrossImPrev, nBins ); set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); @@ -13143,24 +13466,24 @@ static ivas_error ivas_masa_ext_rend_parambin_init( set_zero_fx( hDiracDecBin->ChCrossImOutPrev_fx, nBins ); hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - FOR ( bin = 0; bin < nBins; bin++ ) + FOR( bin = 0; bin < nBins; bin++ ) { - binCenterFreq_fx = L_mult0(extract_l(L_shr(output_Fs,1)), div_s(add(shl(bin, 1), 1), shl(nBins, 1)))/*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/;/*Q15*/ + binCenterFreq_fx = L_mult0( extract_l( L_shr( output_Fs, 1 ) ), div_s( add( shl( bin, 1 ), 1 ), shl( nBins, 1 ) ) ) /*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/; /*Q15*/ /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmp = BASOP_Util_Divide3232_Scale( binCenterFreq_fx, 2700<diffuseFieldCoherence_fx[bin] = L_shl(L_mult0(divide3232(tmpFloat_fx, Mult_32_16(binCenterFreq_fx, 187/*2^15*pi/550*/)), getSineWord16R2(tmp2)), tmp_e);/*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ + tmpFloat_fx = s_max( 0, sub( shl_sat( 1, 15 - tmp_e ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/; /*Q30*/ + tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 ); //*binCenterFreq_fx * EVS_PI / 550.0f*/ + hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ hDiracDecBin->diffuseFieldCoherence[bin] = fixedToFloat( hDiracDecBin->diffuseFieldCoherence_fx[bin], Q30 ); } /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */ -#if 1/*TODO: To be removed later(floating buffer init)*/ +#if 1 /*TODO: To be removed later(floating buffer init)*/ set_zero( hDiracDecBin->diffuseFieldCoherenceX, BINAURAL_COHERENCE_DIFFERENCE_BINS ); set_zero( hDiracDecBin->diffuseFieldCoherenceY, BINAURAL_COHERENCE_DIFFERENCE_BINS ); set_zero( hDiracDecBin->diffuseFieldCoherenceZ, BINAURAL_COHERENCE_DIFFERENCE_BINS ); @@ -13169,25 +13492,25 @@ static ivas_error ivas_masa_ext_rend_parambin_init( set_zero_fx( hDiracDecBin->diffuseFieldCoherenceY_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); set_zero_fx( hDiracDecBin->diffuseFieldCoherenceZ_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - IF ( EQ_16(renderer_type , RENDERER_BINAURAL_PARAMETRIC) ) /* Indication of binaural rendering without room effect */ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */ { - set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28/*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); + set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); hDiracDecBin->hReverb = NULL; } - ELSE IF ( EQ_16(renderer_type , RENDERER_BINAURAL_PARAMETRIC_ROOM) ) /* Indication of binaural rendering with room effect */ + ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ { Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); - IF ( hDiracDecBin->hReverb == NULL ) + IF( hDiracDecBin->hReverb == NULL ) { /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } } - ELSE IF ( EQ_16(renderer_type , RENDERER_STEREO_PARAMETRIC) ) + ELSE IF( EQ_16( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); hDiracDecBin->hReverb = NULL; @@ -13201,15 +13524,15 @@ static ivas_error ivas_masa_ext_rend_parambin_init( /* Always open frequency domain decorrelator */ ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); - IF ( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis_fx, - BINAURAL_CHANNELS, - output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis_fx, + BINAURAL_CHANNELS, + output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -13397,7 +13720,7 @@ static ivas_error initMasaExtRenderer( error = IVAS_ERR_OK; - IF ( ( hMasaExtRend = (MASA_EXT_REND_HANDLE) malloc( sizeof( MASA_EXT_REND_DATA ) ) ) == NULL ) + IF( ( hMasaExtRend = (MASA_EXT_REND_HANDLE) malloc( sizeof( MASA_EXT_REND_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA external renderer structure\n" ) ); } @@ -13414,20 +13737,20 @@ static ivas_error initMasaExtRenderer( hMasaExtRend->hVBAPdata = NULL; hMasaExtRend->hoa_dec_mtx = NULL; - IF ( ( error = getAudioConfigNumChannels( inputMasa->base.inConfig, &hMasaExtRend->nchan_input ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( inputMasa->base.inConfig, &hMasaExtRend->nchan_input ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = getAudioConfigNumChannels( outConfig, &hMasaExtRend->nchan_output ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( outConfig, &hMasaExtRend->nchan_output ) ) != IVAS_ERR_OK ) { return error; } - SWITCH ( outConfig ) + SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_MONO: - IF ( EQ_16(inputMasa->base.inConfig , IVAS_AUDIO_CONFIG_MASA2) ) + IF( EQ_16( inputMasa->base.inConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) { hMasaExtRend->renderer_type = RENDERER_DIRAC; } @@ -13467,7 +13790,7 @@ static ivas_error initMasaExtRenderer( return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); } - IF ( NE_16(hMasaExtRend->renderer_type , RENDERER_DISABLE) ) + IF( NE_16( hMasaExtRend->renderer_type, RENDERER_DISABLE ) ) { Word16 subframe; IF( ( error = ivas_spat_hSpatParamRendCom_config_fx( &hMasaExtRend->hSpatParamRendCom, DIRAC_OPEN, 0, MASA_FORMAT, MC_MODE_NONE, *( inputMasa->base.ctx.pOutSampleRate ), 0, 1 ) ) != IVAS_ERR_OK ) @@ -13476,7 +13799,7 @@ static ivas_error initMasaExtRenderer( } /* Simple population of the metadata index map as no adaptation is present */ set16_fx( hMasaExtRend->hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - FOR ( subframe = 0; subframe < MAX_PARAM_SPATIAL_SUBFRAMES; subframe++ ) + FOR( subframe = 0; subframe < MAX_PARAM_SPATIAL_SUBFRAMES; subframe++ ) { hMasaExtRend->hSpatParamRendCom->render_to_md_map[subframe] = subframe; move16(); @@ -13485,23 +13808,23 @@ static ivas_error initMasaExtRenderer( move16(); } - IF ( EQ_16(hMasaExtRend->renderer_type , RENDERER_DIRAC) ) + IF( EQ_16( hMasaExtRend->renderer_type, RENDERER_DIRAC ) ) { - IF ( ( error = ivas_masa_ext_rend_dirac_rend_init( inputMasa ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_masa_ext_rend_dirac_rend_init( inputMasa ) ) != IVAS_ERR_OK ) { return error; } } - IF ( EQ_16(hMasaExtRend->renderer_type , RENDERER_BINAURAL_PARAMETRIC) || EQ_16(hMasaExtRend->renderer_type , RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(hMasaExtRend->renderer_type , RENDERER_STEREO_PARAMETRIC) ) + IF( EQ_16( hMasaExtRend->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( hMasaExtRend->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( hMasaExtRend->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - IF ( NE_16(hMasaExtRend->renderer_type , RENDERER_STEREO_PARAMETRIC) ) + IF( NE_16( hMasaExtRend->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - IF ( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &inputMasa->hMasaExtRend->hHrtfParambin ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &inputMasa->hMasaExtRend->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } -#if 1/*TODO: To be removed later after dependency on floating buffers in hHrtfParambin is removed*/ +#if 1 /*TODO: To be removed later after dependency on floating buffers in hHrtfParambin is removed*/ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &inputMasa->hMasaExtRend->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; @@ -13509,36 +13832,36 @@ static ivas_error initMasaExtRenderer( #endif // IVAS_FLOAT_FIXED } - IF ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK ) { return error; } } /* Init CLDFB for analysis & synthesis if renderer is used. Otherwise, NULL. */ - FOR ( i = 0; i < MASA_MAX_TRANSPORT_CHANNELS; i++ ) + FOR( i = 0; i < MASA_MAX_TRANSPORT_CHANNELS; i++ ) { hMasaExtRend->cldfbAnaRend[i] = NULL; } - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { hMasaExtRend->cldfbSynRend[i] = NULL; } - IF ( hMasaExtRend->renderer_type != RENDERER_DISABLE ) + IF( hMasaExtRend->renderer_type != RENDERER_DISABLE ) { - FOR ( i = 0; i < hMasaExtRend->nchan_input; i++ ) + FOR( i = 0; i < hMasaExtRend->nchan_input; i++ ) { - IF ( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } - FOR ( i = 0; i < hMasaExtRend->nchan_output; i++ ) + FOR( i = 0; i < hMasaExtRend->nchan_output; i++ ) { - IF ( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 902d63ace1b74dc38d0b9124c4095a5214e7b776..a2dc9888c666f33c8c7c572a1dd5cd1c4c7cfbf5 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -184,6 +184,9 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { deindex_sph_idx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation[j][b] ), &( hMeta->directional_meta[i].azimuth[j][b] ) ); +#ifdef IVAS_FLOAT_FIXED + deindex_sph_idx_fx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation_fx[j][b] ), &( hMeta->directional_meta[i].azimuth_fx[j][b] ) ); +#endif hMeta->directional_meta[i].spherical_index[j][b] = readIndex[b]; } @@ -196,6 +199,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { hMeta->directional_meta[i].energy_ratio[j][b] = ( (float) readOther[b] ) / UINT8_MAX; +#ifdef IVAS_FLOAT_FIXED + hMeta->directional_meta[i].energy_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 );//Q30 + +#endif } /* Spread coherence */ @@ -207,6 +214,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { hMeta->directional_meta[i].spread_coherence[j][b] = ( (float) readOther[b] ) / UINT8_MAX; +#ifdef IVAS_FLOAT_FIXED + hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( readOther[b] * ONE_IN_Q7 );//Q15 + +#endif } } @@ -220,6 +231,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { hMeta->common_meta.diffuse_to_total_ratio[j][b] = ( (float) readOther[b] ) / UINT8_MAX; +#ifdef IVAS_FLOAT_FIXED + hMeta->common_meta.diffuse_to_total_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30 + +#endif } /* Surround coherence */