From 4e838b23c2b967a9452862b84406a2007c748feb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sat, 11 May 2024 22:04:06 +0530 Subject: [PATCH] Clean up : objectRendererSources [x] ftf changes added for ivas_td_binaural_open_ext_fx, ivas_td_binaural_renderer_fx. [x] Disabled structure members of TDREND_SRC_REND_t. [x] Integrated ivas_td_binaural_open_fx in ivas_td_binaural_open_ext_fx (parent function has intermediate conversions). [x] Integrated ivas_td_binaural_renderer_unwrap_fx in ivas_td_binaural_renderer_fx. [x] Disabled float call for TDREND_SRC_Init_fx. [x] Disabled all static functions in ivas_objectRenderer_sources.c file. --- lib_com/ivas_dirac_com.c | 12 +- lib_com/ivas_prot.h | 12 +- lib_dec/ivas_init_dec.c | 130 ++++--- lib_dec/ivas_ism_dec.c | 28 -- lib_dec/ivas_jbm_dec.c | 99 ++++++ lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 35 +- lib_dec/ivas_sba_dec.c | 31 ++ lib_rend/ivas_objectRenderer.c | 454 +++++++++++++++++++++++-- lib_rend/ivas_objectRenderer_mix.c | 17 +- lib_rend/ivas_objectRenderer_sources.c | 272 ++++++++------- lib_rend/ivas_prot_rend.h | 37 +- lib_rend/ivas_stat_rend.h | 26 +- lib_rend/lib_rend.c | 70 +++- 14 files changed, 930 insertions(+), 295 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d3057e3e8..f0f82bf97 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -654,8 +654,18 @@ void ivas_get_dirac_sba_max_md_bits_fx( Word16 exp_res = 0; IF (var1 % 5 != 0) { var4 = BASOP_Util_Add_Mant32Exp(var2_32, exp, ONE_IN_Q30, 1, &exp_res); + exp = exp_res; } - *metadata_max_bits = extract_l(L_min(MAX16B, L_shr(var4, 14))); + Word16 flag = BASOP_Util_Cmp_Mant32Exp(MAX16B, 31, var4, exp); + Word32 tmp; + if (flag == 1) { + tmp = var4; + } + else { + tmp = MAX16B; + exp = 31; + } + *metadata_max_bits = (Word16)L_shr(tmp, 31 - exp);; *qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1; return; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2253f7694..fce1edd5d 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -7333,11 +7333,19 @@ ivas_error ivas_td_binaural_open_fx( Word16 * SrcInd, /*Temporarily used to store the updated value of SrcInd*/ Word16 *num_src ); -#endif // IVAS_FLOAT_FIXED - +#else ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#endif // IVAS_FLOAT_FIXED + +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *output[], /* i/o: SCE channels / Binaural synthesis */ + const Word16 output_frame /* i : output frame length */ +); +#endif ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 79a4cb735..2ed3529f1 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -371,15 +371,6 @@ ivas_error ivas_dec_setup( // Cleanup changes for ivas_td_binaural_open: fixed to float IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); - TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; - DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); - DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); - DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); Word16 nchan_rend = num_src; IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -390,26 +381,15 @@ ivas_error ivas_dec_setup( TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; IF( Src_p->SrcSpatial_p != NULL ) { - Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; 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 ); fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); } } - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; - Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; - } TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); - SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); } } // Cleanup changes for ivas_cldfb_dec_reconfig_fx: fixed to float @@ -497,15 +477,6 @@ ivas_error ivas_dec_setup( // Cleanup changes for ivas_td_binaural_open: fixed to float IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); - TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; - DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); - DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); - DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); Word16 nchan_rend = num_src; IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -516,26 +487,15 @@ ivas_error ivas_dec_setup( TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; IF( Src_p->SrcSpatial_p != NULL ) { - Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; 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 ); fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); } } - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; - Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; - } TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); - SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); } } // Cleanup changes for ivas_cldfb_dec_reconfig_fx: fixed to float @@ -2224,30 +2184,13 @@ ivas_error ivas_init_decoder_fx( ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { #ifdef IVAS_FLOAT_FIXED -#if 1 /*Cleanup changes: float to fixed */ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; - FOR( i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } -#endif IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } #if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); - TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; - DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); - DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); - DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); Word16 nchan_rend = num_src; IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -2258,26 +2201,15 @@ ivas_error ivas_init_decoder_fx( TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; IF( Src_p->SrcSpatial_p != NULL ) { - Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; 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 ); fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); } } - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; - Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; - } TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); - SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); } #endif #else @@ -2367,10 +2299,41 @@ ivas_error ivas_init_decoder_fx( IF ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + IF((error = ivas_td_binaural_open_fx(st_ivas, SrcInd, &num_src)) != IVAS_ERR_OK) + { + return error; + } +#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float + Word16 nchan_rend = num_src; + IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR(Word16 nS = 0; nS < nchan_rend; nS++) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF(Src_p->SrcSpatial_p != NULL) + { + 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); + fixedToFloat_arrL(Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL(SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3); + fixedToFloat_arrL(SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3); + } +#endif +#else IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2412,10 +2375,41 @@ ivas_error ivas_init_decoder_fx( IF ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + IF((error = ivas_td_binaural_open_fx(st_ivas, SrcInd, &num_src)) != IVAS_ERR_OK) + { + return error; + } +#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float + Word16 nchan_rend = num_src; + IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR(Word16 nS = 0; nS < nchan_rend; nS++) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF(Src_p->SrcSpatial_p != NULL) + { + 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); + fixedToFloat_arrL(Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL(SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3); + fixedToFloat_arrL(SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3); + } +#endif +#else IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif } } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 22d7484c4..4df423d75 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -619,30 +619,13 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Open the TD Binaural renderer */ if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) { -#if 1 /*Cleanup changes: float to fixed */ Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; - FOR( Word16 i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } -#endif IF ( ( error = ivas_td_binaural_open_fx( st_ivas , SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } #if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); - TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; - DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); - DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); - DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); Word16 nchan_rend = num_src; IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -653,26 +636,15 @@ static ivas_error ivas_ism_bitrate_switching_dec( TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; IF( Src_p->SrcSpatial_p != NULL ) { - Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; 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 ); fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); } } - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; - Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; - } TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); - SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 89128520f..f56362f1b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -5457,10 +5457,109 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { +#ifdef IVAS_FLOAT_FIXED_s + //Word32 output_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + //Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + floatToFixed_arrL(p_output[i], p_output_fx[i], Q7, L_FRAME48k); + p_output_fx[i] = p_output_fx[i]; + } + + Word16 subframe_length; + Word16 num_subframes = (int16_t)((*nSamplesRendered * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); + subframe_length = (*nSamplesRendered) / num_subframes; +#if 1 + for (Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) + { + Word16 idx = subframe_idx; + + IF(st_ivas->hCombinedOrientationData->Quaternions) { + float max_val = 0; + max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].w)); + max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].x)); + max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].y)); + max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].z)); + Word16 quat_q = Q_factor_L(max_val); + st_ivas->hCombinedOrientationData->Quaternions[idx].w_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].w, quat_q); + st_ivas->hCombinedOrientationData->Quaternions[idx].x_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].x, quat_q); + st_ivas->hCombinedOrientationData->Quaternions[idx].y_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].y, quat_q); + st_ivas->hCombinedOrientationData->Quaternions[idx].z_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].z, quat_q); + } + Word16 pos_q = Q25; + + IF(st_ivas->hCombinedOrientationData->listenerPos != NULL) + { + st_ivas->hCombinedOrientationData->listenerPos[idx].x_fx = (Word32)float_to_fix(st_ivas->hCombinedOrientationData->listenerPos[idx].x, pos_q); + st_ivas->hCombinedOrientationData->listenerPos[idx].y_fx = (Word32)float_to_fix(st_ivas->hCombinedOrientationData->listenerPos[idx].y, pos_q); + st_ivas->hCombinedOrientationData->listenerPos[idx].z_fx = (Word32)float_to_fix(st_ivas->hCombinedOrientationData->listenerPos[idx].z, pos_q); + } + FOR( i = 0; i < 3; i++) + { + st_ivas->hBinRendererTd->Listener_p->Front_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Front[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Up_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Up[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Right_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Right[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Pos_q = pos_q; + st_ivas->hBinRendererTd->Listener_p->Pos_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Pos[i], st_ivas->hBinRendererTd->Listener_p->Pos_q); + } + + } +#endif + if ((error = ivas_td_binaural_renderer_fx(st_ivas, p_output_fx, *nSamplesRendered)) != IVAS_ERR_OK) + { + return error; + } +#if 1 + for ( i = 0; i < 3; i++) + { + st_ivas->hBinRendererTd->Listener_p->Front[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Front_fx[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Up[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Up_fx[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Right[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Right_fx[i], Q30); + st_ivas->hBinRendererTd->Listener_p->Pos[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Pos_fx[i], st_ivas->hBinRendererTd->Listener_p->Pos_q); + } + + Word16 ism_md_subframe_update_ext = 0; + Word16 nchan_transport_tmp = (st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC) ? st_ivas->nchan_ism : st_ivas->nchan_transport; + + if (st_ivas->hDecoderConfig->Opt_delay_comp) + { + ism_md_subframe_update_ext = 1; + } + else + { + ism_md_subframe_update_ext = 2; + } + + if (st_ivas->ivas_format == MASA_ISM_FORMAT) + { + ism_md_subframe_update_ext = 2; + } + + for (Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) + { + if (subframe_idx == ism_md_subframe_update_ext) + { + for(Word16 ns = 0; ns < nchan_transport_tmp - 1; ns++) + { + fixedToFloat_arrL(st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p_fx, st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p, Q30, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + fixedToFloat_arrL(st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p_fx, st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p, Q25, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + } + } + } + + + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + fixedToFloat_arrL(p_output_fx[i], p_output[i], Q7, L_FRAME48k); + } +#endif + +#else if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } +#endif Word16 q = Q16; q = q - find_guarded_bits_fx( *nSamplesRendered ); diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 8a9b8a517..2e18522b5 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -4016,8 +4016,8 @@ void ivas_param_mc_dec_render( slot_idx_start_cldfb_synth = 0; for (subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++) { - Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; #ifdef IVAS_FLOAT_FIXED + Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; for (i = 0; i < nchan_out_cldfb; i++) { floatToFixed_arrL(output_f[i], output_f_fx[i], Q11, len); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ce8e3c6f3..d4c0132a1 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -69,8 +69,7 @@ ivas_error ivas_td_binaural_open_fx( } return ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, *num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity_fx, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns, SrcInd ); } -#endif // IVAS_FLOAT_FIXED - +#else ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -86,6 +85,7 @@ ivas_error ivas_td_binaural_open( return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); } +#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * ivas_td_binaural_renderer() @@ -93,6 +93,35 @@ ivas_error ivas_td_binaural_open( * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *output[], /* i/o: SCE channels / Binaural synthesis */ + const Word16 output_frame /* i : output frame length */ +) +{ + Word16 ism_md_subframe_update; + Word16 nchan_transport; + test(); + nchan_transport = (EQ_16(st_ivas->ism_mode , ISM_MASA_MODE_DISC) || EQ_16(st_ivas->ism_mode , ISM_SBA_MODE_DISC)) ? st_ivas->nchan_ism : st_ivas->nchan_transport; + + IF (st_ivas->hDecoderConfig->Opt_delay_comp) + { + ism_md_subframe_update = 1; + } + ELSE + { + ism_md_subframe_update = 2; + } + + IF (EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT)) + { + ism_md_subframe_update = 2; + } + + return ivas_td_binaural_renderer_unwrap_fx(st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES); +} +#endif ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -121,8 +150,6 @@ ivas_error ivas_td_binaural_renderer( return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); } - - /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_sf() * diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a169d6683..5d06f0bfa 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1478,10 +1478,41 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* Allocate TD renderer for the objects in DISC mode */ if ( st_ivas->hBinRendererTd == NULL ) { +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + IF((error = ivas_td_binaural_open_fx(st_ivas, SrcInd, &num_src)) != IVAS_ERR_OK) + { + return error; + } +#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float + Word16 nchan_rend = num_src; + IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR(Word16 nS = 0; nS < nchan_rend; nS++) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF(Src_p->SrcSpatial_p != NULL) + { + 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); + fixedToFloat_arrL(Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL(SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3); + fixedToFloat_arrL(SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3); + } +#endif +#else if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif } } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index f8e2a9a17..a2eac77dc 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -274,7 +274,7 @@ ivas_error ivas_td_binaural_open_unwrap_fx( return error; } -#endif // IVAS_FLOAT_FIXED +#else ivas_error ivas_td_binaural_open_unwrap( TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ const int32_t output_Fs, /* i : Output sampling rate */ @@ -431,11 +431,17 @@ ivas_error ivas_td_binaural_open_unwrap( { return error; } - +#ifdef IVAS_FLOAT_FIXED + if ((error = TDREND_MIX_SRC_SetDirAtten_fx(pBinRendTd, nS, DirAtten_p)) != IVAS_ERR_OK) + { + return error; + } +#else if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) { return error; } +#endif } } @@ -462,11 +468,17 @@ ivas_error ivas_td_binaural_open_unwrap( DirAtten_p->ConeOuterAngle_fx = float_to_fix(DirAtten_p->ConeOuterAngle, Q22); DirAtten_p->ConeOuterGain_fx = float_to_fix(DirAtten_p->ConeOuterGain, Q30); #endif - +#ifdef IVAS_FLOAT_FIXED + if ((error = TDREND_MIX_SRC_SetDirAtten_fx(pBinRendTd, nS, DirAtten_p)) != IVAS_ERR_OK) + { + return error; + } +#else if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) { return error; } +#endif } } @@ -479,6 +491,7 @@ ivas_error ivas_td_binaural_open_unwrap( return error; } +#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* @@ -530,6 +543,175 @@ void ivas_td_binaural_close( * * Call ivas_td_binaural_renderer() without st_ivas. *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_renderer_unwrap_fx( + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ + const Word16 num_src, /* i : number of sources to render */ + const Word16 lfe_idx, /* i : LFE channel index */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ + const Word16 ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + Word32 *output_fx[], /* i/o: SCE channels / Binaural synthesis */ + const Word16 output_frame, /* i : output frame length */ + const Word16 num_subframes /* i : number of subframes to render */ +) +{ + Word16 subframe_length; + Word16 subframe_idx; + ivas_error error; + Word16 c_indx, nS; + Word16 ch; + Word16 *enableCombinedOrientation; /* i : Combined orientation flag */ + IVAS_QUATERNION *Quaternions; /* i : Head tracking data per subframe */ + IVAS_VECTOR3 *Pos; /* i : Listener position data per subframe */ + + + Word32 reverb_signal_fx[BINAURAL_CHANNELS][L_FRAME48k]; + Word32 *p_reverb_signal_fx[BINAURAL_CHANNELS]; + + enableCombinedOrientation = NULL; + Quaternions = NULL; + Pos = NULL; + IF(hCombinedOrientationData != NULL) + { + enableCombinedOrientation = hCombinedOrientationData->enableCombinedOrientation; + Quaternions = hCombinedOrientationData->Quaternions; + Pos = hCombinedOrientationData->listenerPos; + } + + FOR(ch = 0; ch < BINAURAL_CHANNELS; ch++) + { + p_reverb_signal_fx[ch] = reverb_signal_fx[ch]; + } + + subframe_length = output_frame / num_subframes; + + c_indx = 0; + FOR(nS = 0; nS < num_src; nS++) + { + IF(!(ivas_format == MC_FORMAT && nS == lfe_idx)) /* Skip LFE for MC */ + { + hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = output_fx[nS]; + hBinRendererTd->Sources[c_indx]->InputFrame_p_q = Q7; + hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; + c_indx = add(c_indx, 1); + } + } + + FOR(subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) + { + IF(subframe_idx == ism_md_subframe_update) + { + /* Update object position(s) */ + IF((error = TDREND_Update_object_positions_fx(hBinRendererTd, num_src, ivas_format, hIsmMetaData)) != IVAS_ERR_OK) + { + return error; + } + } + + /* Update the listener's location/orientation */ + Word16 tmp_headRotEnabled; + + tmp_headRotEnabled = 0; + move16(); + + + IF(enableCombinedOrientation != NULL) + { + tmp_headRotEnabled = enableCombinedOrientation[hCombinedOrientationData->subframe_idx]; + move16(); + } + + IF((error = TDREND_Update_listener_orientation_fx(hBinRendererTd, tmp_headRotEnabled, &Quaternions[hCombinedOrientationData->subframe_idx], &Pos[hCombinedOrientationData->subframe_idx])) != IVAS_ERR_OK) + { + return error; + } + + IF(hReverb != NULL) + { + Word16 i, j, exp; + Word32 pcm_in_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 pcm_out_buff[BINAURAL_CHANNELS][L_FRAME48k]; + Word32 *pcm_in_fx[MAX_OUTPUT_CHANNELS]; + Word32 *pcm_out_fx[BINAURAL_CHANNELS]; + Word16 nchan_transport = audioCfg2channels(transport_config); + exp = Q7; + move16(); + FOR(i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + pcm_in_fx[i] = pcm_in_buff[i]; + } + FOR(i = 0; i < nchan_transport; i++) + { + + FOR(j = 0; j < ((subframe_idx + 1) * hReverb->full_block_size); j++) + { + + pcm_in_fx[i][j] = output_fx[i][j]; + } + } + FOR(i = 0; i < BINAURAL_CHANNELS; i++) + { + pcm_out_fx[i] = pcm_out_buff[i]; + } + FOR(i = 0; i < BINAURAL_CHANNELS; i++) + { + + FOR(j = 0; j < (hReverb->full_block_size); j++) + { + pcm_out_fx[i][j] = p_reverb_signal_fx[i][j]; + } + } + IF((error = ivas_reverb_process_fx(hReverb, transport_config, 0, pcm_in_fx, pcm_out_fx, subframe_idx)) != IVAS_ERR_OK) + { + return error; + } + FOR(i = 0; i < BINAURAL_CHANNELS; i++) + { + + FOR(j = 0; j < (hReverb->full_block_size); j++) + { + + p_reverb_signal_fx[i][subframe_idx * hReverb->full_block_size + j] = L_shl(pcm_out_fx[i][subframe_idx * hReverb->full_block_size + j], 2); + } + } + } + + /* Render subframe */ + IF((error = TDREND_GetMix_fx(hBinRendererTd, output_fx, subframe_length, subframe_idx, ism_md_subframe_update)) != IVAS_ERR_OK) + { + return error; + } + + + /* Advance subframe pointer */ + c_indx = 0; + move16(); + FOR(nS = 0; nS < num_src; nS++) + { + IF(!(ivas_format == MC_FORMAT && nS == lfe_idx)) /* Skip LFE for MC */ + { + hBinRendererTd->Sources[c_indx]->InputFrame_p_fx += subframe_length; + c_indx = add(c_indx, 1); + } + } + + /* update combined orientation access index */ + ivas_combined_orientation_update_index(hCombinedOrientationData, subframe_length); + } + + IF(hReverb != NULL) + { + v_add_32(reverb_signal_fx[0], output_fx[0], output_fx[0], output_frame); + v_add_32(reverb_signal_fx[1], output_fx[1], output_fx[1], output_frame); + } + + return IVAS_ERR_OK; +} +#endif ivas_error ivas_td_binaural_renderer_unwrap( const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -656,14 +838,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( tmp_Pos->y_fx = (Word32)float_to_fix(tmp_Pos->y, pos_q); tmp_Pos->z_fx = (Word32)float_to_fix(tmp_Pos->z, pos_q); tmp_Pos->q_fact= pos_q; - for (int i = 0; i < 3; i++) - { - hBinRendererTd->Listener_p->Front_fx[i] = float_to_fix(hBinRendererTd->Listener_p->Front[i], Q30); - hBinRendererTd->Listener_p->Up_fx[i] = float_to_fix(hBinRendererTd->Listener_p->Up[i], Q30); - hBinRendererTd->Listener_p->Right_fx[i] = float_to_fix(hBinRendererTd->Listener_p->Right[i], Q30); - hBinRendererTd->Listener_p->Pos_q = pos_q; - hBinRendererTd->Listener_p->Pos_fx[i] = float_to_fix(hBinRendererTd->Listener_p->Pos[i], hBinRendererTd->Listener_p->Pos_q); - } // end float to fix IF ( ( error = TDREND_Update_listener_orientation_fx( hBinRendererTd, tmp_headRotEnabled, tmp_Quaternions, tmp_Pos ) ) != IVAS_ERR_OK ) @@ -672,13 +846,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( } // fix to float - for (int i = 0; i < 3; i++) - { - hBinRendererTd->Listener_p->Front[i] = fix_to_float(hBinRendererTd->Listener_p->Front_fx[i], Q30); - hBinRendererTd->Listener_p->Up[i] = fix_to_float(hBinRendererTd->Listener_p->Up_fx[i], Q30); - hBinRendererTd->Listener_p->Right[i] = fix_to_float(hBinRendererTd->Listener_p->Right_fx[i], Q30); - hBinRendererTd->Listener_p->Pos[i] = fix_to_float(hBinRendererTd->Listener_p->Pos_fx[i], hBinRendererTd->Listener_p->Pos_q); - } #else if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL ) ) != IVAS_ERR_OK ) { @@ -800,7 +967,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * TDREND_GetMix() * @@ -1098,10 +1264,17 @@ ivas_error TDREND_Update_object_positions( return error; } +#ifdef IVAS_FLOAT_FIXED + if ((error = TDREND_MIX_SRC_SetDirAtten_fx(hBinRendererTd, nS, DirAtten_p)) != IVAS_ERR_OK) + { + return error; + } +#else if ( ( error = TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) { return error; } +#endif if ( hIsmMetaData[nS]->non_diegetic_flag ) { @@ -1129,13 +1302,13 @@ ivas_error TDREND_Update_object_positions( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * TDREND_Update_listener_orientation() * * Update listener orientation (s) *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ @@ -1198,8 +1371,7 @@ ivas_error TDREND_Update_listener_orientation( return error; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error TDREND_Update_listener_orientation_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const Word16 headRotEnabled, /* i : Headrotation flag */ @@ -1285,7 +1457,57 @@ ivas_error TDREND_Update_listener_orientation_fx( * * *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_open_ext_fx( + TDREND_WRAPPER *pTDRend, + AUDIO_CONFIG inConfig, + RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ + LSSETUP_CUSTOM_STRUCT *customLsInput, + const Word32 outFs, + Word16 *SrcInd, + Word16 *num_src ) +{ + Word16 nchan_transport; + AUDIO_CONFIG transport_config; + IVAS_FORMAT ivas_format; + IVAS_OUTPUT_SETUP hTransSetup; + ivas_error error; + Word16 *directivity_fx = NULL; + + IF( NE_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + IF( ( error = getAudioConfigNumChannels( inConfig, &nchan_transport ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + nchan_transport = customLsInput->num_spk; + } + *num_src = nchan_transport; + + transport_config = inConfig; + ivas_format = ( EQ_16( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) ? MC_FORMAT : ISM_FORMAT; + + hTransSetup.ls_azimuth_fx = NULL; + hTransSetup.ls_elevation_fx = NULL; + + IF( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + hTransSetup.ls_azimuth_fx = customLsInput->ls_azimuth_fx; + hTransSetup.ls_elevation_fx = customLsInput->ls_elevation_fx; + } + + IF( NULL != hRendCfg ) + { + directivity_fx = hRendCfg->directivity_fx; + } + + return ivas_td_binaural_open_unwrap_fx( &pTDRend->hHrtfTD, outFs, *num_src, ivas_format, transport_config, directivity_fx, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns, SrcInd ); +} +#else ivas_error ivas_td_binaural_open_ext( TDREND_WRAPPER *pTDRend, AUDIO_CONFIG inConfig, @@ -1333,6 +1555,7 @@ ivas_error ivas_td_binaural_open_ext( return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); } +#endif #ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_ext() @@ -1363,6 +1586,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( IVAS_REND_AudioConfigType inConfigType; AUDIO_CONFIG transport_config; ivas_error error; +#if 1 float *p_output[MAX_OUTPUT_CHANNELS]; float output_fl[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word16 ch,j; @@ -1378,6 +1602,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( { p_output[ch] = output_fl[ch]; } +#endif push_wmops( "ivas_td_binaural_renderer_ext" ); @@ -1418,23 +1643,112 @@ ivas_error ivas_td_binaural_renderer_ext_fx( hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } - IF ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, - ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK ) +#ifdef IVAS_FLOAT_FIXED_S + //Word32 output_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; + FOR(Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + Scale_sig32(output[i], Q7 - (31 - exp), L_FRAME48k); + p_output_fx[i] = output[i]; + } + + Word16 subframe_length; + Word16 num_subframes = (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); + subframe_length = output_frame / num_subframes; + +#if 1 + for ( Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) + { + Word16 idx = subframe_idx; + + IF( ( *hCombinedOrientationData )->Quaternions ) + { + float max_val = 0; + max_val = (float) max( max_val, fabs( ( *hCombinedOrientationData )->Quaternions[idx].w ) ); + max_val = (float) max( max_val, fabs( ( *hCombinedOrientationData )->Quaternions[idx].x ) ); + max_val = (float) max( max_val, fabs( ( *hCombinedOrientationData )->Quaternions[idx].y ) ); + max_val = (float) max( max_val, fabs( ( *hCombinedOrientationData )->Quaternions[idx].z ) ); + Word16 quat_q = Q_factor_L( max_val ); + ( *hCombinedOrientationData )->Quaternions[idx].w_fx = float_to_fix( ( *hCombinedOrientationData )->Quaternions[idx].w, quat_q ); + ( *hCombinedOrientationData )->Quaternions[idx].x_fx = float_to_fix( ( *hCombinedOrientationData )->Quaternions[idx].x, quat_q ); + ( *hCombinedOrientationData )->Quaternions[idx].y_fx = float_to_fix( ( *hCombinedOrientationData )->Quaternions[idx].y, quat_q ); + ( *hCombinedOrientationData )->Quaternions[idx].z_fx = float_to_fix( ( *hCombinedOrientationData )->Quaternions[idx].z, quat_q ); + } + Word16 pos_q = Q25; + + IF((*hCombinedOrientationData)->listenerPos != NULL) + { + (*hCombinedOrientationData)->listenerPos[idx].x_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].x, pos_q); + (*hCombinedOrientationData)->listenerPos[idx].y_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].y, pos_q); + (*hCombinedOrientationData)->listenerPos[idx].z_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].z, pos_q); + } + FOR(int i = 0; i < 3; i++) + { + pTDRend->hBinRendererTd->Listener_p->Front_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Front[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Up_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Up[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Right_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Right[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Pos_q = pos_q; + pTDRend->hBinRendererTd->Listener_p->Pos_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Pos[i], pTDRend->hBinRendererTd->Listener_p->Pos_q); + } + } +#endif + if ((error = ivas_td_binaural_renderer_unwrap_fx(hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, + ism_md_subframe_update_ext, p_output_fx, output_frame, (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs))) != IVAS_ERR_OK) { return error; } - IF ( hReverb != NULL) + +#if 1 + for (int i = 0; i < 3; i++) { - exp = sub(exp , 2); + pTDRend->hBinRendererTd->Listener_p->Front[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Front_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Up[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Up_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Right[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Right_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Pos[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Pos_fx[i], pTDRend->hBinRendererTd->Listener_p->Pos_q); } - /*This intermediate conversion will be removed once the subfunctions are also converted to fixed*/ - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + + for (Word16 subframe_idx = 0; subframe_idx < (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); subframe_idx++) { - for ( j = 0; j < L_FRAME48k; j++ ) + if (subframe_idx == ism_md_subframe_update_ext) { - output[ch][j] = (Word32) output_fl[ch][j] *( 1 << (exp)) ; + FOR(Word16 ns = 0; ns < num_src - 1; ns++) + { + fixedToFloat_arrL(pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p_fx, pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p, Q30, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + fixedToFloat_arrL(pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p_fx, pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p, Q25, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + } } } + exp = 31 - Q7; +#endif + +#if 0 + FOR(Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + fixedToFloat_arrL(output_fx[i], output[i], Q7, L_FRAME48k); + } +#endif +#else + if ((error = ivas_td_binaural_renderer_unwrap(hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, + ism_md_subframe_update_ext, p_output, output_frame, (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs))) != IVAS_ERR_OK) + { + return error; + } +#if 1 + IF(hReverb != NULL) + { + exp = sub(exp, 2); + } + /*This intermediate conversion will be removed once the subfunctions are also converted to fixed*/ + for (ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) + { + for (j = 0; j < L_FRAME48k; j++) + { + output[ch][j] = (Word32)output_fl[ch][j] * (1 << (exp)); + } + } +#endif +#endif + pop_wmops(); return IVAS_ERR_OK; @@ -1513,12 +1827,92 @@ ivas_error ivas_td_binaural_renderer_ext( hIsmMetaData[0]->radius = currentPos->radius; hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } +#ifdef IVAS_FLOAT_FIXED_s + Word32 output_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; + FOR(Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + floatToFixed_arrL(output[i], output_fx[i], Q7, L_FRAME48k); + p_output_fx[i] = output_fx[i]; + } + + Word16 subframe_length; + Word16 num_subframes = (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); + subframe_length = output_frame / num_subframes; + +#if 1 + for (Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) + { + Word16 idx = subframe_idx; + + IF((*hCombinedOrientationData)->Quaternions) { + float max_val = 0; + max_val = (float)max(max_val, fabs((*hCombinedOrientationData)->Quaternions[idx].w)); + max_val = (float)max(max_val, fabs((*hCombinedOrientationData)->Quaternions[idx].x)); + max_val = (float)max(max_val, fabs((*hCombinedOrientationData)->Quaternions[idx].y)); + max_val = (float)max(max_val, fabs((*hCombinedOrientationData)->Quaternions[idx].z)); + Word16 quat_q = Q_factor_L(max_val); + (*hCombinedOrientationData)->Quaternions[idx].w_fx = float_to_fix((*hCombinedOrientationData)->Quaternions[idx].w, quat_q); + (*hCombinedOrientationData)->Quaternions[idx].x_fx = float_to_fix((*hCombinedOrientationData)->Quaternions[idx].x, quat_q); + (*hCombinedOrientationData)->Quaternions[idx].y_fx = float_to_fix((*hCombinedOrientationData)->Quaternions[idx].y, quat_q); + (*hCombinedOrientationData)->Quaternions[idx].z_fx = float_to_fix((*hCombinedOrientationData)->Quaternions[idx].z, quat_q); + } + Word16 pos_q = Q25; + + IF((*hCombinedOrientationData)->listenerPos != NULL) + { + (*hCombinedOrientationData)->listenerPos[idx].x_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].x, pos_q); + (*hCombinedOrientationData)->listenerPos[idx].y_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].y, pos_q); + (*hCombinedOrientationData)->listenerPos[idx].z_fx = (Word32)float_to_fix((*hCombinedOrientationData)->listenerPos[idx].z, pos_q); + } + FOR(int i = 0; i < 3; i++) + { + pTDRend->hBinRendererTd->Listener_p->Front_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Front[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Up_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Up[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Right_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Right[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Pos_q = pos_q; + pTDRend->hBinRendererTd->Listener_p->Pos_fx[i] = float_to_fix(pTDRend->hBinRendererTd->Listener_p->Pos[i], pTDRend->hBinRendererTd->Listener_p->Pos_q); + } + } +#endif + if ((error = ivas_td_binaural_renderer_unwrap_fx(hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, + ism_md_subframe_update_ext, p_output_fx, output_frame, (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs))) != IVAS_ERR_OK) + { + return error; + } + +#if 1 + for (int i = 0; i < 3; i++) + { + pTDRend->hBinRendererTd->Listener_p->Front[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Front_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Up[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Up_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Right[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Right_fx[i], Q30); + pTDRend->hBinRendererTd->Listener_p->Pos[i] = fix_to_float(pTDRend->hBinRendererTd->Listener_p->Pos_fx[i], pTDRend->hBinRendererTd->Listener_p->Pos_q); + } + for (Word16 subframe_idx = 0; subframe_idx < (int16_t)((output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); subframe_idx++) + { + if (subframe_idx == ism_md_subframe_update_ext) + { + FOR(Word16 ns = 0; ns < num_src; ns++) + { + fixedToFloat_arrL(pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p_fx, pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p, Q30, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + fixedToFloat_arrL(pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p_fx, pTDRend->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p, Q25, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); + } + } + } + FOR(Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++) + { + fixedToFloat_arrL(output_fx[i], output[i], Q7, L_FRAME48k); + } +#endif +#else if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK ) { return error; } +#endif pop_wmops(); diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 30dbb9cd4..c91f8f6cd 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -94,8 +94,7 @@ void TDREND_MIX_LIST_SetPos_fx( return; } -#endif - +#else void TDREND_MIX_LIST_SetPos( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *Pos_p /* i : Listener's position */ @@ -116,6 +115,7 @@ void TDREND_MIX_LIST_SetPos( return; } +#endif /*-------------------------------------------------------------------* @@ -124,6 +124,7 @@ void TDREND_MIX_LIST_SetPos( * Sets the listener's orientation vectors in the specified mixer unit. --------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error TDREND_MIX_LIST_SetOrient( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *FrontVec_p, /* i : Listener's orientation front vector */ @@ -150,9 +151,7 @@ ivas_error TDREND_MIX_LIST_SetOrient( return IVAS_ERR_OK; } - - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error TDREND_MIX_LIST_SetOrient_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word32 *FrontVec_p_fx, /* i : Listener's orientation front vector */ @@ -416,12 +415,13 @@ ivas_error TDREND_MIX_Init( } /* Init virtual and rendering listeners for spatial mixers */ +#ifndef IVAS_FLOAT_FIXED TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Pos, 0.0f, 0.0f, 0.0f ); TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Vel, 0.0f, 0.0f, 0.0f ); TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Front, 0.0f, 0.0f, -1.0f ); TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Up, 0.0f, 1.0f, 0.0f ); TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Right, 1.0f, 0.0f, 0.0f ); - +#endif #ifdef IVAS_FLOAT_FIXED TDREND_SPATIAL_VecInit_fx( hBinRendererTd->Listener_p->Pos_fx, 0, 0, 0 ); hBinRendererTd->Listener_p->Pos_q = Q25; @@ -618,8 +618,11 @@ ivas_error TDREND_MIX_AddSrc( { return error; } - +#ifdef IVAS_FLOAT_FIXED + TDREND_SRC_Init_fx(Src_p, PosType); +#else TDREND_SRC_Init( Src_p, PosType ); +#endif /* Special OpenAL initialization due to a common distance attenuation model */ if ( hBinRendererTd->DistAttenModel != 0 ) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 1b566cb9f..747859a15 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -47,25 +47,21 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); - +#ifndef IVAS_FLOAT_FIXED static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); -static void TDREND_SRC_SPATIAL_Init_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); - static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); -static void TDREND_SRC_SPATIAL_SetDirAtten_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); - static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); -static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( const TDREND_DirAtten_t *DirAtten_p, const Word32 *Front_p_fx, const Word32 *RelPos_p, const Word16 RelPos_p_e ); - static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); -static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( const TDREND_DistAtten_t *DistAtten_p, const Word32 Dist_fx, const Word16 Dist_e ); - -static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); - static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p ); +#else static void TDREND_SRC_REND_Init_fx( TDREND_SRC_REND_t *SrcRend_p ); - +static void TDREND_SRC_SPATIAL_Init_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); +static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( const TDREND_DirAtten_t *DirAtten_p, const Word32 *Front_p_fx, const Word32 *RelPos_p, const Word16 RelPos_p_e ); +static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( const TDREND_DistAtten_t *DistAtten_p, const Word32 Dist_fx, const Word16 Dist_e ); +static void TDREND_SRC_SPATIAL_SetDirAtten_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); +#endif +static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); +static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPos() @@ -215,8 +211,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten_fx( return IVAS_ERR_OK; } -#endif // IVAS_FLOAT_FIXED - +#else ivas_error TDREND_MIX_SRC_SetDirAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ @@ -236,6 +231,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -325,9 +321,6 @@ static void TDREND_SRC_REND_Init_fx( /* SrcGain */ FOR( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { - // Float code - SrcRend_p->SrcGain_p[nC] = 1.0f; - SrcRend_p->SrcGainMin_p_fx[nC] = 0;/*Assuming Q15*/ move16(); SrcRend_p->SrcGain_p_fx[nC] = ONE_IN_Q14; @@ -340,10 +333,6 @@ static void TDREND_SRC_REND_Init_fx( /* Init directional and distance gains */ FOR ( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { - // Float code - SrcRend_p->DirGain_p[nC] = 1.0f; - SrcRend_p->DistGain_p[nC] = 1.0f; - SrcRend_p->DirGain_p_fx[nC] = ONE_IN_Q14; move16(); SrcRend_p->DistGain_p_fx[nC] = ONE_IN_Q14; @@ -351,8 +340,7 @@ static void TDREND_SRC_REND_Init_fx( } return; } -#endif // IVAS_FLOAT_FIXED - +#else static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p /* i/o: Source object */ ) @@ -365,12 +353,17 @@ static void TDREND_SRC_REND_Init( /* SrcGain */ for ( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { +#ifndef IVAS_FLOAT_FIXED SrcRend_p->SrcGainMin_p[nC] = 0.0f; SrcRend_p->SrcGain_p[nC] = 1.0f; SrcRend_p->SrcGainMax_p[nC] = 1.0f; -#ifdef IVAS_FLOAT_FIXED +#else + SrcRend_p->SrcGainMin_p_fx[nC] = ONE_IN_Q14; + move16(); SrcRend_p->SrcGain_p_fx[nC] = ONE_IN_Q14; move16(); + SrcRend_p->SrcGainMax_p_fx[nC] = ONE_IN_Q14; + move16(); #endif } SrcRend_p->SrcGainUpdated = FALSE; @@ -378,9 +371,10 @@ static void TDREND_SRC_REND_Init( /* Init directional and distance gains */ for ( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { +#ifndef IVAS_FLOAT_FIXED SrcRend_p->DirGain_p[nC] = 1.0f; SrcRend_p->DistGain_p[nC] = 1.0f; -#ifdef IVAS_FLOAT_FIXED +#else SrcRend_p->DirGain_p_fx[nC] = ONE_IN_Q14; move16(); SrcRend_p->DistGain_p_fx[nC] = ONE_IN_Q14; @@ -392,6 +386,7 @@ static void TDREND_SRC_REND_Init( return; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * TDREND_SRC_REND_UpdateFiltersFromSpatialParams() @@ -623,115 +618,115 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( ELSE{ IF( SrcSpatial_p->DistAttenEnabled ){ *SrcRend_p->DistGain_p_fx = TDREND_SRC_SPATIAL_GetDistGain_fx( &SrcSpatial_p->DistAtten, ListRelDist, ListRelDist_e ); + } + } + + /* Update total gains */ + *Gain = extract_h( L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ) ); + + /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ + + elev_delta = L_sub( Elev, Src_p->elev_prev_fx ); + azim_delta = L_sub( Azim, Src_p->azim_prev_fx ); + + Src_p->elev_prev_fx = Elev; + move32(); + Src_p->azim_prev_fx = Azim; + move32(); + + /* map to -180:180 range */ + IF( GT_32( azim_delta, DEG_180_IN_Q22 ) ) + { + azim_delta = L_sub( azim_delta, DEG_360_IN_Q22 ); + } + ELSE IF( LT_32( azim_delta, -DEG_180_IN_Q22 ) ) + { + azim_delta = L_add( azim_delta, DEG_360_IN_Q22 ); + } + Word16 tmp1 = extract_l( Mpy_32_32( L_abs( azim_delta ), 100 << Q9 ) ); // Q22 + Q9 - Q31 = Q0 + Word16 tmp2 = extract_l( Mpy_32_32( L_abs( elev_delta ), 100 << Q9 ) ); // Q22 + Q9 - Q31 = Q0 + *intp_count = s_min( MAX_INTERPOLATION_STEPS, s_max( tmp1, tmp2 ) ); } -} - -/* Update total gains */ -*Gain = extract_h( L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ) ); - -/* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ - -elev_delta = L_sub( Elev, Src_p->elev_prev_fx ); -azim_delta = L_sub( Azim, Src_p->azim_prev_fx ); - -Src_p->elev_prev_fx = Elev; -move32(); -Src_p->azim_prev_fx = Azim; -move32(); - -/* map to -180:180 range */ -IF( GT_32( azim_delta, DEG_180_IN_Q22 ) ) -{ - azim_delta = L_sub( azim_delta, DEG_360_IN_Q22 ); -} -ELSE IF( LT_32( azim_delta, -DEG_180_IN_Q22 ) ) -{ - azim_delta = L_add( azim_delta, DEG_360_IN_Q22 ); -} -Word16 tmp1 = extract_l( Mpy_32_32( L_abs( azim_delta ), 100 << Q9 ) ); // Q22 + Q9 - Q31 = Q0 -Word16 tmp2 = extract_l( Mpy_32_32( L_abs( elev_delta ), 100 << Q9 ) ); // Q22 + Q9 - Q31 = Q0 -*intp_count = s_min( MAX_INTERPOLATION_STEPS, s_max( tmp1, tmp2 ) ); -} -ELSE /* TDREND_POSTYPE_NON_DIEGETIC */ -{ - *itd = 0; - move16(); - *Gain = ONE_IN_Q14; - move16(); - set32_fx( hrf_left, 0, *filterlength ); - set32_fx( hrf_right, 0, *filterlength ); - hrf_left[0] = L_shr( L_add( SrcSpatial_p->Pos_p_fx[1], ONE_IN_Q25 ), 1 ); // Q25 - move32(); - hrf_right[0] = L_sub( ONE_IN_Q25, hrf_left[0] ); // Q25 - move32(); - hrf_left_e = 6; - move16(); - hrf_right_e = 6; - move16(); - *intp_count = MAX_INTERPOLATION_STEPS; - move16(); - Src_p->elev_prev_fx = 0; - move16(); - Src_p->azim_prev_fx = DEG_360_IN_Q22; /* Dummy angle -- sets max interpolation if switching to TDREND_POSTYPE_ABSOLUTE */ - move16(); -} - -test(); -IF( ( *intp_count > 0 ) && subframe_update_flag ) -{ - /* Set deltas for interpolation */ - Word16 tmp_e; - tmp_e = s_max( *hrf_left_prev_e, hrf_left_e ); - FOR( Word16 i = 0; i < *filterlength; i++ ) + ELSE /* TDREND_POSTYPE_NON_DIEGETIC */ { - hrf_left[i] = L_shr( hrf_left[i], sub( tmp_e, hrf_left_e ) ); - hrf_left_prev[i] = L_shr( hrf_left_prev[i], sub( tmp_e, *hrf_left_prev_e ) ); + *itd = 0; + move16(); + *Gain = ONE_IN_Q14; + move16(); + set32_fx( hrf_left, 0, *filterlength ); + set32_fx( hrf_right, 0, *filterlength ); + hrf_left[0] = L_shr( L_add( SrcSpatial_p->Pos_p_fx[1], ONE_IN_Q25 ), 1 ); // Q25 + move32(); + hrf_right[0] = L_sub( ONE_IN_Q25, hrf_left[0] ); // Q25 + move32(); + hrf_left_e = 6; + move16(); + hrf_right_e = 6; + move16(); + *intp_count = MAX_INTERPOLATION_STEPS; + move16(); + Src_p->elev_prev_fx = 0; + move16(); + Src_p->azim_prev_fx = DEG_360_IN_Q22; /* Dummy angle -- sets max interpolation if switching to TDREND_POSTYPE_ABSOLUTE */ + move16(); } - *hrf_left_prev_e = tmp_e; - move16(); - hrf_left_e = tmp_e; - move16(); - v_sub_32( hrf_left, hrf_left_prev, hrf_left_delta, *filterlength ); - *hrf_left_delta_e = tmp_e; - move16(); - - Word32 fac = L_deposit_h( div_s( 1, *intp_count ) ); - v_multc_fixed( hrf_left_delta, fac, hrf_left_delta, *filterlength ); - - tmp_e = s_max( *hrf_right_prev_e, hrf_right_e ); - FOR( Word16 i = 0; i < *filterlength; i++ ) + + test(); + IF( ( *intp_count > 0 ) && subframe_update_flag ) { - hrf_right[i] = L_shr( hrf_right[i], sub( tmp_e, hrf_right_e ) ); - hrf_right_prev[i] = L_shr( hrf_right_prev[i], sub( tmp_e, *hrf_right_prev_e ) ); + /* Set deltas for interpolation */ + Word16 tmp_e; + tmp_e = s_max( *hrf_left_prev_e, hrf_left_e ); + FOR( Word16 i = 0; i < *filterlength; i++ ) + { + hrf_left[i] = L_shr( hrf_left[i], sub( tmp_e, hrf_left_e ) ); + hrf_left_prev[i] = L_shr( hrf_left_prev[i], sub( tmp_e, *hrf_left_prev_e ) ); + } + *hrf_left_prev_e = tmp_e; + move16(); + hrf_left_e = tmp_e; + move16(); + v_sub_32( hrf_left, hrf_left_prev, hrf_left_delta, *filterlength ); + *hrf_left_delta_e = tmp_e; + move16(); + + Word32 fac = L_deposit_h( div_s( 1, *intp_count ) ); + v_multc_fixed( hrf_left_delta, fac, hrf_left_delta, *filterlength ); + + tmp_e = s_max( *hrf_right_prev_e, hrf_right_e ); + FOR( Word16 i = 0; i < *filterlength; i++ ) + { + hrf_right[i] = L_shr( hrf_right[i], sub( tmp_e, hrf_right_e ) ); + hrf_right_prev[i] = L_shr( hrf_right_prev[i], sub( tmp_e, *hrf_right_prev_e ) ); + } + *hrf_right_prev_e = tmp_e; + move16(); + hrf_right_e = tmp_e; + move16(); + v_sub_32( hrf_right, hrf_right_prev, hrf_right_delta, *filterlength ); + *hrf_right_delta_e = tmp_e; + move16(); + + v_multc_fixed( hrf_right_delta, fac, hrf_right_delta, *filterlength ); } - *hrf_right_prev_e = tmp_e; - move16(); - hrf_right_e = tmp_e; - move16(); - v_sub_32( hrf_right, hrf_right_prev, hrf_right_delta, *filterlength ); - *hrf_right_delta_e = tmp_e; - move16(); - - v_multc_fixed( hrf_right_delta, fac, hrf_right_delta, *filterlength ); -} -ELSE -{ - /* No interpolation, just set the new filters and reset deltas */ - Copy32( hrf_left, hrf_left_prev, *filterlength ); - *hrf_left_prev_e = hrf_left_e; - move16(); - Copy32( hrf_right, hrf_right_prev, *filterlength ); - *hrf_right_prev_e = hrf_right_e; - move16(); - set32_fx( hrf_left_delta, 0, *filterlength ); - set32_fx( hrf_right_delta, 0, *filterlength ); - *hrf_left_delta_e = 0; - move16(); - *hrf_right_delta_e = 0; - move16(); -} - -return; + ELSE + { + /* No interpolation, just set the new filters and reset deltas */ + Copy32( hrf_left, hrf_left_prev, *filterlength ); + *hrf_left_prev_e = hrf_left_e; + move16(); + Copy32( hrf_right, hrf_right_prev, *filterlength ); + *hrf_right_prev_e = hrf_right_e; + move16(); + set32_fx( hrf_left_delta, 0, *filterlength ); + set32_fx( hrf_right_delta, 0, *filterlength ); + *hrf_left_delta_e = 0; + move16(); + *hrf_right_delta_e = 0; + move16(); + } + + return; } #endif @@ -851,8 +846,7 @@ static void TDREND_SRC_SPATIAL_Init_fx( return; } -#endif - +#else static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i/o: Source spatial parameters */ const TDREND_PosType_t PosType /* i : Relative/absolute position type */ @@ -912,7 +906,7 @@ static void TDREND_SRC_SPATIAL_Init( return; } - +#endif /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_SetDirAtten() @@ -937,7 +931,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten_fx( move16(); return; } -#endif +#else static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i/o: Source spatial parameters */ const TDREND_DirAtten_t *DirAtten_p /* i : Directionality specification */ @@ -957,7 +951,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( return; } - +#endif /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDirGain() @@ -966,6 +960,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( --------------------------------------------------------------------*/ /*! r: Gain value */ +#ifndef IVAS_FLOAT_FIXED static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, /* i : Directional attenuation specification */ const float *Front_p, /* i : Front-pointing vector */ @@ -1009,8 +1004,7 @@ static float TDREND_SRC_SPATIAL_GetDirGain( return DirGain; } - -#ifdef IVAS_FLOAT_FIXED +#else static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( /* o : Directional Gain Output Q14 */ const TDREND_DirAtten_t *DirAtten_p, /* i : Directional attenuation specification */ const Word32 *Front_p_fx, /* i : Front-pointing vector */ @@ -1340,8 +1334,7 @@ void TDREND_SRC_Init_fx( move16(); return; } -#endif // IVAS_FLOAT_FIXED - +#else void TDREND_SRC_Init( TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ const TDREND_PosType_t PosType /* i : Position type specifier */ @@ -1394,3 +1387,4 @@ void TDREND_SRC_Init( return; } +#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index b4d9a1da1..6c96ade83 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1142,6 +1142,22 @@ void ivas_HRTF_CRend_binary_close( /*----------------------------------------------------------------------------------* * TD object renderer *----------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_renderer_unwrap_fx( + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ + const Word16 num_src, /* i : number of sources to render */ + const Word16 lfe_idx, /* i : LFE channel index */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ + const Word16 ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + Word32 *output_fx[], /* i/o: SCE channels / Binaural synthesis */ + const Word16 output_frame, /* i : output frame length */ + const Word16 num_subframes /* i : number of subframes to render */ +); +#endif ivas_error ivas_td_binaural_renderer_unwrap( const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -1211,6 +1227,17 @@ ivas_error ivas_td_binaural_open_unwrap( int32_t *binaural_latency_ns /* i : Binauralization delay */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_td_binaural_open_ext_fx( + TDREND_WRAPPER *pTDRend, + const AUDIO_CONFIG inConfig, + RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ + LSSETUP_CUSTOM_STRUCT *customLsInput, + const int32_t output_Fs, + Word16 *SrcInd, + Word16 *num_src +); +#else ivas_error ivas_td_binaural_open_ext( TDREND_WRAPPER *pTDRend, const AUDIO_CONFIG inConfig, @@ -1218,6 +1245,8 @@ ivas_error ivas_td_binaural_open_ext( LSSETUP_CUSTOM_STRUCT *customLsInput, const int32_t output_Fs ); +#endif + #ifdef IVAS_FLOAT_FIXED void ivas_td_binaural_close_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ @@ -1245,12 +1274,14 @@ ivas_error TDREND_GetMix_fx( ); #endif +#ifndef IVAS_FLOAT_FIXED ivas_error TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ const IVAS_VECTOR3 *Pos /* i : Listener Position */ ); +#endif ivas_error TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ @@ -1353,13 +1384,13 @@ ivas_error TDREND_MIX_SRC_SetDirAtten_fx( const Word16 SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); -#endif // IVAS_FLOAT_FIXED - +#else ivas_error TDREND_MIX_SRC_SetDirAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); +#endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED ivas_error TDREND_MIX_SRC_SetPlayState( @@ -1514,6 +1545,7 @@ ivas_error TDREND_MIX_SetDistAttenModel( const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */ ); +#ifndef IVAS_FLOAT_FIXED void TDREND_MIX_LIST_SetPos( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *Pos_p /* i : Listener's position */ @@ -1524,6 +1556,7 @@ ivas_error TDREND_MIX_LIST_SetOrient( const float *FrontVec_p, /* i : Listener's orientation front vector */ const float *UpVec_p /* i : Listener's orientation up vector */ ); +#endif #ifdef IVAS_FLOAT_FIXED void TDREND_MIX_Dealloc_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 0824de2c3..f961f6dfc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1680,14 +1680,6 @@ typedef struct typedef struct { int16_t PoseUpdated; - float Pos[3]; - float Front[3]; - float Up[3]; - float Right[3]; - - int16_t VelUpdated; - float Vel[3]; - #ifdef IVAS_FLOAT_FIXED Word32 Pos_fx[3]; Word16 Pos_q; @@ -1695,7 +1687,16 @@ typedef struct Word32 Up_fx[3]; Word32 Right_fx[3]; Word32 Vel_fx[3]; -#endif // IVAS_FLOAT_FIXED +#else + float Pos[3]; + float Front[3]; + float Up[3]; + float Right[3]; + float Vel[3]; +#endif// IVAS_FLOAT_FIXED + + int16_t VelUpdated; + } TDREND_MIX_Listener_t; /* HR filter */ @@ -1750,10 +1751,11 @@ typedef struct /* Directional attenuation */ typedef struct { +#ifndef IVAS_FLOAT_FIXED float ConeInnerAngle; float ConeOuterAngle; float ConeOuterGain; -#ifdef IVAS_FLOAT_FIXED +#else Word32 ConeInnerAngle_fx; // Q22 Word32 ConeOuterAngle_fx; // Q22 Word32 ConeOuterGain_fx; // Q30 @@ -1782,13 +1784,13 @@ typedef struct TDREND_SRC_REND_s Word16 SrcGainMax_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; Word16 DirGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 Word16 DistGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED float SrcGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float SrcGainMin_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float SrcGainMax_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DirGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DistGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; - +#endif } TDREND_SRC_REND_t; /* Source spatial parameters */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c406220d3..dbb301be6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2280,11 +2280,45 @@ static ivas_error setRendInputActiveIsm( } else { - if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + Word16 ivas_format = ( EQ_16( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) ? MC_FORMAT : ISM_FORMAT; + IF( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } + Word16 nchan_rend = num_src; + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) + { + IF( Src_p->SrcSpatial_p != NULL ) + { + 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 ); + fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); + fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); + } + } +#else + if ((error = ivas_td_binaural_open_ext(&inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate)) != IVAS_ERR_OK) + { + return error; + } +#endif + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef IVAS_FLOAT_FIXED @@ -3707,10 +3741,44 @@ static ivas_error initMcBinauralRendering( if ( useTDRend && inputMc->tdRendWrapper.hBinRendererTd == NULL ) { +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + Word16 ivas_format = ( EQ_16( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) ? MC_FORMAT : ISM_FORMAT; + IF( ( error = ivas_td_binaural_open_ext_fx( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK ) + { + return error; + } + + Word16 nchan_rend = num_src; + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputMc->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) + { + IF( Src_p->SrcSpatial_p != NULL ) + { + 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 ); + fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputMc->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); + fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); + } + } +#else if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#endif if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { -- GitLab