From 48d359183d3893223e5c3add6203018ec718f327 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 28 Jan 2024 13:29:34 +0530 Subject: [PATCH] basop updates in few functions --- lib_com/cldfb.c | 62 ++- lib_com/fd_cng_com.c | 2 +- lib_com/igf_base.c | 341 ++++++++++++++++ lib_com/igf_base_fx.c | 6 +- lib_com/ivas_ism_com.c | 387 ++++++++++++++++++- lib_com/ivas_mc_com.c | 66 ++-- lib_com/ivas_prot.h | 40 +- lib_com/ivas_prot_fx.h | 54 ++- lib_com/ivas_sba_config.c | 2 +- lib_com/ivas_stereo_mdct_bands_com.c | 5 + lib_com/prot.h | 8 +- lib_com/prot_fx2.h | 7 + lib_dec/fd_cng_dec.c | 2 +- lib_dec/ivas_dirac_dec.c | 4 + lib_dec/ivas_init_dec.c | 22 +- lib_dec/ivas_ism_dec.c | 8 + lib_dec/ivas_ism_dtx_dec.c | 37 ++ lib_dec/ivas_ism_metadata_dec.c | 5 + lib_dec/ivas_ism_param_dec.c | 25 +- lib_dec/ivas_ism_renderer.c | 4 +- lib_dec/ivas_jbm_dec.c | 313 ++++++++++++++- lib_dec/ivas_masa_dec.c | 9 +- lib_dec/ivas_mc_param_dec.c | 7 + lib_dec/ivas_mc_paramupmix_dec.c | 4 + lib_dec/ivas_mct_dec.c | 16 +- lib_dec/ivas_output_config.c | 247 ++++++++---- lib_dec/ivas_sce_dec.c | 40 +- lib_dec/ivas_spar_decoder.c | 4 + lib_dec/ivas_stereo_mdct_stereo_dec.c | 23 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 89 ++++- lib_rend/ivas_dirac_rend.c | 23 +- lib_rend/ivas_efap.c | 2 +- lib_rend/ivas_output_init.c | 148 ++++--- lib_rend/ivas_output_init_fx.c | 12 +- lib_rend/ivas_prot_rend.h | 6 +- lib_rend/ivas_reverb.c | 67 ++-- lib_rend/ivas_stat_rend.h | 5 + lib_rend/lib_rend.c | 50 +++ 38 files changed, 1834 insertions(+), 318 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 083967c5b..9f89fd1db 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1422,6 +1422,64 @@ ivas_error openCldfb_ivas( return IVAS_ERR_OK; } +#ifdef IVAS_FLOAT_FIXED +ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +) +{ + HANDLE_CLDFB_FILTER_BANK hs; + Word16 buf_len; + + IF ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); + } + + hs->type = type; + move16(); + hs->prototype = prototype; + move16(); + + configureCldfb_ivas( hs, sampling_rate ); + hs->memory_flt = NULL; + hs->memory_length = 0; + move16(); + + IF ( EQ_32( type, CLDFB_ANALYSIS ) ) + { + buf_len = sub( hs->p_filter_length, hs->no_channels ); + } + ELSE + { + buf_len = hs->p_filter_length; + move16(); + } + + IF ( ( hs->cldfb_state_fx = (Word16 *) malloc( buf_len * sizeof( Word16 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); + } + + set_s(hs->cldfb_state_fx, 0, buf_len); + + /* TODO: remove the floating point dependency */ + + IF ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); + } + + set_f( hs->cldfb_state, 0.0f, buf_len ); + + *h_cldfb = hs; + move16(); + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * resampleCldfb_ivas() @@ -1570,12 +1628,12 @@ void deleteCldfb_ivas( { HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb; - if ( h_cldfb == NULL || *h_cldfb == NULL ) + IF ( h_cldfb == NULL || *h_cldfb == NULL ) { return; } - if ( hs->cldfb_state ) + IF ( hs->cldfb_state ) { free( hs->cldfb_state ); } diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 101e7b5b4..0a9867fb8 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -155,7 +155,7 @@ void deleteFdCngCom_flt( { HANDLE_FD_CNG_COM hsCom = *hFdCngCom; - if ( hsCom != NULL ) + IF ( hsCom != NULL ) { free( hsCom ); *hFdCngCom = NULL; diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index c90f7bf97..3c97125e2 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -357,6 +357,347 @@ int16_t IGF_MapBitRateToIndex_flt( return bitRateIndex; } +#ifdef IVAS_FLOAT_FIXED +Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +) +{ + Word16 bitRateIndex = IGF_BITRATE_UNKNOWN; + move16(); + + /* Stereo/CPE modes */ + IF ( GT_16( element_mode, IVAS_SCE ) ) + { + SWITCH ( bwidth ) + { + case IGF_MODE_WB: + IF ( LE_32( brate, IVAS_13k2 ) && EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_WB_13200; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_9k60 ) ) + { + bitRateIndex = IGF_BITRATE_WB_13200_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_13k2 ) ) + { + bitRateIndex = IGF_BITRATE_WB_16400_CPE; + move16(); + } + BREAK; + case IGF_MODE_SWB: + /* DFT and TD Stereo bitrates */ + IF ( LE_32( brate, ACELP_9k60 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_13200_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_13k2 ) ) + { + IF ( EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_SWB_13200; + move16(); + } + ELSE + { + bitRateIndex = IGF_BITRATE_SWB_16400_CPE; + move16(); + } + } + ELSE IF ( LE_32( brate, IVAS_16k4 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_24400_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_24k4 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_32000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_32k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_32000; + move16(); + } + /* MDCT Stereo bitrates */ + ELSE IF ( LE_32( brate, IVAS_48k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_48000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_64k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_64000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_80k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_80000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_96k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_96000_CPE; + move16(); + } + BREAK; + case IGF_MODE_FB: + /* DFT and TD Stereo bitrates */ + IF ( LE_32( brate, IVAS_16k4 ) ) + { + bitRateIndex = IGF_BITRATE_FB_24400_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_24k4 ) ) + { + bitRateIndex = IGF_BITRATE_FB_32000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_32k ) ) + { + bitRateIndex = IGF_BITRATE_FB_32000; + move16(); + } + /* MDCT Stereo bitrates */ + ELSE IF ( LE_32( brate, IVAS_48k ) ) + { + bitRateIndex = IGF_BITRATE_FB_48000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_64k ) ) + { + bitRateIndex = IGF_BITRATE_FB_64000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_80k ) ) + { + bitRateIndex = IGF_BITRATE_FB_80000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_96k ) ) + { + bitRateIndex = IGF_BITRATE_FB_96000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_128k ) ) + { + bitRateIndex = IGF_BITRATE_FB_128000_CPE; + move16(); + } + BREAK; + } + } + /* SCE modes: use tunings done for DFT stereo bitrates also for according SCE bitrates, otherwise same config as mono modes */ + ELSE IF ( EQ_16( element_mode, IVAS_SCE ) ) + { + SWITCH ( bwidth ) + { + case IGF_MODE_WB: + IF ( LE_32( brate, IVAS_13k2 ) && EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_WB_13200; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_9k60 ) ) /* bitrates 8000 and 9600 */ + { + bitRateIndex = IGF_BITRATE_WB_9600; + move16(); + } + BREAK; + case IGF_MODE_SWB: + IF ( LE_32( brate, ACELP_9k60 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_13200_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_13k2 ) ) + { + IF ( EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_SWB_13200; + move16(); + } + ELSE + { + bitRateIndex = IGF_BITRATE_SWB_16400_CPE; + move16(); + } + } + ELSE IF ( LE_32( brate, IVAS_16k4 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_24400_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_24k4 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_32000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_32k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_32000; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_48k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_48000; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_64k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_64000; + move16(); + } + BREAK; + case IGF_MODE_FB: + IF ( LE_32( brate, IVAS_16k4 ) ) + { + bitRateIndex = IGF_BITRATE_FB_24400_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_24k4 ) ) + { + bitRateIndex = IGF_BITRATE_FB_32000_CPE; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_32k ) ) + { + bitRateIndex = IGF_BITRATE_FB_32000; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_48k ) ) + { + bitRateIndex = IGF_BITRATE_FB_48000; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_64k ) ) + { + bitRateIndex = IGF_BITRATE_FB_64000; + } + ELSE IF ( LE_32( brate, IVAS_96k ) ) + { + bitRateIndex = IGF_BITRATE_FB_96000; + move16(); + } + ELSE IF ( LE_32( brate, IVAS_128k ) ) + { + bitRateIndex = IGF_BITRATE_FB_128000; + move16(); + } + BREAK; + } + } + /* EVS mono */ + ELSE + { + SWITCH ( bwidth ) + { + case IGF_MODE_WB: + IF ( LE_32( brate, ACELP_13k20 ) && EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_WB_13200; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_9k60 ) ) /* bitrates 8000 and 9600 */ + { + bitRateIndex = IGF_BITRATE_WB_9600; + move16(); + } + BREAK; + case IGF_MODE_SWB: + IF ( LE_32( brate, ACELP_9k60 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_9600; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_13k20 ) ) + { + IF ( EQ_16( rf_mode, 1 ) ) + { + bitRateIndex = IGF_BITRATE_RF_SWB_13200; + move16(); + } + ELSE + { + bitRateIndex = IGF_BITRATE_SWB_13200; + move16(); + } + } + ELSE IF ( LE_32( brate, ACELP_16k40 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_16400; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_24k40 ) ) + { + bitRateIndex = IGF_BITRATE_SWB_24400; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_32k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_32000; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_48k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_48000; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_64k ) ) + { + bitRateIndex = IGF_BITRATE_SWB_64000; + move16(); + } + BREAK; + case IGF_MODE_FB: + IF ( LE_32( brate, ACELP_16k40 ) ) + { + bitRateIndex = IGF_BITRATE_FB_16400; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_24k40 ) ) + { + bitRateIndex = IGF_BITRATE_FB_24400; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_32k ) ) + { + bitRateIndex = IGF_BITRATE_FB_32000; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_48k ) ) + { + bitRateIndex = IGF_BITRATE_FB_48000; + move16(); + } + ELSE IF ( LE_32( brate, ACELP_64k ) ) + { + bitRateIndex = IGF_BITRATE_FB_64000; + move16(); + } + ELSE IF ( LE_32( brate, HQ_96k ) ) + { + bitRateIndex = IGF_BITRATE_FB_96000; + move16(); + } + ELSE IF ( LE_32( brate, HQ_128k ) ) + { + bitRateIndex = IGF_BITRATE_FB_128000; + move16(); + } + BREAK; + } + } + + return bitRateIndex; +} +#endif /*---------------------------------------------------------------------* * IGF_gridSetUp_flt() diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index cfefe1121..89ddd1899 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -51,7 +51,7 @@ static Word16 IGF_MapBitRateToIndex( /* Stereo/CPE modes */ IF(GT_16(element_mode, IVAS_SCE)) { - switch (bwidth) + SWITCH (bwidth) { case IGF_MODE_WB: IF(LE_32(brate, IVAS_13k2) && EQ_16(rf_mode, 1)) @@ -176,7 +176,7 @@ static Word16 IGF_MapBitRateToIndex( /* SCE modes: use tunings done for DFT stereo bitrates also for according SCE bitrates, otherwise same config as mono modes */ ELSE IF(EQ_16(element_mode, IVAS_SCE)) { - switch (bwidth) + SWITCH (bwidth) { case IGF_MODE_WB: IF(LE_32(brate, IVAS_13k2) && EQ_16(rf_mode, 1) ) @@ -277,7 +277,7 @@ static Word16 IGF_MapBitRateToIndex( /* EVS mono */ else { - switch (bwidth) + SWITCH (bwidth) { case IGF_MODE_WB: IF(LE_32(brate, ACELP_13k20) && EQ_16(rf_mode, 1)) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index e9ec74717..8742ed43d 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -40,6 +40,7 @@ #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* @@ -52,6 +53,12 @@ #define BETA_ISM_MEDIUM_IMP 0.8f #define MAX_BRATE_TCX_32k 48000 +#define BITS_IVAS_512k ( IVAS_512k / FRAMES_PER_SEC ) +#define BITS_ACELP_12k8_HIGH_LIMIT ( ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC ) +#define BITS_MIN_BRATE_SWB_BWE ( MIN_BRATE_SWB_BWE / FRAMES_PER_SEC ) +#define BITS_MIN_BRATE_WB_BWE ( MIN_BRATE_WB_BWE / FRAMES_PER_SEC ) +#define BITS_ACELP_16k_LOW_LIMIT_1k6 ( ACELP_16k_LOW_LIMIT + SWB_TBE_1k6 ) / FRAMES_PER_SEC +#define BITS_MAX_BRATE_TCX_32k ( MAX_BRATE_TCX_32k / FRAMES_PER_SEC ) /*-------------------------------------------------------------------* @@ -61,14 +68,14 @@ *-------------------------------------------------------------------*/ void bitbudget_to_brate( - const int16_t x[], /* i : bitbudgets */ - int32_t y[], /* o : bitrates */ - const int16_t N /* i : number of entries to be converted */ + const Word16 x[], /* i : bitbudgets */ + Word32 y[], /* o : bitrates */ + const Word16 N /* i : number of entries to be converted */ ) { - int16_t i; + Word16 i; - for ( i = 0; i < N; i++ ) + FOR ( i = 0; i < N; i++ ) { y[i] = FRAMES_PER_SEC * x[i]; } @@ -379,6 +386,346 @@ ivas_error ivas_ism_config( return error; } +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_ism_config_fx( + const Word32 ism_total_brate, /* i : ISM total bitrate */ + const Word16 nchan_transport, /* i : number of transport channels */ + const Word16 nchan_ism, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 ism_extended_metadata_flag, /* i : extended metadata flag */ + const Word16 null_metadata_flag[MAX_NUM_OBJECTS], /* i : NULL MD flag */ + const Word16 ism_imp[], /* i : ISM importance flags */ + Word32 element_brate[], /* o : element bitrate per object */ + Word32 total_brate[], /* o : total bitrate per object */ + Word16 nb_bits_metadata[], /* i/o: number of metadata bits */ + const Word16 combined_format_flag /* i : flag indicating combined format */ +) +{ + Word16 ch; + Word16 bits_element[MAX_NUM_OBJECTS], bits_CoreCoder[MAX_NUM_OBJECTS]; + Word16 bits_ism, bits_side; + Word16 limit_high = 0; /* just to avoid compilation warning */ + Word16 tmp, tmp1, exp; + Word16 ism_metadata_flag_global; + Word16 n_ISms; + ivas_error error; + + error = IVAS_ERR_OK; + move16(); + IF ( combined_format_flag ) + { + n_ISms = nchan_ism; + move16(); + } + ELSE + { + n_ISms = nchan_transport; + move16(); + } + + /* initialization */ + ism_metadata_flag_global = 0; + move16(); + bits_side = 0; + move16(); + IF ( hIsmMeta != NULL ) + { + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + ism_metadata_flag_global = s_or( ism_metadata_flag_global, ism_imp[ch] ); + } + } + + /* decision about bitrates per channel */ + IF ( combined_format_flag ) + { + /* combined format: decision about bitrates per channel - variable during the session (at one ivas_total_brate) */ + //bits_ism = (Word16) ( ism_total_brate / FRAMES_PER_SEC ); + bits_ism = ( Word16 ) Mpy_32_32( 42949673, ism_total_brate ); + tmp1 = BASOP_Util_Divide1616_Scale( bits_ism, n_ISms, &exp ); + set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms ); + bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms ); + + /* ISM common signaling bits are counted in MASA MD bit-budget */ + } + ELSE + { + /* ISM format: decision about bitrates per channel - constant during the session (at one ivas_total_brate) */ + //bits_ism = (Word16) ( ism_total_brate / FRAMES_PER_SEC ); + // 1 / 50 * 2 ^ 31 -- > 42949673, --> Q31, + //(Q31 +Q0) - Q31 --> Q0 + bits_ism = (Word16)Mpy_32_32( 42949673, ism_total_brate ); + tmp1 = BASOP_Util_Divide1616_Scale(bits_ism, n_ISms, &exp); + set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms ); + bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms ); + bitbudget_to_brate( bits_element, element_brate, n_ISms ); + + /* count ISm common signaling bits */ + IF ( hIsmMeta != NULL ) + { + nb_bits_metadata[0] = add( nb_bits_metadata[0], add( n_ISms * ISM_METADATA_FLAG_BITS, nchan_ism ) ); + + IF ( GE_32( ism_total_brate, ISM_EXTENDED_METADATA_BRATE ) ) + { + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_EXTENDED_METADATA_BITS ); + + IF ( ism_extended_metadata_flag ) + { + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_IS_NDP_BITS ); + } + } + + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( null_metadata_flag[ch] ) + { + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS ); + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_FLAG_BITS ); + } + ELSE + { + IF ( ism_imp[ch] == ISM_NO_META ) + { + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS ); + nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_INACTIVE_FLAG_BITS ); + } + } + } + } + } + + /* split metadata bitbudget equally between channels */ + IF ( nb_bits_metadata != NULL ) + { + bits_side = sum_s( nb_bits_metadata, n_ISms ); + tmp1 = BASOP_Util_Divide1616_Scale( bits_side, n_ISms, &exp ); + set_s( nb_bits_metadata, shr( tmp1, ( 15 - exp ) ), n_ISms ); + nb_bits_metadata[n_ISms - 1] = add( nb_bits_metadata[n_ISms - 1], bits_side % n_ISms ); + v_sub_s( bits_element, nb_bits_metadata, bits_CoreCoder, n_ISms ); + bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); + + mvs2s( nb_bits_metadata, nb_bits_metadata, n_ISms ); + } + + /* assign less CoreCoder bit-budget to inactive streams (at least one stream must be active) */ + IF ( ism_metadata_flag_global ) + { + Word16 diff, n_higher, flag_higher[MAX_NUM_OBJECTS]; + + set_s( flag_higher, 1, MAX_NUM_OBJECTS ); + + diff = 0; + move16(); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( EQ_16( ism_imp[ch], ISM_NO_META ) ) + { + diff = add( diff, sub( bits_CoreCoder[ch], BITS_ISM_INACTIVE ) ); + bits_CoreCoder[ch] = BITS_ISM_INACTIVE; + flag_higher[ch] = 0; + } + } + + n_higher = sum_s( flag_higher, n_ISms ); + + test(); + IF ( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) ) + { + tmp = BASOP_Util_Divide1616_Scale( diff, n_higher, &exp ); + tmp = shr( tmp, ( 15 - exp ) ); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( flag_higher[ch] ) + { + bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + } + } + + tmp = diff % n_higher; + move16(); + ch = 0; + move16(); + WHILE ( EQ_16( flag_higher[ch], 0 ) ) + { + ch = add( ch, 1 ); + } + bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + } + + bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); + + diff = 0; + move16(); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + Word16 limit; + + limit = BITS_MIN_BRATE_SWB_BWE; + move16(); + IF ( LT_32( element_brate[ch], MIN_BRATE_SWB_STEREO ) ) /* replicate function set_bw() -> check the coded audio band-width */ + { + limit = BITS_MIN_BRATE_WB_BWE; + move16(); + } + ELSE IF ( GE_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */ + { + /*limit = SCE_CORE_16k_LOW_LIMIT;*/ + limit = BITS_ACELP_16k_LOW_LIMIT_1k6; + move16(); + } + + IF ( EQ_16( ism_imp[ch], ISM_NO_META ) ) + { + tmp = BITS_ISM_INACTIVE; + move16(); + } + ELSE IF ( EQ_16( ism_imp[ch], ISM_LOW_IMP ) ) + { + //tmp = (Word16) ( BETA_ISM_LOW_IMP * bits_CoreCoder[ch] ); + tmp1 = BASOP_Util_Divide1616_Scale( bits_CoreCoder[ch], 5, &exp ); + tmp = shr( mult( tmp1, 24576 ), ( 15 - exp + 13 ) - 15); + tmp = s_max( limit, tmp ); + } + ELSE IF ( EQ_16( ism_imp[ch], ISM_MEDIUM_IMP ) ) + { + //tmp = (Word16) ( BETA_ISM_MEDIUM_IMP * bits_CoreCoder[ch] ); + tmp1 = BASOP_Util_Divide1616_Scale( bits_CoreCoder[ch], 5, &exp ); + tmp = shr( mult( tmp1, 16384 ), ( 15 - exp + 12 ) - 15 ); + tmp = s_max( limit, tmp ); + } + ELSE /* ism_imp[ch] == ISM_HIGH_IMP */ + { + tmp = bits_CoreCoder[ch]; + move16(); + } + + diff = add( diff, sub( bits_CoreCoder[ch], tmp ) ); + bits_CoreCoder[ch] = tmp; + move16(); + } + + test(); + IF ( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) ) + { + tmp = BASOP_Util_Divide1616_Scale( diff , n_higher, &exp ); + tmp = shr( tmp, ( 15 - exp ) ); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( flag_higher[ch] ) + { + bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp ); + } + } + + tmp = diff % n_higher; + move16(); + ch = 0; + move16(); + WHILE ( EQ_16( flag_higher[ch], 0 ) ) + { + ch = add( ch, 1 ); + } + bits_CoreCoder[ch] = add(bits_CoreCoder[ch], tmp ); + } + + /* verify for the maximum bitrate @12.8kHz core */ + diff = 0; + move16(); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + limit_high = BITS_IVAS_512k; + move16(); + IF ( LT_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */ + { + limit_high = BITS_ACELP_12k8_HIGH_LIMIT; + move16(); + } + + tmp = (Word16) s_min( bits_CoreCoder[ch], limit_high ); + + diff = add( diff, sub( bits_CoreCoder[ch], tmp ) ); + bits_CoreCoder[ch] = tmp; + move16(); + } + + /* limitation to avoid too high bitrate in one active TCX channel */ + test(); + IF ( GE_32( element_brate[0], SCE_CORE_16k_LOW_LIMIT ) && LE_32( element_brate[0], IVAS_32k ) ) + { + diff = 0; + move16(); + limit_high = BITS_MAX_BRATE_TCX_32k; + + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + tmp = (Word16) s_min( bits_CoreCoder[ch], limit_high ); + + diff = add( diff, sub( bits_CoreCoder[ch], tmp ) ); + bits_CoreCoder[ch] = tmp; + move16(); + } + } + + IF ( GT_16( diff, 0 ) ) + { + ch = 0; + move16(); + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( EQ_16( flag_higher[ch], 0 ) ) + { + IF ( GT_16( diff, limit_high ) ) + { + diff = add( diff, sub( bits_CoreCoder[ch], limit_high ) ); + bits_CoreCoder[ch] = limit_high; + move16(); + } + ELSE + { + bits_CoreCoder[ch] = add( bits_CoreCoder[ch], diff ); + + IF ( combined_format_flag ) + { + diff = 0; + move16(); + } + BREAK; + } + } + } + } + + IF ( combined_format_flag ) + { + IF ( GT_16( diff, 0 ) ) + { + FOR ( ch = 0; ch < n_ISms; ch++ ) + { + IF ( LE_16( ism_imp[ch], ISM_MEDIUM_IMP ) ) + { + IF ( GT_16( diff, limit_high ) ) + { + diff = add( diff, sub( bits_CoreCoder[ch], limit_high ) ); + bits_CoreCoder[ch] = limit_high; + move16(); + } + ELSE + { + bits_CoreCoder[ch] = add( bits_CoreCoder[ch], diff ); + BREAK; + } + } + } + } + } + + bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); + } + + + return error; +} +#endif /*-------------------------------------------------------------------* * ivas_ism_reset_metadata() @@ -596,17 +943,17 @@ void ivas_param_ism_config( /*! r : ISM format mode */ ISM_MODE ivas_ism_mode_select( - const int16_t nchan_inp, /* i : number of input objects */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const Word16 nchan_inp, /* i : number of input objects */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ ) { ISM_MODE ism_mode = ISM_MODE_NONE; - if ( nchan_inp > 2 && ivas_total_brate <= ACELP_32k ) + IF ( GT_16( nchan_inp, 2 ) && LE_32( ivas_total_brate, ACELP_32k ) ) { ism_mode = ISM_MODE_PARAM; } - else + ELSE { ism_mode = ISM_MODE_DISC; } @@ -676,7 +1023,29 @@ void update_last_metadata( return; } +#ifdef IVAS_FLOAT_FIXED +void update_last_metadata_fx( + const Word16 nchan_ism, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 updt_flag[] /* i : last metadata update flag */ +) +{ + Word16 ch; + FOR ( ch = 0; ch < nchan_ism; ch++ ) + { + IF ( EQ_16( updt_flag[ch], 1 ) ) + { + hIsmMeta[ch]->last_azimuth_fx = hIsmMeta[ch]->azimuth_fx; + move32(); + hIsmMeta[ch]->last_elevation_fx = hIsmMeta[ch]->elevation_fx; + move32(); + } + } + + return; +} +#endif /*----------------------------------------------------------------* * ivas_get_ism_sid_quan_bitbudget() * diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 664dd3a70..937edd564 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -48,67 +48,79 @@ /*! r : MC format mode */ MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ - const int32_t total_brate /* i : IVAS total bitrate */ + const Word32 total_brate /* i : IVAS total bitrate */ ) { MC_MODE mc_mode = MC_MODE_MCT; + move16(); - switch ( mc_ls_setup ) + SWITCH ( mc_ls_setup ) { case MC_LS_SETUP_5_1: - if ( total_brate < IVAS_48k ) + IF ( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; + move16(); } - else if ( total_brate < IVAS_96k ) + ELSE IF ( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_PARAMMC; + move16(); } - break; + BREAK; case MC_LS_SETUP_7_1: - if ( total_brate < IVAS_48k ) + IF ( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; + move16(); } - else if ( total_brate < IVAS_128k ) + ELSE IF ( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; + move16(); } - break; + BREAK; case MC_LS_SETUP_5_1_2: - if ( total_brate < IVAS_48k ) + IF ( LT_32( total_brate, IVAS_48k ) ) { mc_mode = MC_MODE_MCMASA; + move16(); } - else if ( total_brate < IVAS_128k ) + ELSE IF ( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_PARAMMC; + move16(); } - break; + BREAK; case MC_LS_SETUP_5_1_4: - if ( total_brate < IVAS_96k ) + IF ( LT_32( total_brate, IVAS_96k ) ) { mc_mode = MC_MODE_MCMASA; + move16(); } - else if ( total_brate < IVAS_160k ) + ELSE IF ( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; + move16(); } - break; + BREAK; case MC_LS_SETUP_7_1_4: - if ( total_brate < IVAS_128k ) + IF ( LT_32( total_brate, IVAS_128k ) ) { mc_mode = MC_MODE_MCMASA; + move16(); } - else if ( total_brate < IVAS_160k ) + ELSE IF ( LT_32( total_brate, IVAS_160k ) ) { mc_mode = MC_MODE_PARAMMC; + move16(); } - else if ( total_brate < IVAS_192k ) + ELSE IF ( LT_32( total_brate, IVAS_192k ) ) { mc_mode = MC_MODE_PARAMUPMIX; + move16(); } - break; + BREAK; default: assert( 0 && "LS Setup not supported or defined for MC mode!\n" ); } @@ -171,24 +183,30 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( MC_LS_SETUP mc_ls_setup; mc_ls_setup = MC_LS_SETUP_INVALID; + move16(); - switch ( output_config ) + SWITCH ( output_config ) { case IVAS_AUDIO_CONFIG_5_1: mc_ls_setup = MC_LS_SETUP_5_1; - break; + move16(); + BREAK; case IVAS_AUDIO_CONFIG_7_1: mc_ls_setup = MC_LS_SETUP_7_1; - break; + move16(); + BREAK; case IVAS_AUDIO_CONFIG_5_1_2: mc_ls_setup = MC_LS_SETUP_5_1_2; - break; + move16(); + BREAK; case IVAS_AUDIO_CONFIG_5_1_4: mc_ls_setup = MC_LS_SETUP_5_1_4; - break; + move16(); + BREAK; case IVAS_AUDIO_CONFIG_7_1_4: mc_ls_setup = MC_LS_SETUP_7_1_4; - break; + move16(); + BREAK; default: assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" ); } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a77946813..a629e1a6a 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -324,8 +324,8 @@ ivas_error ivas_dec_setup( #ifndef IVAS_FLOAT_FIXED ivas_error create_sce_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t cpe_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ + const Word16 cpe_id, /* i : SCE # identifier */ + const Word32 element_brate /* i : element bitrate */ ); ivas_error create_cpe_dec( @@ -668,7 +668,7 @@ ivas_error ivas_mc_dec_config( /*! r: MC format mode (MCT, McMASA, ParamMC) */ MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : loudspeaker setup (CICP) */ - const int32_t total_brate /* i : IVAS total bitrate */ + const Word32 total_brate /* i : IVAS total bitrate */ ); /*! r: number of loudspeaker channels */ @@ -900,7 +900,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( ); /*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity( +int16_t ivas_jbm_dec_get_render_granularity_flt( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ @@ -947,23 +947,23 @@ void ivas_jbm_masa_sf_to_sf_map( *----------------------------------------------------------------------------------*/ ivas_error ivas_ism_config( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nchan_ism, /* i : number of objects */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t ism_extended_metadata_flag, /* i : extended metadata flag */ - const int16_t null_metadata_flag[MAX_NUM_OBJECTS], /* i : NULL MD flag */ - const int16_t ism_imp[], /* i : ISM importance flags */ - int32_t element_brate[], /* o : element bitrate per object */ - int32_t total_brate[], /* o : total bitrate per object */ - int16_t nb_bits_metadata[], /* i/o: number of metadata bits */ - const int16_t combined_format_flag /* i : flag indicating combined format */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_ism, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const int16_t ism_extended_metadata_flag, /* i : extended metadata flag */ + const int16_t null_metadata_flag[MAX_NUM_OBJECTS], /* i : NULL MD flag */ + const int16_t ism_imp[], /* i : ISM importance flags */ + int32_t element_brate[], /* o : element bitrate per object */ + int32_t total_brate[], /* o : total bitrate per object */ + int16_t nb_bits_metadata[], /* i/o: number of metadata bits */ + const int16_t combined_format_flag /* i : flag indicating combined format */ ); void bitbudget_to_brate( - const int16_t x[], /* i : bitbudgets */ - int32_t y[], /* o : bitrates */ - const int16_t N /* i : number of entries to be converted */ + const Word16 x[], /* i : bitbudgets */ + Word32 y[], /* o : bitrates */ + const Word16 N /* i : number of entries to be converted */ ); void ivas_ism_reset_metadata( @@ -1064,8 +1064,8 @@ ivas_error ivas_ism_metadata_dec( /*! r: ISM format mode */ ISM_MODE ivas_ism_mode_select( - const int16_t nchan_inp, /* i : number of input objects */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const Word16 nchan_inp, /* i : number of input objects */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); ivas_error ivas_param_ism_enc_open( diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 8a5d14f16..93fed0737 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -640,4 +640,56 @@ void ivas_mcmasa_split_brate_fx( Word32 *brate_cpe /* o : Pointer to CPE element bitrate */ ); -#endif +void update_last_metadata_fx( + const Word16 nchan_ism, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 updt_flag[] /* i : last metadata update flag */ +); + +ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ + const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ + const Word16 nchan_full, /* i : new number of channels to fully store */ + const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ +); + +ivas_error ivas_dirac_allocate_parameters_fx( + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const Word16 params_flag /* i : set of parameters flag */ +); + +Word16 configure_reqularization_factor_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +ivas_error ivas_ism_config_fx( + const Word32 ism_total_brate, /* i : ISM total bitrate */ + const Word16 nchan_transport, /* i : number of transport channels */ + const Word16 nchan_ism, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 ism_extended_metadata_flag, /* i : extended metadata flag */ + const Word16 null_metadata_flag[MAX_NUM_OBJECTS], /* i : NULL MD flag */ + const Word16 ism_imp[], /* i : ISM importance flags */ + Word32 element_brate[], /* o : element bitrate per object */ + Word32 total_brate[], /* o : total bitrate per object */ + Word16 nb_bits_metadata[], /* i/o: number of metadata bits */ + const Word16 combined_format_flag /* i : flag indicating combined format */ +); + +Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const Word32 output_Fs /* i : sampling rate */ +); +#endif \ No newline at end of file diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 33f009c5a..6f9941de3 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -336,7 +336,7 @@ Word16 ivas_sba_get_nchan_metadata( ELSE { /* FOA + planar HOA */ - nb_channels = add(FOA_CHANNELS , shl( sub( sba_order , 1 ),1)); + nb_channels = add( FOA_CHANNELS, shl( sub( sba_order, 1 ), 1 ) ); } } diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c index eafac4193..80994dda9 100644 --- a/lib_com/ivas_stereo_mdct_bands_com.c +++ b/lib_com/ivas_stereo_mdct_bands_com.c @@ -39,6 +39,7 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" +#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* * Local union @@ -226,7 +227,11 @@ void stereo_mdct_init_igf_start_band( int16_t i, bitRateIndex, igfStartLine; const int16_t *swb_offset; +#ifdef IVAS_FLOAT_FIXED + bitRateIndex = IGF_MapBitRateToIndex( element_brate, bwidth, IVAS_CPE_MDCT, 0 ); +#else bitRateIndex = IGF_MapBitRateToIndex_flt( element_brate, bwidth, IVAS_CPE_MDCT, 0 ); +#endif swb_offset = &swb_offset_LB_new[bitRateIndex][1]; igfStartLine = IGF_ApplyTransFac_flt( swb_offset[0], transFac ); diff --git a/lib_com/prot.h b/lib_com/prot.h index a22d96bf5..71fbd3376 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -9991,10 +9991,10 @@ int16_t IGF_ApplyTransFac_flt( /*! r: return bitrate index */ int16_t IGF_MapBitRateToIndex_flt( - const int32_t brate, /* i : bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ + const int32_t brate, /* i : bitrate */ + const int16_t bwidth, /* i : audio bandwidth */ + const int16_t element_mode, /* i : element mode */ + const int16_t rf_mode /* i : flag to signal the RF mode */ ); void IGFSCFEncoderOpen( diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 5e0859f7b..1734df734 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -8222,4 +8222,11 @@ void ivas_get_stereo_panning_gains_fx( const Word16 aziDeg, const Word16 eleDeg, Word16 panningGains[2] ); + +ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); #endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 6aa71b694..e6e77c9f7 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -353,7 +353,7 @@ void deleteFdCngDec_flt( { HANDLE_FD_CNG_DEC hsDec = *hFdCngDec; - if ( hsDec != NULL ) + IF ( hsDec != NULL ) { deleteFdCngCom_flt( &( hsDec->hFdCngCom ) ); free( hsDec ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 365cb006c..7e8acd1f3 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -903,7 +903,11 @@ ivas_error ivas_dirac_dec_config( } } +#ifdef IVAS_FLOAT_FIXED + st_ivas->hDiracDecBin->reqularizationFactor = (float) configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ) / ( 1 << 14 ); +#else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif } } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 589a5ebf3..388a8a6fb 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -41,10 +41,10 @@ #include #include #include "wmc_auto.h" -#include "ivas_prot_fx.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx1.h" #include "prot_fx2.h" +#include "ivas_prot_fx.h" #endif // IVAS_FLOAT_FIXED @@ -1717,7 +1717,11 @@ ivas_error ivas_init_decoder( granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#else IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1760,7 +1764,11 @@ ivas_error ivas_init_decoder( n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) +#else IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1771,7 +1779,11 @@ ivas_error ivas_init_decoder( n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#else IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1930,7 +1942,11 @@ ivas_error ivas_init_decoder( /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1939,7 +1955,11 @@ ivas_error ivas_init_decoder( IF ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) +#else IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index da6b5a07f..c63051f25 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -86,7 +86,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); #endif // IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -144,7 +148,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ +#ifdef IVAS_FLOAT_FIXED tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#else + tc_granularity_new = ivas_jbm_dec_get_render_granularity_flt( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 8884ae102..df081c536 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -37,7 +37,23 @@ #include "ivas_prot_fx.h" #include "prot.h" #include "wmc_auto.h" +#include "ivas_prot_fx.h" + +#ifdef IVAS_FLOAT_FIXED +static Word16 float_to_fix16(float number, Word16 Q); +static float fix16_to_float(Word16 number, Word16 Q); + +static Word16 float_to_fix16(float number, Word16 Q){ + Word16 ret=(Word16)(number * ((UWord16)1 << Q)); + return ret; +} +static float fix16_to_float(Word16 number, Word16 Q){ + float ret=(float) number / ((UWord16)1 << Q); + return ret; +} + +#endif /*-------------------------------------------------------------------* * ivas_ism_dtx_dec() @@ -131,8 +147,29 @@ void ivas_ism_dtx_dec( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed = st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed; } } +#ifdef IVAS_FLOAT_FIXED + for ( ch = 0; ch < nchan_ism; ch++ ) + { + if ( EQ_16(md_diff_flag[ch], 1 ) ) + { + st_ivas->hIsmMetaData[ch]->azimuth_fx = float_to_fix16(st_ivas->hIsmMetaData[ch]->azimuth, 7); // azimuth -180 to +180 + st_ivas->hIsmMetaData[ch]->elevation_fx = float_to_fix16(st_ivas->hIsmMetaData[ch]->elevation, 8); // azimuth -180 to +180 + } + } + update_last_metadata_fx( nchan_ism, st_ivas->hIsmMetaData, md_diff_flag ); + + for ( ch = 0; ch < nchan_ism; ch++ ) + { + if ( EQ_16(md_diff_flag[ch], 1 ) ) + { + st_ivas->hIsmMetaData[ch]->last_azimuth = fix16_to_float(st_ivas->hIsmMetaData[ch]->last_azimuth_fx, 7 ); + st_ivas->hIsmMetaData[ch]->last_elevation = fix16_to_float(st_ivas->hIsmMetaData[ch]->last_elevation_fx, 8); + } + } +#else update_last_metadata( nchan_ism, st_ivas->hIsmMetaData, md_diff_flag ); +#endif st_ivas->hISMDTX.ism_dtx_hangover_cnt = 0; diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index f92bfbef8..be37aaa7c 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -43,6 +43,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* @@ -634,7 +635,11 @@ ivas_error ivas_ism_metadata_dec( } } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_ism_config_fx( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, masa_ism_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, masa_ism_flag ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 112d32ce6..863e455d1 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -573,26 +573,22 @@ ivas_error ivas_param_ism_dec_open( if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef IVAS_FLOAT_FIXED - if ((error = ivas_dirac_allocate_parameters_fx(hSpatParamRendCom, 1)) != IVAS_ERR_OK) - { - return error; - } - - if ((error = ivas_dirac_allocate_parameters_fx(hSpatParamRendCom, 2)) != IVAS_ERR_OK) - { - return error; - } + IF ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) +#endif { return error; } -#endif } st_ivas->hISMDTX.dtx_flag = 0; @@ -656,7 +652,12 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { + +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -673,7 +674,11 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 1f51e9f19..002bf77ec 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -112,12 +112,12 @@ void ivas_ism_renderer_close( ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ ) { - if ( hIsmRendererData == NULL || *hIsmRendererData == NULL ) + IF ( hIsmRendererData == NULL || *hIsmRendererData == NULL ) { return; } - if ( ( *hIsmRendererData )->interpolator != NULL ) + IF ( ( *hIsmRendererData )->interpolator != NULL ) { free( ( *hIsmRendererData )->interpolator ); ( *hIsmRendererData )->interpolator = NULL; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6d01d5eac..329ae0059 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2095,6 +2095,23 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) +#ifdef IVAS_FLOAT_FIXED +{ + Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; + + /* render first frame with front zero padding and discarding those samples */ + nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); + IF ( GT_16( nSlotsInFirstSubframe, 0 ) ) + { + st_ivas->hTcBuffer->n_samples_discard = sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ) * st_ivas->hTcBuffer->n_samples_granularity; + /* set last subframes number to max to ensure correct continuation */ + st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; + } + + return IVAS_ERR_OK; +} +#else { int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; @@ -2110,6 +2127,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( return IVAS_ERR_OK; } +#endif /*--------------------------------------------------------------------------* @@ -2171,28 +2189,32 @@ void ivas_jbm_dec_get_adapted_subframes( /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ - nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); + nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); *nb_subframes = 0; - IF ( nSlotsInFirstSubframe > 0 ) + move16(); + IF ( GT_16( nSlotsInFirstSubframe, 0 ) ) { *nb_subframes = 1; - nCldfbSlotsLocal -= nSlotsInFirstSubframe; + move16(); + nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe ); } - *nb_subframes += (nCldfbSlotsLocal + PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1) / PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + *nb_subframes = add( *nb_subframes, ( nCldfbSlotsLocal + PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1) / PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); - IF ( nSlotsInFirstSubframe > 0 ) + IF ( GT_16( nSlotsInFirstSubframe, 0 ) ) { subframe_nbslots[0] = nSlotsInFirstSubframe; + move16(); } - IF ( nSlotsInLastSubframe > 0 ) + IF ( GT_16( nSlotsInLastSubframe, 0 ) ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; + move16(); } return; @@ -2268,8 +2290,8 @@ void ivas_jbm_dec_get_md_map( (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ IF ( src_idx >= 0 ) { - dec_fx = L_shl(src_idx + 1, 16) / jbm_segment_len; - src_idx_fx = L_shl(src_idx + 1, 16) - dec_fx; + dec_fx = L_shl(src_idx + 1, 16) / jbm_segment_len; + src_idx_fx = L_shl(src_idx + 1, 16) - dec_fx; FOR ( ; map_idx >= 0; map_idx-- ) { src_idx = max( 0, round_fx( src_idx_fx ) / subframe_len ); @@ -2365,7 +2387,7 @@ void ivas_jbm_dec_get_md_map_even_spacing( eps_fx = 65; FOR ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - increment = (Word16)L_shr(decimal_sum_fx + eps_fx, 16); + increment = (Word16)L_shr(decimal_sum_fx + eps_fx, 16); subframe_map_length[sf_idx] = sf_length + increment; IF ( increment > 0 ) { @@ -2825,7 +2847,7 @@ static void ivas_jbm_dec_copy_tc( *--------------------------------------------------------------------------*/ /*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity( +int16_t ivas_jbm_dec_get_render_granularity_flt( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ @@ -2853,6 +2875,38 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const Word32 output_Fs /* i : sampling rate */ +) +{ + Word16 render_granularity; + + test(); test(); + IF ( EQ_32( rendererType, RENDERER_BINAURAL_OBJECTS_TD ) || EQ_32( rendererType, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( rendererType, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + { + test(); + IF ( ( EQ_32( ivas_format, MC_FORMAT ) ) && ( EQ_32( mc_mode, MC_MODE_PARAMUPMIX ) ) ) + { + render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + } + ELSE + { + render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + ELSE + { + render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + } + + return render_granularity; +} +#endif + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() @@ -3335,6 +3389,150 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return IVAS_ERR_OK; } +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ + const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ + const Word16 nchan_full, /* i : new number of channels to fully store */ + const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ +) +{ + Word16 nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; + Word16 ch_idx; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; + move16(); + + + /* if granularity changes, adapt subframe_nb_slots */ + IF ( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) + { + Word16 nMaxSlotsPerSubframeNew; + + nMaxSlotsPerSubframeNew = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + /* if samples were flushed, take that into account here */ + test(); + IF ( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && GT_16( hTcBuffer->n_samples_flushed, 0 ) ) + { + hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = hTcBuffer->n_samples_flushed / n_samples_granularity; + hTcBuffer->n_samples_flushed = 0; + } + ELSE + { + hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew; + } + } + + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + move16(); + hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + move16(); + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + move16(); + hTcBuffer->nchan_buffer_full = nchan_full; + move16(); + nchan_residual = sub( nchan_transport_internal, nchan_full ); + hTcBuffer->n_samples_granularity = n_samples_granularity; + move16(); + + /* realloc buffers */ + IF ( hTcBuffer->tc_buffer != NULL ) + { + free( hTcBuffer->tc_buffer ); + hTcBuffer->tc_buffer = NULL; + } + + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + n_samp_full = ( add( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ) ); + n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); + } + ELSE + { + n_samp_full = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_residual = 0; + move16(); + } + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; + nsamp_to_allocate = add( nsamp_to_allocate, nchan_residual * n_samp_residual ); + + IF ( EQ_16( nsamp_to_allocate, 0 ) ) + { + hTcBuffer->tc_buffer = NULL; + FOR ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } + ELSE + { + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + + IF ( ( hTcBuffer->tc_buffer_fx = (Word16 *) malloc( nsamp_to_allocate * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) ); + } + set16_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); + + offset = 0; + move16(); + FOR ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; + offset = add( offset, n_samp_full ); + } + FOR ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; + offset = add( offset, n_samp_residual ); + } + FOR ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc_fx[ch_idx] = NULL; + } + + /* TODO: remove the floating point dependency */ + IF ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + + offset = 0; + move16(); + FOR ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset = add( offset, n_samp_full ); + } + FOR ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset = add( offset, n_samp_residual ); + } + FOR ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } + ELSE + { + hTcBuffer->tc_buffer_fx = NULL; + + /* TODO: remove floating point dependency */ + hTcBuffer->tc_buffer = NULL; + + } + } + + return IVAS_ERR_OK; +} +#endif + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_playout() @@ -3473,6 +3671,100 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) +#ifdef IVAS_FLOAT_FIXED +{ + TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + + SWITCH ( st_ivas->renderer_type ) + { + /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ + case RENDERER_DISABLE: + case RENDERER_MCMASA_MONO_STEREO: + case RENDERER_OSBA_STEREO: + case RENDERER_MONO_DOWNMIX: + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + BREAK; + case RENDERER_TD_PANNING: + case RENDERER_BINAURAL_OBJECTS_TD: + case RENDERER_BINAURAL_FASTCONV: + case RENDERER_BINAURAL_FASTCONV_ROOM: + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + case RENDERER_STEREO_PARAMETRIC: + case RENDERER_DIRAC: + case RENDERER_PARAM_ISM: + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + case RENDERER_OSBA_AMBI: + case RENDERER_OSBA_LS: + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + BREAK; + case RENDERER_NON_DIEGETIC_DOWNMIX: + IF ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + break; + case RENDERER_MC_PARAMMC: + IF ( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; /* TCs are already the DMX to mono or stereo */ + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_MC: + IF ( NE_16( ivas_jbm_dec_get_num_tc_channels( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_SBA_LINEAR_ENC: + test(); test(); test(); test(); + IF ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( ( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), ( add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + case RENDERER_SBA_LINEAR_DEC: + test(); test(); + IF ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); + } + ELSE + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); + } + BREAK; + } + + return buffer_mode; +} +#else { TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -3551,6 +3843,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( return buffer_mode; } +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 5d6a42c68..16564e0b5 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -44,7 +44,6 @@ #include "prot_fx1.h" #include "prot_fx2.h" #include "ivas_prot_fx.h" -#include "prot_fx1.h" #include "ivas_rom_com_fx.h" @@ -822,7 +821,11 @@ ivas_error ivas_masa_dec_open( nchan_to_allocate++; } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2267,7 +2270,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDiracDecBin != NULL ) { /* regularization factor is bitrate-dependent */ +#ifdef IVAS_FLOAT_FIXED + st_ivas->hDiracDecBin->reqularizationFactor = (float) configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ) / ( 1 << 14 ); +#else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif } if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 4ea487a5f..da9b70bb9 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -45,6 +45,9 @@ #include "math.h" #include "wmc_auto.h" #include "rom_dec.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------* * Local constants @@ -452,7 +455,11 @@ ivas_error ivas_param_mc_dec_open( if ( st_ivas->hTcBuffer == NULL ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index adac05933..2cb7f1dd6 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -378,7 +378,11 @@ ivas_error ivas_mc_paramupmix_dec_open( nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index e06fb74ea..dae6a663c 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -42,10 +42,10 @@ #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx1.h" #include "prot_fx2.h" +#include "ivas_prot_fx.h" #endif // IVAS_FLOAT_FIXED @@ -707,20 +707,20 @@ void ivas_mct_dec_close( MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ ) { - int16_t n, maxBlocks; + Word16 n, maxBlocks; - if ( hMCT == NULL || *hMCT == NULL ) + IF ( hMCT == NULL || *hMCT == NULL ) { return; } maxBlocks = ( *hMCT )->nchan_out_woLFE / 2; - for ( n = 0; n < maxBlocks; n++ ) + FOR ( n = 0; n < maxBlocks; n++ ) { - if ( ( *hMCT )->hBlockData[n] != NULL ) + IF ( ( *hMCT )->hBlockData[n] != NULL ) { - if ( ( *hMCT )->hBlockData[n]->hStereoMdct != NULL ) + IF ( ( *hMCT )->hBlockData[n]->hStereoMdct != NULL ) { free( ( *hMCT )->hBlockData[n]->hStereoMdct ); ( *hMCT )->hBlockData[n]->hStereoMdct = NULL; @@ -881,7 +881,11 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef IVAS_FLOAT_FIXED tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#else + tc_granularity_new = ivas_jbm_dec_get_render_granularity_flt( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 906795ced..ab4ec5a5c 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -43,10 +43,10 @@ * * Select and configure IVAS renderer parameters *-------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) +#ifdef IVAS_FLOAT_FIXED { RENDERER_TYPE *renderer_type; AUDIO_CONFIG *internal_config; @@ -58,164 +58,204 @@ void ivas_renderer_select( renderer_type = &( st_ivas->renderer_type ); internal_config = &( st_ivas->intern_config ); output_config = st_ivas->hDecoderConfig->output_config; + move16(); transport_config = st_ivas->transport_config; + move16(); /* disabled rendering by default */ *renderer_type = RENDERER_DISABLE; + move16(); /*-----------------------------------------------------------------* * Binaural rendering configurations *-----------------------------------------------------------------*/ + test(); IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; + move16(); } - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + test(); test(); test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + ) { - IF ( EQ_16(st_ivas->ivas_format , ISM_FORMAT) ) + test(); test(); test(); test(); test(); + IF ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { - IF ( EQ_16(st_ivas->ism_mode , ISM_MODE_PARAM) ) + IF ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + move16(); } } ELSE /* ISM_MODE_DISC */ { - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + ) { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + move16(); *internal_config = output_config; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + move16(); *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + move16(); } } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_FORMAT) || EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT) || ( ( EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) && LE_16(st_ivas->nchan_transport , 2) ) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || ( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && LE_16( st_ivas->nchan_transport, 2 ) ) ) { *internal_config = output_config; + move16(); - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + move16(); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { *internal_config = IVAS_AUDIO_CONFIG_HOA3; + move16(); - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + move16(); } - IF ( EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) && EQ_16(*renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) + test(); + IF ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( *renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + move16(); } + test(); IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - IF ( EQ_16(nchan_internal , 2) ) + test(); test(); test(); + IF ( EQ_16( nchan_internal, 2 ) ) { st_ivas->hCombinedOrientationData->shd_rot_max_order = 1; } - ELSE IF ( EQ_16(nchan_internal , 4) || EQ_16(nchan_internal , 3) ) + ELSE IF ( EQ_16( nchan_internal, 4 ) || EQ_16( nchan_internal, 3 ) ) { st_ivas->hCombinedOrientationData->shd_rot_max_order = 0; } - ELSE IF ( EQ_16(nchan_internal , 6) || EQ_16(nchan_internal , 5) ) + ELSE IF ( EQ_16( nchan_internal, 6 ) || EQ_16( nchan_internal, 5 ) ) { st_ivas->hCombinedOrientationData->shd_rot_max_order = 2; } - ELSE IF ( EQ_16(nchan_internal , 8) || EQ_16(nchan_internal , 7) ) + ELSE IF ( EQ_16( nchan_internal, 8 ) || EQ_16( nchan_internal, 7 ) ) { st_ivas->hCombinedOrientationData->shd_rot_max_order = 3; } } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MC_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { *internal_config = output_config; + move16(); - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + move16(); } } ELSE { *internal_config = transport_config; - - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + move16(); + test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF ( ( EQ_16(st_ivas->transport_config , IVAS_AUDIO_CONFIG_5_1) || EQ_16(st_ivas->transport_config , IVAS_AUDIO_CONFIG_7_1) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) || EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) ) + test(); test(); test(); test(); test(); + IF ( ( EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + move16(); } ELSE { - IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { *renderer_type = RENDERER_BINAURAL_MIXER_CONV; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_FASTCONV; + move16(); } #if 0 // def DEBUGGING /*temp disabling this as paramMC crashes with CREND*/ - IF( EQ_16( st_ivas->hRenderConfig->renderer_type_override, IVAS_RENDER_TYPE_OVERRIDE_CREND ) ) + IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) { *renderer_type = RENDERER_BINAURAL_MIXER_CONV; } - ELSE IF( EQ_16( st_ivas->hRenderConfig->renderer_type_override, IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) ) + ELSE IF ( st_ivas->hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; } #endif + test(); IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { /* force HOA3 domain for rotation*/ *internal_config = IVAS_AUDIO_CONFIG_HOA3; + move16(); } } } ELSE { - IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + move16(); } ELSE { *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + move16(); } } } @@ -226,226 +266,279 @@ void ivas_renderer_select( * Non-binaural rendering configurations *-----------------------------------------------------------------*/ - ELSE IF ( EQ_16(st_ivas->ivas_format , MONO_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , STEREO_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_STEREO) && NE_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + test(); + IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_MC; + move16(); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , ISM_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { - IF ( ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) && ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) + test(); + IF ( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) && ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) { *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); } ELSE { - IF ( EQ_16(st_ivas->ism_mode , ISM_MODE_PARAM) ) + IF ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { *renderer_type = RENDERER_PARAM_ISM; - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_MONO_DOWNMIX; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + move16(); } } ELSE /* ISM_MODE_DISC */ { *renderer_type = RENDERER_TD_PANNING; - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_MONO_DOWNMIX; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } } } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { IVAS_FORMAT ivas_format; *renderer_type = RENDERER_DIRAC; - ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ + move16(); + ivas_format = ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ - IF ( EQ_16(ivas_format , SBA_FORMAT) && ( NE_16(output_config , IVAS_AUDIO_CONFIG_5_1) && NE_16(output_config , IVAS_AUDIO_CONFIG_5_1_2) && NE_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) && NE_16(output_config , IVAS_AUDIO_CONFIG_7_1) && NE_16(output_config , IVAS_AUDIO_CONFIG_7_1_4) && NE_16(output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) && NE_16(output_config , IVAS_AUDIO_CONFIG_MONO) && NE_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) ) + test(); test(); test(); test(); test(); test(); test(); + test(); test(); test(); test(); test(); test(); test(); + test(); test(); test(); test(); test(); test(); test(); + test(); test(); test(); test(); test(); test(); test(); + test(); test(); test(); + IF ( EQ_32( ivas_format, SBA_FORMAT ) && ( NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) ) + test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) ) { *internal_config = output_config; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *internal_config = IVAS_AUDIO_CONFIG_FOA; + move16(); } ELSE { *internal_config = IVAS_AUDIO_CONFIG_HOA3; + move16(); } st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; } - ELSE IF ( ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) && EQ_16(st_ivas->nchan_transport , 1) ) || - ( EQ_16(ivas_format , SBA_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) ) ) + ELSE IF ( ( EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) || + ( EQ_32( ivas_format, SBA_FORMAT ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } - ELSE IF ( ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) && LT_32(st_ivas->hDecoderConfig->ivas_total_brate , MASA_STEREO_MIN_BITRATE) && GT_32(st_ivas->hDecoderConfig->ivas_total_brate , IVAS_SID_5k2) ) ) + ELSE IF ( ( EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } - ELSE IF ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + ELSE IF ( EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *renderer_type = RENDERER_STEREO_PARAMETRIC; + move16(); } - ELSE IF ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + ELSE IF ( EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + ELSE IF ( EQ_32( ivas_format, SBA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_SBA_LINEAR_DEC; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + ELSE IF ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *renderer_type = RENDERER_OSBA_STEREO; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + ELSE IF ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_MONO_DOWNMIX; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) ) + ELSE IF ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) { *renderer_type = RENDERER_OSBA_AMBI; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) ) ) + ELSE IF ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ) { *renderer_type = RENDERER_OSBA_LS; + move16(); } - ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + ELSE IF ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { *renderer_type = RENDERER_SBA_LINEAR_DEC; + move16(); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { *renderer_type = RENDERER_DIRAC; + move16(); - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { *renderer_type = RENDERER_MONO_DOWNMIX; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { *renderer_type = RENDERER_STEREO_PARAMETRIC; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MC_FORMAT) ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { *internal_config = transport_config; - IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) && NE_16(*internal_config , output_config) ) + test(); + IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && NE_32( *internal_config, output_config ) ) { - IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_FOA) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA2) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + test(); test(); + IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_MC; + move16(); } ELSE { *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); } } - ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) + ELSE IF ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { *internal_config = transport_config; - IF ( NE_16(*internal_config , output_config) ) + IF ( NE_32( *internal_config, output_config ) ) { - IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_FOA) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA2) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + test(); test(); + IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_MC; + move16(); } ELSE { *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); } } } - ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) ) + ELSE IF ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); } ELSE { *renderer_type = RENDERER_MC_PARAMMC; } } - ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + ELSE IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { *internal_config = output_config; + move16(); /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - IF ( EQ_16(st_ivas->nchan_transport , 1) ) + test(); test(); + IF ( EQ_16( st_ivas->nchan_transport, 1 ) ) { *renderer_type = RENDERER_DISABLE; + move16(); } - ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) && EQ_16(st_ivas->nchan_transport , 2) && !st_ivas->hOutSetup.separateChannelEnabled ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && EQ_16( st_ivas->nchan_transport, 2 ) && !st_ivas->hOutSetup.separateChannelEnabled ) { *renderer_type = RENDERER_DISABLE; + move16(); } ELSE { *renderer_type = RENDERER_MCMASA_MONO_STEREO; + move16(); } } ELSE { *renderer_type = RENDERER_DIRAC; - IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + test(); test(); test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_SBA_LINEAR_ENC; *internal_config = transport_config; + move16(); } - ELSE IF ( EQ_16(transport_config , IVAS_AUDIO_CONFIG_5_1) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) ) ) + ELSE IF ( EQ_32( transport_config, IVAS_AUDIO_CONFIG_5_1 ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) ) { *internal_config = transport_config; + move16(); } } } } + return; } -#else // IVAS_FLOAT_FIXED - -void ivas_renderer_select( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) +#else { RENDERER_TYPE *renderer_type; AUDIO_CONFIG *internal_config; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 367ecccc8..711f93fdc 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -294,23 +294,23 @@ ivas_error ivas_sce_dec( ivas_error create_sce_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ + const Word16 sce_id, /* i : SCE # identifier */ + const Word32 element_brate /* i : element bitrate */ ) { SCE_DEC_HANDLE hSCE; Decoder_State *st; ivas_error error; - int16_t output_frame; + Word16 output_frame; error = IVAS_ERR_OK; - output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + output_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); /*-----------------------------------------------------------------* * Allocate SCE handle *-----------------------------------------------------------------*/ - if ( ( hSCE = (SCE_DEC_HANDLE) malloc( sizeof( SCE_DEC_DATA ) ) ) == NULL ) + IF ( ( hSCE = (SCE_DEC_HANDLE) malloc( sizeof( SCE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SCE\n" ) ); } @@ -329,7 +329,7 @@ ivas_error create_sce_dec( *-----------------------------------------------------------------*/ //if ( ( st = (DEC_CORE_HANDLE) calloc( sizeof( Decoder_State ) ) ) == NULL ) - if ( ( st = (Decoder_State *)calloc(1, sizeof(Decoder_State))) == NULL ) + IF ( ( st = (Decoder_State *)calloc(1, sizeof(Decoder_State))) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); } @@ -339,12 +339,12 @@ ivas_error create_sce_dec( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; st->is_ism_format = 0; - if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) + IF ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) { st->is_ism_format = 1; } #ifdef EVS_FLOAT - if ( ( error = init_decoder( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) + IF ( ( error = init_decoder( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) #else if ( ( error = init_decoder_fx(st, EVS_MONO) ) != IVAS_ERR_OK ) #endif @@ -352,22 +352,22 @@ ivas_error create_sce_dec( return error; } - if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ) ) + IF ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ) ) { - if ( ( error = openCldfb_ivas( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb_ivas( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { st->cldfbSynHB = NULL; } /* allocate and initialize "hTdCngDec" - needed in DTX */ - if ( sce_id == 0 && st->hTdCngDec == NULL ) + IF ( sce_id == 0 && st->hTdCngDec == NULL ) { - if ( ( st->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + IF ( ( st->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } @@ -379,21 +379,21 @@ ivas_error create_sce_dec( * Synthesis buffers: allocate and initialize *-----------------------------------------------------------------*/ - if ( st_ivas->sba_dirac_stereo_flag ) + IF ( st_ivas->sba_dirac_stereo_flag ) { - if ( ( hSCE->save_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) + IF ( ( hSCE->save_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); } set_zero( hSCE->save_synth, output_frame ); - if ( ( hSCE->save_hb_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) + IF ( ( hSCE->save_hb_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); } set_zero( hSCE->save_hb_synth, output_frame ); } - else + ELSE { hSCE->save_synth = NULL; hSCE->save_hb_synth = NULL; @@ -420,7 +420,7 @@ void destroy_sce_dec( st = hSCE->hCoreCoder[0]; - if ( st != NULL ) + IF ( st != NULL ) { destroy_core_dec( st ); @@ -428,12 +428,12 @@ void destroy_sce_dec( st = NULL; } - if ( hSCE->save_synth != NULL ) + IF ( hSCE->save_synth != NULL ) { free( hSCE->save_synth ); hSCE->save_synth = NULL; } - if ( hSCE->save_hb_synth != NULL ) + IF ( hSCE->save_hb_synth != NULL ) { free( hSCE->save_hb_synth ); hSCE->save_hb_synth = NULL; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index abcfedf8a..51232d259 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -268,7 +268,11 @@ ivas_error ivas_spar_dec_open( granularity = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index b41b4520b..712ca1e87 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -467,19 +467,20 @@ ivas_error initMdctStereoDtxData( CPE_DEC_HANDLE hCPE /* i/o: CPE handle */ ) { - int16_t ch; + Word16 ch; ivas_error error; error = IVAS_ERR_OK; + move16(); - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR ( ch = 0; ch < CPE_CHANNELS; ch++ ) { DEC_CORE_HANDLE st = hCPE->hCoreCoder[ch]; - if ( st->hFdCngDec == NULL ) + IF ( st->hFdCngDec == NULL ) { /* Create FD_CNG instance */ - if ( ( error = createFdCngDec_flt( &st->hFdCngDec ) ) != IVAS_ERR_OK ) + IF ( ( error = createFdCngDec_flt( &st->hFdCngDec ) ) != IVAS_ERR_OK ) { return error; } @@ -488,27 +489,27 @@ ivas_error initMdctStereoDtxData( initFdCngDec_flt( st ); } - if ( st->first_CNG == 0 ) + IF ( EQ_16( st->first_CNG, 0 ) ) { - if ( ch == 1 && st->cng_sba_flag ) + IF ( EQ_16( ch, 1 ) && st->cng_sba_flag ) { - st->hFdCngDec->hFdCngCom->seed += 3; + st->hFdCngDec->hFdCngCom->seed = add( st->hFdCngDec->hFdCngCom->seed, 3 ); } } - if ( st->cldfbAna == NULL ) + IF ( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - if ( ( error = openCldfb_ivas( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb_ivas( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { return error; } } - if ( st->cldfbBPF == NULL ) + IF ( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - if ( ( error = openCldfb_ivas( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb_ivas( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 5a183dc2b..46e2208a6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -42,6 +42,9 @@ #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include "ivas_rom_com.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif #include "wmc_auto.h" @@ -264,7 +267,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( } } +#ifdef IVAS_FLOAT_FIXED + hDiracDecBin->reqularizationFactor = (float) configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ) / ( 1 << 14 ); +#else hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif st_ivas->hDiracDecBin = hDiracDecBin; @@ -286,7 +293,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -306,18 +317,18 @@ void ivas_dirac_dec_close_binaural_data( ) { - if ( hBinaural == NULL || *hBinaural == NULL ) + IF ( hBinaural == NULL || *hBinaural == NULL ) { return; } - if ( ( *hBinaural )->hReverb != NULL ) + IF ( ( *hBinaural )->hReverb != NULL ) { ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); } ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); - if ( ( *hBinaural )->h_freq_domain_decorr_ap_params != NULL ) + IF ( ( *hBinaural )->h_freq_domain_decorr_ap_params != NULL ) { ivas_dirac_dec_decorr_close( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); } @@ -2364,7 +2375,79 @@ float configure_reqularization_factor( return reqularizationFactor; } +#ifdef IVAS_FLOAT_FIXED +Word16 configure_reqularization_factor_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +) +{ + Word16 reqularizationFactor; + reqularizationFactor = 16384; /* Default value */ + move16(); + IF ( EQ_32( ivas_format, MASA_FORMAT ) ) + { + IF ( GE_32( ivas_total_brate, IVAS_160k ) ) + { + reqularizationFactor = 6553; + move16(); + } + ELSE IF ( EQ_32( ivas_total_brate, IVAS_128k ) ) + { + reqularizationFactor = 8192; + move16(); + } + ELSE IF ( EQ_32( ivas_total_brate, IVAS_96k ) ) + { + reqularizationFactor = 9830; + move16(); + } + ELSE IF ( GE_32( ivas_total_brate, IVAS_64k ) ) + { + reqularizationFactor = 13107; + move16(); + } + ELSE + { + reqularizationFactor = 16384; + move16(); + } + } + + IF ( EQ_32( ivas_format, MC_FORMAT ) ) /* This is always McMASA for parametric binauralizer. */ + { + IF ( GE_32( ivas_total_brate, IVAS_96k ) ) + { + reqularizationFactor = 6553; + move16(); + } + ELSE IF ( GE_32( ivas_total_brate, IVAS_80k ) ) + { + reqularizationFactor = 8192; + move16(); + } + ELSE IF ( GE_32( ivas_total_brate, IVAS_64k ) ) + { + reqularizationFactor = 11468; + move16(); + } + ELSE IF ( GE_32( ivas_total_brate, IVAS_48k ) ) + { + reqularizationFactor = 13107; + move16(); + } + ELSE + { + reqularizationFactor = 16384; + move16(); + } + } + + /* For SBA and parametric ISM, currently in default value of 1.0f. */ + + return reqularizationFactor; +} +#endif /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForMovedObjects() * diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 4dbb8437e..dab3bbd78 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -43,6 +43,8 @@ #include "wmc_auto.h" #include "prot_fx1.h" #include "prot_fx2.h" +#include "ivas_prot_fx.h" + /*------------------------------------------------------------------------- * ivas_dirac_allocate_parameters() * @@ -449,16 +451,13 @@ ivas_error ivas_spat_hSpatParamRendCom_config( if ( hodirac_flag && hSpatParamRendCom->azimuth2 == NULL ) { #ifdef IVAS_FLOAT_FIXED - if ((error = ivas_dirac_allocate_parameters_fx(hSpatParamRendCom, 2)) != IVAS_ERR_OK) - { - return error; - } + if ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) +#endif { return error; } -#endif } else if ( !hodirac_flag && hSpatParamRendCom->azimuth2 != NULL ) { @@ -511,29 +510,23 @@ ivas_error ivas_spat_hSpatParamRendCom_config( } } #ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } + IF ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } -#endif if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) ) { #ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) - { - return error; - } + IF ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) +#endif { return error; } -#endif } else { diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 39127bf9f..8aeb77c1e 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -537,7 +537,7 @@ void efap_free_data( EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */ ) { - int16_t i, dim1; + Word16 i, dim1; void **p_dmTranspose; IF( hEFAPdata == NULL || *hEFAPdata == NULL ) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 6c4dfecfa..c04424820 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -56,57 +56,74 @@ Word16 audioCfg2channels( { case IVAS_AUDIO_CONFIG_MONO: nchan_out = 1; + move16(); BREAK; case IVAS_AUDIO_CONFIG_STEREO: nchan_out = 2; + move16(); BREAK; case IVAS_AUDIO_CONFIG_5_1: nchan_out = 6; + move16(); BREAK; case IVAS_AUDIO_CONFIG_7_1: nchan_out = 8; + move16(); BREAK; case IVAS_AUDIO_CONFIG_5_1_2: nchan_out = 8; + move16(); BREAK; case IVAS_AUDIO_CONFIG_5_1_4: nchan_out = 10; + move16(); BREAK; case IVAS_AUDIO_CONFIG_7_1_4: nchan_out = 12; + move16(); BREAK; case IVAS_AUDIO_CONFIG_FOA: nchan_out = 4; + move16(); BREAK; case IVAS_AUDIO_CONFIG_HOA2: nchan_out = 9; + move16(); BREAK; case IVAS_AUDIO_CONFIG_HOA3: nchan_out = 16; + move16(); BREAK; case IVAS_AUDIO_CONFIG_OBA: nchan_out = 8; + move16(); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: nchan_out = 2; + move16(); BREAK; case IVAS_AUDIO_CONFIG_ISM1: nchan_out = 1; + move16(); BREAK; case IVAS_AUDIO_CONFIG_ISM2: nchan_out = 2; + move16(); BREAK; case IVAS_AUDIO_CONFIG_ISM3: nchan_out = 3; + move16(); BREAK; case IVAS_AUDIO_CONFIG_ISM4: nchan_out = 4; + move16(); BREAK; default: IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" ); nchan_out = -1; + move16(); BREAK; } @@ -470,142 +487,151 @@ void ivas_output_init( *-----------------------------------------------------------------*/ /*! r: number of decoder buffers */ -int16_t ivas_get_nchan_buffers_dec( +Word16 ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const Word32 ivas_total_brate /* i : total IVAS bitrate */ ) { - int16_t nchan_out_buff; + Word16 nchan_out_buff; AUDIO_CONFIG output_config; output_config = st_ivas->hDecoderConfig->output_config; + move16(); nchan_out_buff = MAX_OUTPUT_CHANNELS; + move16(); - if ( st_ivas->ivas_format == MONO_FORMAT ) + IF ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + move16(); } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS ); + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS ); } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { nchan_out_buff = st_ivas->nchan_ism; + move16(); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - int16_t nchan_internal; + Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + move16(); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else + ELSE { - nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } - nchan_out_buff = max( nchan_out_buff, nchan_internal ); + nchan_out_buff = s_max( nchan_out_buff, nchan_internal ); } - else if ( st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { nchan_out_buff = CPE_CHANNELS; + move16(); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + test(); test(); test(); + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else if ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - nchan_out_buff = 2 * CPE_CHANNELS; + nchan_out_buff = shl( CPE_CHANNELS, 1 ); } - else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS; + nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - int16_t nchan_internal; + Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); - nchan_out_buff = st_ivas->nchan_ism + st_ivas->nchan_transport; + nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); - if ( st_ivas->hMCT != NULL ) + IF ( st_ivas->hMCT != NULL ) { - nchan_out_buff = ( ( nchan_out_buff + 1 ) >> 1 ) << 1; /* ensure odd number of channels in MCT */ + nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */ } - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF ( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) + test(); + IF ( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ) { - nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ + nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ } - else + ELSE { - nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */ + nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */ } } - else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */ + nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */ } - if ( !( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + test(); + IF ( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { - nchan_out_buff = max( nchan_out_buff, nchan_internal + st_ivas->nchan_ism ); + nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) ); } - nchan_out_buff = min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); + nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - else + ELSE { - nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } } diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index ddd83f441..d3dfaad7b 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -13,8 +13,10 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( AUDIO_CONFIG output_config; output_config = st_ivas->hDecoderConfig->output_config; + move16(); nchan_out_buff = MAX_OUTPUT_CHANNELS; + move16(); IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) ) { @@ -27,6 +29,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { nchan_out_buff = st_ivas->nchan_ism; + move16(); IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -43,6 +46,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + move16(); IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -58,14 +62,17 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) { nchan_out_buff = CPE_CHANNELS; + move16(); + test(); test(); test(); IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - nchan_out_buff = 2 * CPE_CHANNELS; + nchan_out_buff = shl( CPE_CHANNELS, 1 ); + move16(); } ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -107,6 +114,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + move16(); IF( EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) ) { nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ @@ -121,6 +129,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */ } + test(); IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) ); @@ -130,6 +139,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + move16(); IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 69f1abe9d..350cd9eba 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -82,10 +82,10 @@ void ivas_output_init( ); /*! r: number of decoder buffers */ -int16_t ivas_get_nchan_buffers_dec( +Word16 ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const Word32 ivas_total_brate /* i : total IVAS bitrate */ ); #ifdef IVAS_FLOAT_FIXED diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 7ce8a0d5b..0a67670f9 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -507,36 +507,40 @@ static ivas_error set_base_config( Word16 loop_idx; const Word16 *selected_loop_delay = NULL; - if ( pParams == NULL ) + IF ( pParams == NULL ) { return IVAS_ERR_INTERNAL; } pParams->pre_delay = 0; + move16(); pParams->nr_outputs = BINAURAL_CHANNELS; + move16(); pParams->nr_loops = IVAS_REV_MAX_NR_BRANCHES; + move16(); /* set loop delays to default */ - if ( output_Fs == 48000 ) + IF ( EQ_32( output_Fs, 48000 ) ) { selected_loop_delay = default_loop_delay_48k; } - else if ( output_Fs == 32000 ) + ELSE IF ( EQ_32( output_Fs, 32000 ) ) { selected_loop_delay = default_loop_delay_32k; } - else if ( output_Fs == 16000 ) + ELSE IF ( EQ_32( output_Fs, 16000 ) ) { selected_loop_delay = default_loop_delay_16k; } - for ( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) + FOR ( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) { pParams->pLoop_delays[loop_idx] = selected_loop_delay[loop_idx]; + move16(); } /* set feedback and output matrices */ - if ( ( error = compute_feedback_matrix_fx( pParams->pLoop_feedback_matrix_fx, pParams->nr_loops ) ) != IVAS_ERR_OK ) + IF ( NE_32( ( error = compute_feedback_matrix_fx( pParams->pLoop_feedback_matrix_fx, pParams->nr_loops ) ), IVAS_ERR_OK ) ) { return error; } @@ -544,14 +548,17 @@ static ivas_error set_base_config( compute_2_out_extract_matrix_fx( pParams->pLoop_extract_matrix_fx, pParams->nr_loops ); /* pre-set the various filters; they will be set later based on reverb configuration */ pParams->t60_filter_order = 1; /* set to 1 in base config. */ + move16(); - if ( pParams->nr_outputs == 2 ) + IF ( EQ_16( pParams->nr_outputs, 2 ) ) { pParams->do_corr_filter = 1; + move16(); } - else + ELSE { pParams->do_corr_filter = 0; + move16(); } return IVAS_ERR_OK; @@ -565,13 +572,13 @@ static ivas_error set_base_config( static ivas_error set_base_config( ivas_reverb_params_t *pParams, - const int32_t output_Fs ) + const Word32 output_Fs ) { ivas_error error; - int16_t loop_idx; - const int16_t *selected_loop_delay = NULL; + Word16 loop_idx; + const Word16 *selected_loop_delay = NULL; - if ( pParams == NULL ) + IF ( pParams == NULL ) { return IVAS_ERR_INTERNAL; } @@ -581,26 +588,26 @@ static ivas_error set_base_config( pParams->nr_loops = IVAS_REV_MAX_NR_BRANCHES; /* set loop delays to default */ - if ( output_Fs == 48000 ) + IF ( EQ_32( output_Fs, 48000 ) ) { selected_loop_delay = default_loop_delay_48k; } - else if ( output_Fs == 32000 ) + ELSE IF ( EQ_32( output_Fs, 32000 ) ) { selected_loop_delay = default_loop_delay_32k; } - else if ( output_Fs == 16000 ) + ELSE IF ( EQ_32( output_Fs, 16000 ) ) { selected_loop_delay = default_loop_delay_16k; } - for ( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) + FOR ( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) { pParams->pLoop_delays[loop_idx] = selected_loop_delay[loop_idx]; } /* set feedback and output matrices */ - if ( ( error = compute_feedback_matrix( pParams->pLoop_feedback_matrix, pParams->nr_loops ) ) != IVAS_ERR_OK ) + IF ( ( error = compute_feedback_matrix( pParams->pLoop_feedback_matrix, pParams->nr_loops ) ) != IVAS_ERR_OK ) { return error; } @@ -610,11 +617,11 @@ static ivas_error set_base_config( /* pre-set the various filters; they will be set later based on reverb configuration */ pParams->t60_filter_order = 1; /* set to 1 in base config. */ - if ( pParams->nr_outputs == 2 ) + IF ( EQ_16( pParams->nr_outputs, 2 ) ) { pParams->do_corr_filter = 1; } - else + ELSE { pParams->do_corr_filter = 0; } @@ -1919,14 +1926,14 @@ void ivas_reverb_close( hReverb = *hReverb_in; - if ( hReverb_in == NULL || *hReverb_in == NULL ) + IF ( hReverb_in == NULL || *hReverb_in == NULL ) { return; } - for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) + FOR ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { - if ( hReverb->loop_delay_buffer_fx[loop_idx] != NULL ) + IF ( hReverb->loop_delay_buffer_fx[loop_idx] != NULL ) { free( hReverb->loop_delay_buffer_fx[loop_idx] ); hReverb->loop_delay_buffer_fx[loop_idx] = NULL; @@ -1953,18 +1960,18 @@ void ivas_reverb_close( ) { REVERB_HANDLE hReverb; - int16_t loop_idx; + Word16 loop_idx; hReverb = *hReverb_in; - if ( hReverb_in == NULL || *hReverb_in == NULL ) + IF ( hReverb_in == NULL || *hReverb_in == NULL ) { return; } - for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) + FOR ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { - if ( hReverb->loop_delay_buffer[loop_idx] != NULL ) + IF ( hReverb->loop_delay_buffer[loop_idx] != NULL ) { free( hReverb->loop_delay_buffer[loop_idx] ); hReverb->loop_delay_buffer[loop_idx] = NULL; @@ -2970,16 +2977,16 @@ void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ) { - int16_t bin, chIdx; + Word16 bin, chIdx; - if ( hReverb == NULL || *hReverb == NULL ) + IF ( hReverb == NULL || *hReverb == NULL ) { return; } - for ( bin = 0; bin < ( *hReverb )->numBins; bin++ ) + FOR ( bin = 0; bin < ( *hReverb )->numBins; bin++ ) { - for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); free( ( *hReverb )->tapPointersReal[bin][chIdx] ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 498704a2f..b641711e1 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1054,6 +1054,11 @@ typedef struct float abs_coeff[IVAS_ROOM_ABS_COEFF]; float list_orig[3]; + Word16 room_L_fx; + Word16 room_W_fx; + Word16 room_H_fx; + Word16 abs_coeff_fx[IVAS_ROOM_ABS_COEFF]; + Word16 list_orig_fx[3]; } shoebox_config_t; /* Structure to hold the corrected( bounded ) source and listener positions */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 6d14e94e0..7b8520468 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -580,6 +580,55 @@ static ivas_error validateOutputAudioConfig( IVAS_REND_AudioConfigType getAudioConfigType( const AUDIO_CONFIG config ) +#ifdef IVAS_FLOAT_FIXED +{ + IVAS_REND_AudioConfigType type; + + SWITCH ( config ) + { + case IVAS_AUDIO_CONFIG_MONO: + case IVAS_AUDIO_CONFIG_STEREO: + case IVAS_AUDIO_CONFIG_5_1: + case IVAS_AUDIO_CONFIG_7_1: + case IVAS_AUDIO_CONFIG_5_1_2: + case IVAS_AUDIO_CONFIG_5_1_4: + case IVAS_AUDIO_CONFIG_7_1_4: + case IVAS_AUDIO_CONFIG_LS_CUSTOM: + type = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_FOA: + case IVAS_AUDIO_CONFIG_HOA2: + case IVAS_AUDIO_CONFIG_HOA3: + type = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_OBA: + type = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_BINAURAL: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + type = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_MASA1: + case IVAS_AUDIO_CONFIG_MASA2: + type = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; + move16(); + BREAK; + default: + type = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN; + move16(); + BREAK; + } + + return type; +} +#else { IVAS_REND_AudioConfigType type; @@ -621,6 +670,7 @@ IVAS_REND_AudioConfigType getAudioConfigType( return type; } +#endif /*-------------------------------------------------------------------* -- GitLab