From 8f5f4df61eb37aa2784dba6ff69bf806804d1f62 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Sun, 23 Jul 2023 22:34:24 -0400 Subject: [PATCH 01/16] first merge pass with 38 draft --- Workspace_msvc/lib_rend.vcxproj | 4 + lib_com/common_api_types.h | 10 + lib_com/ivas_cnst.h | 32 ++ lib_com/ivas_dirac_com.c | 16 - lib_com/ivas_error.h | 3 + lib_com/ivas_prot.h | 24 - lib_com/ivas_spar_com.c | 4 - lib_com/lsf_tools.c | 8 +- lib_com/options.h | 9 +- lib_com/pvq_com.c | 2 - lib_dec/ivas_dec.c | 16 +- lib_dec/ivas_jbm_dec.c | 20 +- lib_dec/ivas_masa_dec.c | 13 - lib_dec/ivas_qmetadata_dec.c | 58 +- lib_dec/ivas_sba_dec.c | 24 - lib_dec/ivas_sba_dirac_stereo_dec.c | 7 +- lib_dec/ivas_sba_rendering_internal.c | 9 - lib_dec/ivas_spar_decoder.c | 28 +- lib_dec/ivas_spar_md_dec.c | 109 +--- lib_dec/lib_dec.c | 18 + lib_dec/rom_dec.c | 1 - lib_dec/rom_dec.h | 1 - lib_enc/ivas_qmetadata_enc.c | 65 --- lib_enc/lsf_msvq_ma_enc.c | 14 +- lib_rend/ivas_crend.c | 309 ++++++++++ lib_rend/ivas_er_utils.h | 54 ++ lib_rend/ivas_prot_rend.h | 73 ++- lib_rend/ivas_reflections.c | 542 ++++++++++++++++++ lib_rend/ivas_reflections_utils.c | 86 +++ lib_rend/ivas_reverb.c | 8 + lib_rend/ivas_reverb_utils.c | 34 +- lib_rend/ivas_rotation.c | 21 + lib_rend/ivas_sba_rendering.c | 8 - lib_rend/ivas_shoebox.c | 480 ++++++++++++++++ lib_rend/ivas_stat_rend.h | 101 ++++ lib_util/head_rotation_file_reader.c | 37 ++ lib_util/head_rotation_file_reader.h | 38 ++ lib_util/render_config_reader.c | 110 +++- lib_util/render_config_reader.h | 2 +- ...generate_acoustic_environments_metadata.py | 252 +++++++- .../rend_config_ERstrong_LISToff_DIRoff.cfg | 2 + .../rend_config_ERstrong_LISToff_DIRoff.dat | 3 + .../rend_config_ERstrong_LISToff_DIRon.cfg | 2 + .../rend_config_ERstrong_LISToff_DIRon.dat | 3 + .../rend_config_ERstrong_LISTon_DIRoff.cfg | 2 + .../rend_config_ERstrong_LISTon_DIRoff.dat | 3 + .../rend_config_ERstrong_LISTon_DIRon.cfg | 2 + .../rend_config_ERstrong_LISTon_DIRon.dat | 3 + ...plus_early_reflections_listener_origin.cfg | 2 + ...plus_early_reflections_listener_origin.dat | 3 + ...s_early_reflections_no_listener_origin.cfg | 2 + ...s_early_reflections_no_listener_origin.dat | 3 + 52 files changed, 2214 insertions(+), 466 deletions(-) create mode 100644 lib_rend/ivas_er_utils.h create mode 100644 lib_rend/ivas_reflections.c create mode 100644 lib_rend/ivas_reflections_utils.c create mode 100644 lib_rend/ivas_shoebox.c create mode 100644 lib_util/head_rotation_file_reader.c create mode 100644 lib_util/head_rotation_file_reader.h create mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg create mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat create mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg create mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat create mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg create mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat create mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg create mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat create mode 100644 scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.cfg create mode 100644 scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.dat create mode 100644 scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.cfg create mode 100644 scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.dat diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 6e3943249f..959734a82b 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -197,6 +197,9 @@ + + + @@ -250,6 +253,7 @@ + diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 59f6387935..e44eca91a7 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -52,6 +52,9 @@ #define RENDERER_HEAD_POSITIONS_PER_FRAME 4 +#ifdef EARLY_REFLECTIONS +#define QC_ABS_COEFF 6 +#endif /*----------------------------------------------------------------------------------* * Common API structures @@ -175,6 +178,13 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ +#ifdef EARLY_REFLECTIONS + int16_t use_er; /* ER activation flag */ + int16_t lowComplexity; /* Low complexity ER flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float AbsCoeff[QC_ABS_COEFF]; /* Absorption coeffs */ + IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ +#endif } IVAS_ROOM_ACOUSTICS_CONFIG_DATA; #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 0c84499778..e23552fae1 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1842,6 +1842,38 @@ typedef enum #define IVAS_LIMITER_THRESHOLD 32729 /* -0.01 dBFS */ #define IVAS_LIMITER_ATTACK_SECONDS 0.005f + +#ifdef EARLY_REFLECTIONS +/*----------------------------------------------------------------------------------* + * Early Reflection constants + *----------------------------------------------------------------------------------*/ +#define ER_ABS_COEFF 6 +#define ER_MAX_BANDS 1 +#define ER_MAX_SOURCES 25 +#define ER_REF_ORDER 1 +#define ER_NUM_REF 6 + +#define ER_AIR_COEFF (0.00137f) +#define ER_SOUND_SPEED (343.0f) +#define ER_MIN_WALL_DIST (0.1f) + +#define ER_IS_Z_HEIGHT 1 + +#define ER_DEFAULT_ROOM_L (3.0f) +#define ER_DEFAULT_ROOM_W (4.0f) +#define ER_DEFAULT_ROOM_H (5.0f) +#define ER_RADIUS (1.0f) +#define ER_LIST_ORIGIN_X (0.0f) +#define ER_LIST_ORIGIN_Y (0.0f) +#define ER_LIST_HEIGHT (1.6f) + +#define ER_MIN_ROOM_DIMENSION (1.0f) +#define ER_MAX_ROOM_DIMENSION (999.0f) +#define ER_MIN_ABS_COEFF (0.0f) +#define ER_MAX_ABS_COEFF (1.0f) + +#endif + /*----------------------------------------------------------------------------------* * Stereo downmix EVS constants *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 504aea5d6c..20f4b24953 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -111,20 +111,12 @@ ivas_error ivas_dirac_config( if ( ( (Encoder_Struct *) st_ivas )->hSpar != NULL ) { hFbMdft = ( (Encoder_Struct *) st_ivas )->hSpar->hFbMixer; -#ifdef FIX_613_DIRAC_NULL_PTR_USAN - dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; -#endif } else { hFbMdft = NULL; -#ifdef FIX_613_DIRAC_NULL_PTR_USAN - dirac_to_spar_md_bands = NULL; -#endif } -#ifndef FIX_613_DIRAC_NULL_PTR_USAN dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; -#endif } else { @@ -139,21 +131,13 @@ ivas_error ivas_dirac_config( if ( ( (Decoder_Struct *) st_ivas )->hSpar != NULL ) { hFbMdft = ( (Decoder_Struct *) st_ivas )->hSpar->hFbMixer; -#ifdef FIX_613_DIRAC_NULL_PTR_USAN - dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; -#endif } else { hFbMdft = NULL; -#ifdef FIX_613_DIRAC_NULL_PTR_USAN - dirac_to_spar_md_bands = NULL; -#endif } ( (Decoder_Struct *) st_ivas )->hDirAC->hFbMdft = hFbMdft; -#ifndef FIX_613_DIRAC_NULL_PTR_USAN dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; -#endif } if ( ivas_format == SBA_FORMAT ) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index abad0742ca..f2c0931ca8 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -138,6 +138,9 @@ typedef enum #ifdef CONTROL_METADATA_REVERB IVAS_ERR_INVALID_RENDER_CONFIG, IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING, +#ifdef EARLY_REFLECTIONS + IVAS_ERR_INVALID_ER_PARAM, +#endif #endif #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_ERR_LC3PLUS_INVALID_BITRATE, diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9867cda5d9..66b6b68669 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4252,10 +4252,6 @@ void ivas_sba_mix_matrix_determiner( const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ -#ifdef VLBR_20MS_MD - , - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -#endif ); /* AGC */ @@ -4558,23 +4554,7 @@ void ivas_get_spar_md_from_dirac( int16_t ivas_get_spar_dec_md_num_subframes( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#ifdef VLBR_20MS_MD - , - const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ -#endif ); -#ifdef VLBR_20MS_MD - -ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames ); - -void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels ); /* i : number of internal channels */ - -#endif ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ @@ -4582,10 +4562,6 @@ ivas_error ivas_spar_md_dec_open( const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ -#ifdef VLBR_20MS_MD - , - const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ -#endif ); void ivas_spar_md_dec_close( diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index d597d133fd..03721833b9 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1766,11 +1766,7 @@ void ivas_get_spar_md_from_dirac( { for ( band = start_band; band < end_band; band++ ) { -#ifdef FIX_615_UBSAN_SPAR_TO_DIRAC - ndm = hSpar_md_cfg->num_dmx_chans_per_band[band]; -#else ndm = hSpar_md_cfg->num_dmx_chans_per_band[band - 1]; -#endif /*SPAR from DirAC*/ set_f( response_avg, 0.0f, MAX_OUTPUT_CHANNELS ); diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 42688ee145..2f22dafa61 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2072,13 +2072,9 @@ void dec_FDCNG_MSVQ_stage1( for ( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ ) { -#ifdef FIX_612_MSVQ_UBSAN_LEFTSHIFT - dct_vec[col] = (float) shl( (Word16) cbpW8[col], dct_col_shift_tab[col] ); -#else dct_vec[col] = (float) ( ( (Word16) cbpW8[col] ) << dct_col_shift_tab[col] ); -#endif - /* LOGIC( 1 ) , SHIFT( 1 ); - in BASOP: s_and(for W8->W16), shl() + /* LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); + in BASOP: s_and(for W8->W16), shl(), sub() */ } dctT2_N_apply_matrix( (const float *) dct_vec, idct_vec, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype ); diff --git a/lib_com/options.h b/lib_com/options.h index 4d187f6be2..e032b4ce4c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,10 +151,9 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define CONTROL_METADATA_REVERB /* Philips: reverb configuration change to binary format */ #ifdef CONTROL_METADATA_REVERB -#define CONTROL_METADATA_EARLY_REFLECTIONS /* Philips/Qualcomm: early reflections extension to reverb configuration */ +#define EARLY_REFLECTIONS /* Philips/Qualcomm: early reflections extension to reverb configuration */ #define CONTROL_METADATA_DIRECTIVITY /* Ericsson: Directivity renderer configuration */ #endif -#define VLBR_20MS_MD /* Dlb: SBA VLBR 20ms Optimization*/ #define SBA_MODE_CLEANUP_2 /* Dlb : changes part of fix issue #523 for unused signaling bit in SBA SID*/ #define FIX_137_SID_MD_BITS /* Dlb: Fix issue #137 , SID bitrate mismatch correction */ #define FIX_563_PARAMMC_LIMITER /* FhG: issue 563: fix ILD limiter when coming from silence w/o transient set */ @@ -195,11 +194,6 @@ #define JBM_PARAMUPMIX /* Dlb: Issue 471: Integrate the Multichannel Parametric Upmix into the JBM path */ #define FIX_582_INDEX_OUT_OF_BOUNDS_SNS_AVQ_DEC /* FhG: fix an undefined behaviour error in SNS AVQ decoding */ #define FIX_614_ADD_TO_NULL_PTR_DIRAC_SETUP /* FhG: Issue 614: prevent adding to a null pointer in dirac setup code */ -#define UPDATE_REVERB_UTILS /* Use CLDFB HRTFs of the appropriate SBA order in get_IR_from_filter_taps() */ -#define FIX_612_MSVQ_UBSAN_LEFTSHIFT /* Eri: Issue 612 : UBSAN: left shift of negative values in 1st stage of MSVQ */ -#define FIX_621_MSVQ_UBSAN_NULL_PTR_OFFSET /* Eri: Issue 621 : UBSAN: applying non-zero offset 7200 to null pointer in lsf_msvq_ma_enc.c */ -#define FIX_600_CLEANUP_OF_MANUAL_INSTRUMENTATION /* Eri: Issue 600 : removed manual WMCtool instrumentation outside of WMC_TOOL_SKIP defines */ -#define NONBE_FIX_539_MASA_384K_CHIRP /* Nokia: issue 539, puts the normalization of the energy ratios at the correct place, affect MASA 384k only */ /* Fixes for bugs found during split rendering contribution development */ #define REND_STATIC_MEM_OPT /* Dlb: Static memory optimisation for external renderer */ @@ -214,7 +208,6 @@ #define FIX_619_ADD_UNDEF_VAL_FOR_CONCEALMENT_MODE /* FhG: fix usan error */ #define FIX_622_SILENCE_USAN_WARNING /* FhG: silenceusan warning in ifft code */ -#define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_com/pvq_com.c b/lib_com/pvq_com.c index d655dd7d4a..133b7b62f7 100644 --- a/lib_com/pvq_com.c +++ b/lib_com/pvq_com.c @@ -200,9 +200,7 @@ static void dsDiracPerQuanta( if ( t_quanta_o > sv[nsv >> 1] ) { dsIndex = nsv - dsIndex; /*single op*/ -#ifndef FIX_600_CLEANUP_OF_MANUAL_INSTRUMENTATION ADD( 1 ); -#endif } for ( i = frQuanta[0][td] - 1; i >= 0; i-- ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 85334346ad..5fa8d4bec4 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -71,9 +71,6 @@ ivas_error ivas_dec( float pan_left, pan_right; ivas_error error; float *p_output[MAX_OUTPUT_CHANNELS]; -#ifdef VLBR_20MS_MD - int16_t num_md_sub_frames; -#endif error = IVAS_ERR_OK; @@ -391,12 +388,7 @@ ivas_error ivas_dec( } ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -419,13 +411,7 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { -#ifdef VLBR_20MS_MD - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); -#else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); -#endif } else if ( st_ivas->renderer_type != RENDERER_DISABLE ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 98b0672af3..40f077c3c8 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -82,9 +82,6 @@ ivas_error ivas_jbm_dec_tc( AUDIO_CONFIG output_config; ivas_error error; float *p_output[MAX_TRANSPORT_CHANNELS]; -#ifdef VLBR_20MS_MD - int16_t num_md_sub_frames; -#endif error = IVAS_ERR_OK; @@ -262,12 +259,7 @@ ivas_error ivas_jbm_dec_tc( } ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -290,17 +282,7 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { -#ifdef VLBR_20MS_MD - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ); - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); -#else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); -#endif } else { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 78758be569..d44d81d54e 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1177,20 +1177,7 @@ void ivas_spar_param_to_masa_param_mapping( } else { - -#ifdef VLBR_20MS_MD - mixer_mat_index = ( ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ) == 1 ) - ? 0 - : ( sf - SPAR_META_DELAY_SUBFRAMES ); -#else - mixer_mat_index = sf - SPAR_META_DELAY_SUBFRAMES; -#endif for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) { for ( i = 0; i < FOA_CHANNELS; i++ ) diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 3e978a59b9..a2d6d1502c 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -908,60 +908,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } if ( hQMetaData->no_directions == 2 ) { -#ifdef NONBE_FIX_539_MASA_384K_CHIRP - float ratioSum; - if ( bits_sph_idx == 16 ) - { - for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) - { - for ( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) - { - hQMetaData->q_direction[1].band_data[b].energy_ratio[m] = 1.0f - diffuseness_reconstructions_hr[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]]; - - /* Scale energy ratios that sum to over one */ - ratioSum = hQMetaData->q_direction[0].band_data[b].energy_ratio[m] + hQMetaData->q_direction[1].band_data[b].energy_ratio[m]; - - if ( ratioSum > 1.0f ) - { - hQMetaData->q_direction[0].band_data[b].energy_ratio[m] /= ratioSum; - hQMetaData->q_direction[1].band_data[b].energy_ratio[m] /= ratioSum; - } - } - } - } - else - { - int16_t pos_2dir_band[MASA_MAXIMUM_CODING_SUBBANDS]; - d = 0; - for ( b = hQMetaData->q_direction[0].cfg.start_band; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) - { - if ( hQMetaData->twoDirBands[b] == 1 ) - { - pos_2dir_band[d] = b; - d++; - } - else - { - pos_2dir_band[d] = 0; - } - } - for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) - { - for ( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) - { - hQMetaData->q_direction[1].band_data[b].energy_ratio[m] = 1.0f - diffuseness_reconstructions_hr[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]]; - - ratioSum = hQMetaData->q_direction[0].band_data[pos_2dir_band[b]].energy_ratio[m] + hQMetaData->q_direction[1].band_data[b].energy_ratio[m]; - - if ( ratioSum > 1.0f ) - { - hQMetaData->q_direction[0].band_data[pos_2dir_band[b]].energy_ratio[m] /= ratioSum; - hQMetaData->q_direction[1].band_data[b].energy_ratio[m] /= ratioSum; - } - } - } - } -#else #ifdef FIX_566_2DIR_MASA_384K float ratioSum; for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) @@ -992,7 +938,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } -#endif #endif } @@ -1140,7 +1085,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } -#ifndef NONBE_FIX_539_MASA_384K_CHIRP + /* Scale energy ratios that sum to over one */ for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { @@ -1156,7 +1101,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } -#endif } #ifdef DEBUG_MODE_QMETADATA diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fb97faf0de..cacb0621fc 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -110,9 +110,6 @@ ivas_error ivas_sba_dec_reconfigure( int16_t sba_dirac_stereo_flag_old; int32_t ivas_total_brate; int32_t last_ivas_total_brate; -#ifdef VLBR_20MS_MD - int16_t num_channels, num_md_sub_frames; -#endif RENDERER_TYPE old_renderer_type; @@ -184,27 +181,6 @@ ivas_error ivas_sba_dec_reconfigure( } } -#ifdef VLBR_20MS_MD - else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) - { - - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; - - ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); - - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ); - if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, - num_md_sub_frames ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); } else diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index f743f2072b..6c1649d087 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -885,12 +885,7 @@ void ivas_sba_dirac_stereo_dec( ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 643c7b5a6c..6f3dd13b7a 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -578,10 +578,6 @@ void ivas_sba_mix_matrix_determiner( const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ -#ifdef VLBR_20MS_MD - , - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -#endif ) { int16_t i, ch; @@ -625,13 +621,8 @@ void ivas_sba_mix_matrix_determiner( /* Mixing matrix determiner */ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; -#ifdef VLBR_20MS_MD - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, - num_md_sub_frames ); -#else ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif return; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 79ed6c7cf3..cf5e2e11a2 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -114,12 +114,7 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate /* i : IVAS last active bitrate */ -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) { return error; } @@ -730,12 +725,7 @@ static void ivas_spar_dec_MD( bfi = st_ivas->bfi; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; @@ -1210,12 +1200,7 @@ void ivas_spar_dec_set_render_params( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); ivas_spar_dec_set_render_map( st_ivas, n_cldfb_slots ); @@ -1446,12 +1431,9 @@ void ivas_spar_dec_upmixer_sf( num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; -#ifdef VLBR_20MS_MD - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); -#else + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate ); -#endif + slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_idx_start = hSpar->slots_rendered; for ( i = 0; i < nchan_internal; i++ ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index a1d3e98392..a4ee09adc1 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -106,21 +106,15 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder * * Allocate and initialize SPAR MD decoder matrices *------------------------------------------------------------------------*/ -#ifdef VLBR_20MS_MD -ivas_error ivas_spar_md_dec_matrix_open -#else -static ivas_error ivas_spar_md_dec_matrix_open -#endif - ( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames /* i : number of MD subframes */ - ) + +static ivas_error ivas_spar_md_dec_matrix_open( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels, /* i : number of internal channels */ + const int16_t num_md_sub_frames /* i : number of MD subframes */ +) { int16_t i, j; -#ifdef VLBR_20MS_MD - int16_t k; -#endif + if ( ( hMdDec->spar_md.band_coeffs = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * num_md_sub_frames * sizeof( ivas_band_coeffs_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" ); @@ -257,22 +251,7 @@ static ivas_error ivas_spar_md_dec_matrix_open } } } -#ifdef VLBR_20MS_MD - for ( i = 0; i < num_channels; i++ ) - { - for ( j = 0; j < num_channels; j++ ) - { - for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) - { - hMdDec->spar_coeffs_prev.C_re[i][j][k] = 0.0f; - hMdDec->spar_coeffs_prev.P_re[i][j][k] = 0.0f; - hMdDec->spar_coeffs_tar.C_re[i][j][k] = 0.0f; - hMdDec->spar_coeffs_tar.P_re[i][j][k] = 0.0f; - } - } - } -#endif return IVAS_ERR_OK; } @@ -287,10 +266,6 @@ static ivas_error ivas_spar_md_dec_matrix_open int16_t ivas_get_spar_dec_md_num_subframes( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#ifdef VLBR_20MS_MD - , - const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ -#endif ) { int16_t num_subframes; @@ -304,14 +279,6 @@ int16_t ivas_get_spar_dec_md_num_subframes( } } -#ifdef VLBR_20MS_MD - if ( ( ivas_total_brate <= IVAS_SID_5k2 && ivas_last_active_brate < IVAS_24k4 ) || ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate < IVAS_24k4 ) ) - { - - num_subframes = 1; - } -#endif - return ( num_subframes ); } @@ -328,10 +295,6 @@ ivas_error ivas_spar_md_dec_open( const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ -#ifdef VLBR_20MS_MD - , - const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ -#endif ) { ivas_spar_md_dec_state_t *hMdDec; @@ -345,12 +308,7 @@ ivas_error ivas_spar_md_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD decoder" ); } - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - last_active_ivas_total_brate /* i : IVAS last active bitrate */ -#endif - ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate ); if ( ( error = ivas_spar_md_dec_matrix_open( hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { @@ -388,15 +346,11 @@ ivas_error ivas_spar_md_dec_open( * * Deallocate SPAR MD decoder matrices *------------------------------------------------------------------------*/ -#ifdef VLBR_20MS_MD -void ivas_spar_md_dec_matrix_close -#else -static void ivas_spar_md_dec_matrix_close -#endif - ( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ - ) + +static void ivas_spar_md_dec_matrix_close( + ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels /* i : number of internal channels */ +) { int16_t i, j; @@ -539,11 +493,7 @@ ivas_error ivas_spar_md_dec_init( const int16_t sba_order /* i : SBA order */ ) { -#ifdef VLBR_20MS_MD - int16_t i, j; -#else int16_t i, j, k; -#endif int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; @@ -585,7 +535,7 @@ ivas_error ivas_spar_md_dec_init( set_s( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS ); hMdDec->spar_plc_num_lost_frames = 0; hMdDec->spar_plc_enable_fadeout_flag = 1; -#ifndef VLBR_20MS_MD + for ( i = 0; i < num_channels; i++ ) { for ( j = 0; j < num_channels; j++ ) @@ -629,7 +579,7 @@ ivas_error ivas_spar_md_dec_init( } } } -#endif + hMdDec->dtx_md_smoothing_cntr = 1; ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); @@ -751,12 +701,7 @@ void ivas_spar_md_dec_process( num_md_chs = ivas_sba_get_nchan_metadata( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, #ifndef FIX_280_PLANAR_CP @@ -3234,18 +3179,6 @@ void ivas_spar_to_dirac( } } -#ifdef VLBR_20MS_MD - int16_t num_md_sub_frames; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate -#ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate -#endif - ); - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); -#else - num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; if ( st_ivas->hQMetaData->useLowerRes ) { @@ -3254,16 +3187,12 @@ void ivas_spar_to_dirac( ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_subframes, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); -#endif + if ( st_ivas->hQMetaData->useLowerRes && dtx_vad ) { for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ ) { -#ifdef VLBR_20MS_MD - for ( block = 1; block < num_md_sub_frames; block++ ) -#else for ( block = 1; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) -#endif { for ( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */ { @@ -3277,11 +3206,7 @@ void ivas_spar_to_dirac( } } /* expand DirAC TC 20ms MD for residual channels to all subframes*/ -#ifdef VLBR_20MS_MD - for ( block = 0; block < num_md_sub_frames; block++ ) -#else for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) -#endif { for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b66d4ac420..d3f4b9cf19 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1514,6 +1514,11 @@ ivas_error IVAS_DEC_GetRenderConfig( hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; #endif +#ifdef EARLY_REFLECTIONS + hRCout->room_acoustics.use_er = hRCin->roomAcoustics.use_er; + hRCout->room_acoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; +#endif + return IVAS_ERR_OK; } @@ -1555,6 +1560,19 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->roomAcoustics.nBands = renderConfig.room_acoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.room_acoustics.acousticPreDelay; hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.room_acoustics.inputPreDelay; + +#ifdef EARLY_REFLECTIONS + if ( renderConfig.room_acoustics.use_er == 1 ) + { + hRenderConfig->roomAcoustics.use_er = renderConfig.room_acoustics.use_er; + hRenderConfig->roomAcoustics.lowComplexity = renderConfig.room_acoustics.lowComplexity; + hRenderConfig->roomAcoustics.dimensions = renderConfig.room_acoustics.dimensions; + hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.room_acoustics.ListenerOrigin; + + mvr2r( renderConfig.room_acoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, ER_ABS_COEFF ); + } +#endif + mvr2r( renderConfig.room_acoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.room_acoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.room_acoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec.c index 6f0751dc56..ea78271f9e 100644 --- a/lib_dec/rom_dec.c +++ b/lib_dec/rom_dec.c @@ -247,5 +247,4 @@ const float w_hamm_sana16k_2[L_PROT_HAMM_LEN2_16k] = const float h_high3_32[L_FIR_FER2] = {-0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f}; const float h_high3_16[L_FIR_FER2] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; - /* clang-format on */ diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h index 604bfc2fe0..4905ef8f3a 100644 --- a/lib_dec/rom_dec.h +++ b/lib_dec/rom_dec.h @@ -71,5 +71,4 @@ extern const float w_hamm_sana48k_2[L_PROT_HAMM_LEN2_48k]; extern const float h_high3_32[L_FIR_FER2]; extern const float h_high3_16[L_FIR_FER2]; - #endif diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 122bbf2283..de0c9196d4 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -1558,70 +1558,6 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( if ( hQMetaData->no_directions == 2 ) { -#ifdef NONBE_FIX_539_MASA_384K_CHIRP - float ratioSum; - if ( bits_dir_hr == 16 ) - { - for ( j = hQMetaData->q_direction[1].cfg.start_band; j < hQMetaData->q_direction[1].cfg.nbands; j++ ) - { - for ( k = 0; k < hQMetaData->q_direction[1].cfg.nblocks; k++ ) - { - index = masa_sq( 1.0f - hQMetaData->q_direction[1].band_data[j].energy_ratio[k], diffuseness_thresholds_hr, HR_MASA_ER_LEVELS ); - push_next_indice( hMetaData, index, MASA_BITS_ER_HR ); - hQMetaData->q_direction[1].band_data[j].energy_ratio_index[k] = index; - hQMetaData->q_direction[1].band_data[j].energy_ratio[k] = 1.0f - diffuseness_reconstructions_hr[index]; - - ratioSum = hQMetaData->q_direction[0].band_data[j].energy_ratio[k] + hQMetaData->q_direction[1].band_data[j].energy_ratio[k]; - if ( ratioSum > 1.0f ) - { - hQMetaData->q_direction[0].band_data[j].energy_ratio[k] /= ratioSum; - hQMetaData->q_direction[1].band_data[j].energy_ratio[k] /= ratioSum; - } - - needed_bits[1] += MASA_BITS_ER_HR; - hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; - } - } - } - else - { - int16_t pos_2dir_band[MASA_MAXIMUM_CODING_SUBBANDS]; - k = 0; - for ( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; j++ ) - { - if ( hQMetaData->twoDirBands[j] == 1 ) - { - pos_2dir_band[k] = j; - k++; - } - else - { - pos_2dir_band[k] = 0; - } - } - for ( j = hQMetaData->q_direction[1].cfg.start_band; j < hQMetaData->q_direction[1].cfg.nbands; j++ ) - { - for ( k = 0; k < hQMetaData->q_direction[1].cfg.nblocks; k++ ) - { - index = masa_sq( 1.0f - hQMetaData->q_direction[1].band_data[j].energy_ratio[k], diffuseness_thresholds_hr, HR_MASA_ER_LEVELS ); - push_next_indice( hMetaData, index, MASA_BITS_ER_HR ); - hQMetaData->q_direction[1].band_data[j].energy_ratio_index[k] = index; - hQMetaData->q_direction[1].band_data[j].energy_ratio[k] = 1.0f - diffuseness_reconstructions_hr[index]; - - ratioSum = hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio[k] + hQMetaData->q_direction[1].band_data[j].energy_ratio[k]; - - if ( ratioSum > 1.0f ) - { - hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio[k] /= ratioSum; - hQMetaData->q_direction[1].band_data[j].energy_ratio[k] /= ratioSum; - } - - needed_bits[1] += MASA_BITS_ER_HR; - hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; - } - } - } -#else #ifdef FIX_566_2DIR_MASA_384K float ratioSum; #endif @@ -1650,7 +1586,6 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; } } -#endif } return; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index cbc57a3b7b..349fb4f60f 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -148,11 +148,7 @@ int16_t msvq_stage1_dct_search( for ( c2 = 0; c2 < cols_per_segment[segm]; c2++ ) { #define WMC_TOOL_SKIP -#ifdef FIX_612_MSVQ_UBSAN_LEFTSHIFT - tmp = dct_target[c2] - (float) shl( (Word16) cbpW8[c2], dct_col_shift_tab[c2] ); /* note: BASOP shift left defined for signed integers */ -#else tmp = dct_target[c2] - (float) ( ( (Word16) cbpW8[c2] ) << dct_col_shift_tab[c2] ); /* Word8 storage MSE inner loop */ -#endif LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ @@ -559,15 +555,7 @@ void msvq_enc( { /* Subtract codebook entry from residual vector of parent node */ p1 = resid[0] + parents[c] * N; -#ifdef FIX_621_MSVQ_UBSAN_NULL_PTR_OFFSET - p2 = NULL; - if ( cb_stage != NULL ) - { - p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ - } -#else - p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ -#endif + p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ if ( s == 0 && applyDCT_flag != 0 ) { p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ); /*ptr init of stage 1 */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index e333043560..5bc950dfd1 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -898,6 +898,192 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } +#ifdef EARLY_REFLECTIONS +/*------------------------------------------------------------------------- + * ivas_shoebox_data_init() + * + * Initialize shoebox_data_t handle + *------------------------------------------------------------------------*/ + +static ivas_error ivas_shoebox_data_init( + shoebox_data_t *hShoeboxData /* i/o: shoebox_data_t handle */ +) +{ + int16_t i; + + if ( hShoeboxData == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + for ( i = 0; i < 150; i++ ) + { + hShoeboxData->data[i] = 0.0f; + } + for ( i = 0; i < 1; i++ ) + { + hShoeboxData->size[i] = 0; + } + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * ivas_shoebox_output_init() + * + * Initialize shoebox_output_t handle + *------------------------------------------------------------------------*/ + +static ivas_error ivas_shoebox_output_init( + shoebox_output_t *hShoeboxOutput /* i/o: shoebox_output_t handle */ +) +{ + if ( hShoeboxOutput == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + hShoeboxOutput->n_sources = 0; + hShoeboxOutput->n_ref = 0; + + ivas_shoebox_data_init( &hShoeboxOutput->times ); + ivas_shoebox_data_init( &hShoeboxOutput->gains ); + ivas_shoebox_data_init( &hShoeboxOutput->az_angle ); + ivas_shoebox_data_init( &hShoeboxOutput->el_angle ); + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * ivas_shoebox_config_init() + * + * Initialize shoebox_config_t handle + *------------------------------------------------------------------------*/ + +static ivas_error ivas_shoebox_config_init( + shoebox_config_t *hShoeboxConfig /* i/o: shoebox_config_t handle */ +) +{ + int16_t i; + + if ( hShoeboxConfig == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + hShoeboxConfig->room_L = 0.0f; + hShoeboxConfig->room_W = 0.0f; + hShoeboxConfig->room_H = 0.0f; + + for ( i = 0; i < ER_ABS_COEFF; i++ ) + { + hShoeboxConfig->abs_coeff[i] = 0.0f; + } + for ( i = 0; i < 3; i++ ) + { + hShoeboxConfig->list_orig[i] = 0.0f; + } + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * ivas_shoebox_obj_init() + * + * Initialize shoebox_obj_t handle + *------------------------------------------------------------------------*/ + +static ivas_error ivas_shoebox_obj_init( + shoebox_obj_t *hShoeboxObj /* i/o: shoebox_obj_t handle */ +) +{ + int16_t i; + + if ( hShoeboxObj == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + hShoeboxObj->isCartesian = 0; + hShoeboxObj->isRelative = 0; + hShoeboxObj->isZHeight = 0; + hShoeboxObj->isRadians = 0; + hShoeboxObj->MAX_SOURCES = 0.0f; + hShoeboxObj->max_bands = 0.0f; + hShoeboxObj->REF_ORDER = 0.0f; + + for ( i = 0; i < 75; i++ ) + { + hShoeboxObj->src_pos[i] = 0.0f; + } + for ( i = 0; i < 25; i++ ) + { + hShoeboxObj->src_dist[i] = 0.0f; + } + for ( i = 0; i < 3; i++ ) + { + hShoeboxObj->list_pos[i] = 0.0f; + } + + hShoeboxObj->nSrc = 0.0f; + hShoeboxObj->radius = 0.0f; + hShoeboxObj->min_wall_dist = 0.0f; + hShoeboxObj->soundspeed = 0.0f; + hShoeboxObj->air_coeff = 0.0f; + + ivas_shoebox_config_init( &hShoeboxObj->cal ); + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * ivas_er_init() + * + * Initialize early reflections handle + *------------------------------------------------------------------------*/ + +static ivas_error ivas_er_init( + er_struct_t *reflections /* i/o: early reflections handle */ +) +{ + int16_t i; + + if ( reflections == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + reflections->mode = AUDIO_CONFIG_INVALID; + reflections->use_er = 0; + reflections->is_ready = 0; + reflections->circ_len = 0; + reflections->circ_insert = 0; + reflections->n_total_reflections = 0; + reflections->is_cartesian = 0; + reflections->is_relative = 0; + reflections->max_frame_size = 0; + reflections->output_Fs = 0.0f; + + for ( i = 0; i < 75; i++ ) + { + reflections->source_positions[i] = 0.0f; + } + for ( i = 0; i < 3; i++ ) + { + reflections->user_origin[i] = 0.0f; + } + + reflections->circ_buffers = NULL; + reflections->reflection_buffers = NULL; + reflections->closest_ch_idx = NULL; + + ivas_shoebox_output_init( &reflections->shoebox_data ); + ivas_shoebox_obj_init( &reflections->shoebox_lib ); + + return IVAS_ERR_OK; +} +#endif + /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() * @@ -957,6 +1143,9 @@ ivas_error ivas_rend_initCrendWrapper( hCrend->freq_buffer_re_diffuse = NULL; hCrend->freq_buffer_im_diffuse = NULL; hCrend->hReverb = NULL; +#ifdef EARLY_REFLECTIONS + hCrend->reflections = NULL; +#endif hCrend->delay_line_rw_index = 0; hCrend->diffuse_delay_line_rw_index = 0; hCrend->hTrack = NULL; @@ -1139,6 +1328,47 @@ ivas_error ivas_rend_openCrend( { return error; } + +#ifdef EARLY_REFLECTIONS + if ( hRendCfg->roomAcoustics.use_er == 1 ) + { +#ifdef DEBUG_QC_ER + hRendCfg->roomAcoustics.dimensions.x = ER_DEFAULT_ROOM_L; + hRendCfg->roomAcoustics.dimensions.y = ER_DEFAULT_ROOM_W; + hRendCfg->roomAcoustics.dimensions.z = ER_DEFAULT_ROOM_H; + hRendCfg->roomAcoustics.ListenerOrigin.x = ER_LIST_ORIGIN_X; + hRendCfg->roomAcoustics.ListenerOrigin.y = ER_LIST_ORIGIN_Y; + hRendCfg->roomAcoustics.ListenerOrigin.z = ER_LIST_HEIGHT; +#endif + + /* Allocate memory for reflections */ + hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); + if ( !hCrend->reflections ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); + } + ivas_er_init( hCrend->reflections ); + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; + hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; + + /* Set sample rate and frame size */ + hCrend->reflections->output_Fs = (float) output_Fs; + hCrend->reflections->max_frame_size = (int16_t)(output_Fs / FRAMES_PER_SEC); + + /* Init Shoebox */ + shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); + + /* Init and compute Reflections */ + if ( ( error = er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) + { + return error; + }; + } + else + { + hCrend->reflections = NULL; + } +#endif } else { @@ -1246,6 +1476,40 @@ void ivas_rend_closeCrend( ivas_reverb_close( &hCrend->hReverb ); +#ifdef EARLY_REFLECTIONS + if ( hCrend->reflections != NULL ) + { + if ( hCrend->reflections->closest_ch_idx != NULL ) + { + free( hCrend->reflections->closest_ch_idx ); + hCrend->reflections->closest_ch_idx = NULL; + } + + if ( hCrend->reflections->circ_buffers != NULL ) + { + free( hCrend->reflections->circ_buffers ); + hCrend->reflections->circ_buffers = NULL; + } + + if ( hCrend->reflections->reflection_buffers != NULL ) + { + for ( i = 0; i < hCrend->reflections->n_total_reflections; i++ ) + { + if ( hCrend->reflections->reflection_buffers[i] ) + { + free( hCrend->reflections->reflection_buffers[i] ); + hCrend->reflections->reflection_buffers[i] = NULL; + } + } + free( hCrend->reflections->reflection_buffers ); + hCrend->reflections->reflection_buffers = NULL; + } + + free( hCrend->reflections ); + hCrend->reflections = NULL; + } +#endif + free( hCrend ); hCrend = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1513,6 +1777,24 @@ ivas_error ivas_rend_crendProcess( for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { +#ifdef EARLY_REFLECTIONS + /* Early Reflections */ + if ( hCrend->reflections != NULL ) + { + if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) + { + if ( ( error = er_process( hCrend->reflections, + subframe_len, + subframe_idx, + output, + inRendConfig ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + if ( hDecoderConfig && combinedOrientationEnabled ) { /* Orientation tracking */ @@ -1607,6 +1889,15 @@ ivas_error ivas_rend_crendProcessSubframe( IVAS_REND_AudioConfig outRendConfig; int8_t combinedOrientationEnabled; +#ifdef EARLY_REFLECTIONS + CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[0]; +#else + hCrend = pCrend->hCrend; +#endif +#endif + combinedOrientationEnabled = 0; if ( hCombinedOrientationData != NULL ) { @@ -1667,6 +1958,24 @@ ivas_error ivas_rend_crendProcessSubframe( { subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; +#ifdef EARLY_REFLECTIONS + /* Early Reflections */ + if ( hCrend->reflections != NULL ) + { + if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) + { + if ( ( error = er_process( hCrend->reflections, + subframe_len, + subframe_idx, + output, + inRendConfig ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + if ( hDecoderConfig && combinedOrientationEnabled ) { /* Rotation in SHD for: diff --git a/lib_rend/ivas_er_utils.h b/lib_rend/ivas_er_utils.h new file mode 100644 index 0000000000..a278e76adc --- /dev/null +++ b/lib_rend/ivas_er_utils.h @@ -0,0 +1,54 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include +#include "options.h" +#include "ivas_cnst.h" + +#ifdef EARLY_REFLECTIONS + +/*---------------------------------------------------------------------------------* + * Reflections utils prototypes + *-----------------------------------------------------------------------------------*/ + +/* matrix memory handling */ +ivas_error er_init_float_matrix( + float ***mat, + uint16_t rows, + uint16_t cols ); + +ivas_error er_free_float_matrix( + float **mat, + uint16_t rows ); + +#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index e64fdce77a..32bda7212f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -875,6 +875,75 @@ void ivas_reverb_get_hrtf_set_properties( ); +#ifdef EARLY_REFLECTIONS +/*---------------------------------------------------------------------------------* + * Shoebox Prototypes + *-----------------------------------------------------------------------------------*/ + +void shoebox_config_init( + shoebox_config_t *cal, + RENDER_CONFIG_HANDLE pConfig +); + +void shoebox_get_config( + const shoebox_obj_t *obj, + shoebox_config_t *s +); + +void shoebox_init( + shoebox_obj_t *obj, + shoebox_config_t *cal +); + +void shoebox_set_abscoeff( + shoebox_obj_t *obj, + int32_t surface_idx, + float coeff +); + +void shoebox_set_scene ( + shoebox_obj_t *obj, + shoebox_output_t *ER_PARAMS, + const float list_pos[3], + const float src_pos_data[], + uint16_t isCartesian, + uint16_t isRelative +); +#endif + +#ifdef EARLY_REFLECTIONS +/*---------------------------------------------------------------------------------* + * Reflections compute and process Prototypes + *-----------------------------------------------------------------------------------*/ + +ivas_error er_init( + er_struct_t *reflections, + AUDIO_CONFIG inConfig +); + +ivas_error er_set_reflections_mode( + er_struct_t *reflections, + AUDIO_CONFIG mode +); + +ivas_error er_compute_reflections( + er_struct_t *reflections +); + +ivas_error er_encoder_init( + er_struct_t *reflections +); + +ivas_error er_process( + er_struct_t *reflections, + int16_t frame_size, + int16_t subframe_idx, + float **io, + IVAS_REND_AudioConfig inConfig +); + +#endif + /*---------------------------------------------------------------------------------* * Rotation Prototypes *-----------------------------------------------------------------------------------*/ @@ -896,7 +965,9 @@ void Euler2Quat( float deg2rad( float degrees ); - +#ifdef EARLY_REFLECTIONS +float rad2deg( float radians ); +#endif void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c new file mode 100644 index 0000000000..e0428789f1 --- /dev/null +++ b/lib_rend/ivas_reflections.c @@ -0,0 +1,542 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" + +#ifdef EARLY_REFLECTIONS + +#include +#include +#include "prot.h" +#include "rom_dec.h" +#include "lib_rend.h" +#include "ivas_prot_rend.h" +#include "ivas_stat_rend.h" +#include "ivas_cnst.h" +#include "ivas_prot.h" +#include "ivas_er_utils.h" +#include "ivas_rom_com.h" +#include "wmc_auto.h" +#ifdef DEBUGGING +#include "debug.h" +#endif + +uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; +uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4}; +uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1}; +uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; +uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; + +/*-----------------------------------------------------------------------------------------* + * Function er_init + * + * Initializes the reflections data structure according to the requested input config. + *-----------------------------------------------------------------------------------------*/ + + +ivas_error er_init( + er_struct_t *reflections, + AUDIO_CONFIG mode ) +{ + ivas_error error; + IVAS_REND_AudioConfig outRendConfig; + + /* Set to defaults for shoebox */ + reflections->is_ready = 0; + reflections->mode = AUDIO_CONFIG_INVALID; + reflections->is_cartesian = 0; + reflections->is_relative = 1; + reflections->shoebox_data.n_ref = ER_NUM_REF; + reflections->user_origin[0] = 0.0f; + reflections->user_origin[1] = 0.0f; + reflections->user_origin[2] = ER_LIST_HEIGHT; + + /* Init Shoebox */ + shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); + + /* Set mode */ + if ( ( error = er_set_reflections_mode( reflections, mode ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Compute the static reflections (first frame) */ + if ( ( error = er_compute_reflections( reflections ) ) != IVAS_ERR_OK ) + { + return error; + } + + reflections->closest_ch_idx = (uint16_t *) malloc( reflections->n_total_reflections * sizeof( uint16_t ) ); + if ( !reflections->closest_ch_idx ) + { + return IVAS_ERR_FAILED_ALLOC; + } + set_s( (int16_t *) reflections->closest_ch_idx, 0, reflections->n_total_reflections ); + + outRendConfig = getRendAudioConfigFromIvasAudioConfig(reflections->mode); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &( reflections->nchan_out ) ) ) != IVAS_ERR_OK) + { + return error; + } + + /* Initialize Encoder */ + if ( ( error = er_encoder_init( reflections ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Update flag to indicate that reflection module is ready to process */ + reflections->is_ready = 1; + + return error; +} +/*-----------------------------------------------------------------------------------------* + Function er_set_reflections_mode + + Function sets the ER source positions based on the audio config + *-----------------------------------------------------------------------------------------*/ + +ivas_error er_set_reflections_mode( + er_struct_t *reflections, + AUDIO_CONFIG mode ) +{ + ivas_error error; + uint16_t ch; + error = IVAS_ERR_OK; + + if ( reflections->mode == mode ) + { + return error; + } + + reflections->is_ready = 0; + reflections->mode = mode; + + switch ( reflections->mode ) + { + case AUDIO_CONFIG_MONO: + reflections->shoebox_data.n_sources = 1; + reflections->n_LC_sources = 1; + reflections->LC_mixing = LC_mixing_5_1; + reflections->source_positions[0] = 0; + reflections->source_positions[1] = 0; + reflections->source_positions[2] = ER_RADIUS; + break; + case AUDIO_CONFIG_STEREO: + reflections->shoebox_data.n_sources = 2; + reflections->n_LC_sources = 2; + reflections->LC_mixing = LC_mixing_5_1; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP2[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP2[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + case AUDIO_CONFIG_5_1: + reflections->shoebox_data.n_sources = 5; + reflections->n_LC_sources = 3; + reflections->LC_mixing = LC_mixing_5_1; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP6[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP6[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + case AUDIO_CONFIG_7_1: + reflections->shoebox_data.n_sources = 7; + reflections->n_LC_sources = 5; + reflections->LC_mixing = LC_mixing_7_1; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP12[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP12[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + case AUDIO_CONFIG_5_1_2: + reflections->shoebox_data.n_sources = 7; + reflections->n_LC_sources = 5; + reflections->LC_mixing = LC_mixing_5_1_2; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP14[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP14[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + case AUDIO_CONFIG_5_1_4: + reflections->shoebox_data.n_sources = 9; + reflections->n_LC_sources = 5; + reflections->LC_mixing = LC_mixing_5_1_4; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP16[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP16[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + case AUDIO_CONFIG_7_1_4: + reflections->shoebox_data.n_sources = 11; + reflections->n_LC_sources = 5; + reflections->LC_mixing = LC_mixing_7_1_4; + for ( ch = 0; ch < reflections->shoebox_data.n_sources; ch++ ) + { + reflections->source_positions[3 * ch] = deg2rad( ls_azimuth_CICP19[ch] ); + reflections->source_positions[1 + ( 3 * ch )] = deg2rad( ls_elevation_CICP19[ch] ); + reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; + } + break; + default: + reflections->mode = AUDIO_CONFIG_INVALID; + return IVAS_ERROR( IVAS_ERR_INVALID_ER_PARAM, "Unsupported reflections mode" ); + } + + return error; +} + + +/*-----------------------------------------------------------------------------------------* + Function er_encoder_init + + Function that initializes the er encoder + *-----------------------------------------------------------------------------------------*/ + +ivas_error er_encoder_init( + er_struct_t *reflections ) +{ + ivas_error error = IVAS_ERR_OK; + uint16_t i, j, src_idx; + float p_x, p_y, p_z; + float p_x_src, p_y_src, p_z_src; + float tmp; + float dist, min_dist = 0, min_index = 0; + + if ( !reflections ) + { + error = IVAS_ERR_FAILED_ALLOC; + return error; + } + + if ( getAudioConfigType( reflections->mode ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + { + /* Compute MC-snap location (closest channel position to reflection direction) */ + for ( i = 0; i < reflections->n_total_reflections; i++ ) + { + /* Compute cartesian points for reflection (from degrees) */ + p_x = ER_RADIUS * ( (float) cos( deg2rad( reflections->shoebox_data.el_angle.data[i] ) ) * (float) cos( deg2rad( reflections->shoebox_data.az_angle.data[i] ) ) ); + p_y = ER_RADIUS * ( (float) cos( deg2rad( reflections->shoebox_data.el_angle.data[i] ) ) * (float) sin( deg2rad( reflections->shoebox_data.az_angle.data[i] ) ) ); + p_z = ER_RADIUS * ( (float) sin( deg2rad( reflections->shoebox_data.el_angle.data[i] ) ) ); + + /* Calculate the euclidean distance to each point in the config ls setup */ + for ( j = 0; j < reflections->nchan_out; j++ ) + { + /* Ignore LFE */ + if ( j != LFE_CHANNEL ) + { + src_idx = ( j > LFE_CHANNEL ) ? j - 1 : j; + + p_x_src = reflections->source_positions[src_idx * 3 + 2] * ( (float) cos( reflections->source_positions[src_idx * 3 + 1] ) * (float) cos( reflections->source_positions[src_idx * 3] ) ); + p_y_src = reflections->source_positions[src_idx * 3 + 2] * ( (float) cos( reflections->source_positions[src_idx * 3 + 1] ) * (float) sin( reflections->source_positions[src_idx * 3] ) ); + p_z_src = reflections->source_positions[src_idx * 3 + 2] * (float) sin( reflections->source_positions[src_idx * 3 + 1] ); + + tmp = ( p_x_src - p_x ) * ( p_x_src - p_x ); + tmp += ( p_y_src - p_y ) * ( p_y_src - p_y ); + tmp += ( p_z_src - p_z ) * ( p_z_src - p_z ); + dist = (float) sqrt( tmp ); + + /* Save index of closest channel */ + if ( src_idx == 0 ) + { + min_dist = dist; + min_index = j; + } + else + { + if ( dist < min_dist ) + { + min_dist = dist; + min_index = j; + } + } + } + } + + reflections->closest_ch_idx[i] = (uint16_t) min_index; + } + } + + + return error; +} + + +/*-----------------------------------------------------------------------------------------* + Function er_compute_reflections + + Function computes reflections using the shoebox library and sets up the circular buffers + structure for the early reflections process + *-----------------------------------------------------------------------------------------*/ + +ivas_error er_compute_reflections( + er_struct_t *reflections ) +{ + ivas_error error = IVAS_ERR_OK; + uint16_t circ_len, i, j; + float tmp; + + reflections->is_ready = 0; + + /* Disabled case */ + if ( reflections->mode == AUDIO_CONFIG_INVALID ) + { + return error; + } + + /* Run shoebox with current reflection parameters */ + shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), + reflections->user_origin, reflections->source_positions, + reflections->is_cartesian, reflections->is_relative ); + + /* Convert reflection times in seconds to samples and keep track of max */ + circ_len = 0; + for ( i = 0; i < reflections->shoebox_data.n_sources; i++ ) + { + for ( j = 0; j < reflections->shoebox_data.n_ref; j++ ) + { + tmp = reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )]; + tmp = (float) round( tmp * reflections->output_Fs ); + reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )] = tmp; + circ_len = ( (uint16_t) tmp > circ_len ) ? (uint16_t) tmp : circ_len; + } + } + + /* If max delay is less than max frame size, use max frame size to compute circ buffer length */ + circ_len = ( circ_len > (uint16_t) reflections->max_frame_size ) ? circ_len : (uint16_t) reflections->max_frame_size; + circ_len += (uint16_t) reflections->max_frame_size; + + /* If circ buffers exist and size is the same, reset memory to all zeros */ + /* If size is different, reallocate circ buffers */ + /* Otherwise allocate new circ buffers */ + if ( reflections->circ_buffers ) + { + if ( reflections->circ_len == circ_len ) + { + /* circ buffers exist and size is the same */ + set_f( reflections->circ_buffers, 0.0f, + reflections->shoebox_data.n_sources * reflections->circ_len ); + } + else + { + /* circ buffers exist but size is different */ + reflections->circ_len = circ_len; + free( reflections->circ_buffers ); + reflections->circ_buffers = (float *) malloc( + reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); + set_f( reflections->circ_buffers, 0.0f, + reflections->shoebox_data.n_sources * reflections->circ_len ); + } + } + else + { + /* circ buffers do not exist */ + reflections->circ_len = circ_len; + reflections->circ_buffers = (float *) malloc( + reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); + set_f( reflections->circ_buffers, 0.0f, + reflections->shoebox_data.n_sources * reflections->circ_len ); + } + + /* Check that circ buffers were allocated */ + if ( !reflections->circ_buffers ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections buffers" ); + } + + /* Initialize circular buffer insertion point */ + reflections->circ_insert = reflections->circ_len - (uint16_t) reflections->max_frame_size; + + /* Free stale reflection if previously allocated */ + if ( reflections->reflection_buffers ) + { + er_free_float_matrix( reflections->reflection_buffers, + reflections->n_total_reflections ); + } + /* Allocate reflection buffers */ + reflections->n_total_reflections = reflections->shoebox_data.n_sources * reflections->shoebox_data.n_ref; + error = er_init_float_matrix( &( reflections->reflection_buffers ), + reflections->n_total_reflections, + (uint16_t) reflections->max_frame_size ); + + /* Check that reflection buffers were allocated */ + if ( error != IVAS_ERR_OK ) + { + return error; + } + + return error; +} + +/*-----------------------------------------------------------------------------------------* +Function er_process + +Takes a buffer of N channels, returns a buffer of N*6 channels containing the early +reflections (one per wall). The process is a delay line architecture +*-----------------------------------------------------------------------------------------*/ + + +ivas_error er_process( + er_struct_t *reflections, + int16_t subframe_size, + int16_t subframe_idx, + float **io, + IVAS_REND_AudioConfig inConfig ) +{ + ivas_error error = IVAS_ERR_OK; + uint16_t i, j, k, subframe_offset; + uint16_t ref_no, ref_delay; + uint16_t n_ref_sources, n_ref; + int16_t samp_idx, in_ch_idx, buf_ch_idx, ref_out_idx; + float ref_gain; + float *buffer_ch; + + if ( !reflections ) + { + return IVAS_ERR_INIT_ERROR; + } + + /* should not arrive here if reflections are disabled but in case it does just do nothing */ + if ( reflections->use_er != 1 ) + { + return error; + } + + /* Ensure all reflection memory is allocated */ + if ( !reflections->circ_buffers || + !reflections->reflection_buffers || + !reflections->is_ready ) + { + return IVAS_ERR_INIT_ERROR; + } + + subframe_offset = subframe_idx * subframe_size; + n_ref = reflections->shoebox_data.n_ref; + + /* If low complexity ER are requested only compute ER for n_LC_sources */ + if (reflections->lowComplexity) + { + n_ref_sources = reflections->n_LC_sources; + } + else + { + n_ref_sources = reflections->shoebox_data.n_sources; + } + + /* Channel case, copy input into buffers panning for LC mode and skipping LFE */ + if ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + { + /* Loop through all input sources filling circular buffers */ + for ( i = 0; i < reflections->shoebox_data.n_sources; i++ ) + { + /* Pull correct circular buffer depending on complexity mode */ + buf_ch_idx = ( reflections->lowComplexity == 1 ) ? reflections->LC_mixing[i] : i; + buffer_ch = &( reflections->circ_buffers[buf_ch_idx * reflections->circ_len] ); + + /* Skip LFE from input buffer */ + in_ch_idx = ( i >= LFE_CHANNEL ) ? i + 1 : i; + samp_idx = reflections->circ_insert; + + /* If less than number of reflection sources, overwrite buffer */ + if ( i == buf_ch_idx ) + { + for ( j = 0; j < subframe_size; j++ ) + { + buffer_ch[samp_idx++] = io[in_ch_idx][j + subframe_offset]; + samp_idx = samp_idx % reflections->circ_len; + } + } + /* Accumulate with buffer for low complexity mixed sources */ + else + { + for ( j = 0; j < subframe_size; j++ ) + { + buffer_ch[samp_idx++] += io[in_ch_idx][j + subframe_offset]; + samp_idx = samp_idx % reflections->circ_len; + } + } + } + } + else + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } + + /* Loop through sources retrieve reflections from circ buffers */ + for ( i = 0; i < n_ref_sources; i++ ) + { + /* Access correct row of input circ buffer */ + buffer_ch = &( reflections->circ_buffers[i * reflections->circ_len] ); + + /* Loop through reflections */ + for ( j = 0; j < n_ref; j++ ) + { + ref_no = j + ( i * n_ref ); + ref_gain = reflections->shoebox_data.gains.data[ref_no]; + ref_delay = (uint16_t) reflections->shoebox_data.times.data[ref_no]; + ref_out_idx = reflections->closest_ch_idx[ref_no]; + + /* Determine start idx of reflection in circ buffer based on + current insert idx and reflection delay */ + samp_idx = (int) reflections->circ_insert - ref_delay; + if (samp_idx < 0 ) + { + samp_idx = (int) reflections->circ_len + samp_idx; + } + + /* Pull reflection from circ buffer and apply gain, storing in reflection buffer */ + for ( k = 0; k < subframe_size; k++ ) + { + io[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; + samp_idx = samp_idx % reflections->circ_len; + } + } + } + + /* Increment circular buffer start index */ + reflections->circ_insert = ( reflections->circ_insert + subframe_size ) % reflections->circ_len; + + return error; +} + + +#endif diff --git a/lib_rend/ivas_reflections_utils.c b/lib_rend/ivas_reflections_utils.c new file mode 100644 index 0000000000..331e2c312a --- /dev/null +++ b/lib_rend/ivas_reflections_utils.c @@ -0,0 +1,86 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" + +#ifdef EARLY_REFLECTIONS + +#include +#include +#include +#include "prot.h" +#include "ivas_prot_rend.h" +#include "ivas_stat_rend.h" +#include "ivas_error.h" +#include "ivas_er_utils.h" +#include "wmc_auto.h" + +/* Initialize memory for a 2D matrix of floats */ +ivas_error er_init_float_matrix( float ***mat, uint16_t rows, uint16_t cols ) +{ + *mat = malloc( rows * sizeof( **mat ) ); + if ( !( *mat ) ) + { + return IVAS_ERR_FAILED_ALLOC; + } + for ( uint16_t i = 0; i < rows; i++ ) + { + ( *mat )[i] = malloc( cols * sizeof( ***mat ) ); + + if ( !( ( *mat )[i] ) ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + set_f( ( *mat )[i], 0.0f, cols ); + } + return IVAS_ERR_OK; +} + +/* Delete memory stored in a 2D matrix of floats */ +ivas_error er_free_float_matrix( float **mat, uint16_t rows ) +{ + if ( mat ) + { + for ( uint16_t i = 0; i < rows; i++ ) + { + if ( mat[i] ) + { + free( mat[i] ); + } + } + free( mat ); + } + return IVAS_ERR_OK; +} + +#endif diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index fd485ffbce..b110cd372d 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1182,6 +1182,14 @@ ivas_error ivas_reverb_open( pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; +#ifdef EARLY_REFLECTIONS + if ( hRenderConfig->roomAcoustics.use_er == 1 ) + { + pState->pConfig.roomAcoustics.use_er = hRenderConfig->roomAcoustics.use_er; + pState->pConfig.roomAcoustics.lowComplexity = hRenderConfig->roomAcoustics.lowComplexity; + } +#endif + /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index b821521b68..6ff101bec5 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -52,9 +52,7 @@ #define FFT_SPECTRUM_SIZE ( 1 + ( RV_FILTER_MAX_FFT_SIZE / 2 ) ) #define N_INITIAL_IGNORED_FRAMES 4 -#ifndef UPDATE_REVERB_UTILS -#define NUM_CLDFB_TAPES 7 -#endif +#define NUM_CLDFB_TAPES 7 /*-----------------------------------------------------------------------------------------* * Local function prototypes @@ -227,11 +225,7 @@ static void get_IR_from_filter_taps( output_sample_idx = 0; /* Assign CLDFB taps */ -#ifdef UPDATE_REVERB_UTILS - if ( input_audio_config == AUDIO_CONFIG_HOA3 ) -#else if ( input_audio_config == AUDIO_CONFIG_FOA || input_audio_config == AUDIO_CONFIG_HOA2 || input_audio_config == AUDIO_CONFIG_HOA3 ) -#endif { for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) { @@ -241,28 +235,6 @@ static void get_IR_from_filter_taps( convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_HOA3[band_idx][hrtf_idx]; } } -#ifdef UPDATE_REVERB_UTILS - else if ( input_audio_config == AUDIO_CONFIG_HOA2 ) - { - for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) - { - convolver_state.filter_taps_left_re[band_idx] = hHrtfFastConv->leftHRIRReal_HOA2[band_idx][hrtf_idx]; - convolver_state.filter_taps_left_im[band_idx] = hHrtfFastConv->leftHRIRImag_HOA2[band_idx][hrtf_idx]; - convolver_state.filter_taps_right_re[band_idx] = hHrtfFastConv->rightHRIRReal_HOA2[band_idx][hrtf_idx]; - convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_HOA2[band_idx][hrtf_idx]; - } - } - else if ( input_audio_config == AUDIO_CONFIG_FOA ) - { - for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) - { - convolver_state.filter_taps_left_re[band_idx] = hHrtfFastConv->leftHRIRReal_FOA[band_idx][hrtf_idx]; - convolver_state.filter_taps_left_im[band_idx] = hHrtfFastConv->leftHRIRImag_FOA[band_idx][hrtf_idx]; - convolver_state.filter_taps_right_re[band_idx] = hHrtfFastConv->rightHRIRReal_FOA[band_idx][hrtf_idx]; - convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_FOA[band_idx][hrtf_idx]; - } - } -#endif else { array_idx = 0; @@ -341,11 +313,7 @@ static void get_IR_from_filter_taps( } } -#ifdef UPDATE_REVERB_UTILS - ivas_cldfb_convolver( &convolver_state, out_CLDFB_real, out_CLDFB_imag, real_buffer_in, imag_buffer_in, BINAURAL_CONVBANDS, BINAURAL_NTAPS ); -#else ivas_cldfb_convolver( &convolver_state, out_CLDFB_real, out_CLDFB_imag, real_buffer_in, imag_buffer_in, BINAURAL_CONVBANDS, NUM_CLDFB_TAPES ); -#endif ppRealBuf[0] = out_CLDFB_real[0]; ppImagBuf[0] = out_CLDFB_imag[0]; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index a3bf1f1d92..869d907514 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -278,6 +278,27 @@ float deg2rad( return PI_OVER_180 * degrees; } +#ifdef EARLY_REFLECTIONS +/*------------------------------------------------------------------------- + * rad2deg() + * + * Converts normalized radians to degrees + *------------------------------------------------------------------------*/ +float rad2deg( + float radians ) +{ + while ( radians >= EVS_PI ) + { + radians = radians - EVS_PI; + } + while ( radians <= -EVS_PI ) + { + radians = radians + EVS_PI; + } + return _180_OVER_PI * radians; +} +#endif + /*------------------------------------------------------------------------- * rotateAziEle() * diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index f4f627daab..0974677922 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -67,11 +67,6 @@ void ivas_sba_prototype_renderer( int16_t out_ch, in_ch; int16_t firstInCh, inChEnd, firstOutCh, outChEnd; int16_t slot_idx_start, md_idx; -#ifdef VLBR_20MS_MD - int16_t num_md_sub_frames; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); -#endif push_wmops( "ivas_sba_prototype_renderer" ); @@ -153,9 +148,6 @@ void ivas_sba_prototype_renderer( { /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ int16_t md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME; -#ifdef VLBR_20MS_MD - md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? md_sf : 0; -#endif hSpar->i_subframe++; hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c new file mode 100644 index 0000000000..b0adf65a96 --- /dev/null +++ b/lib_rend/ivas_shoebox.c @@ -0,0 +1,480 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" + +#ifdef EARLY_REFLECTIONS + +#include +#include +#include "ivas_prot_rend.h" +#include "ivas_stat_rend.h" +#include "ivas_cnst.h" +#include "prot.h" +#include "ivas_er_utils.h" +#include "wmc_auto.h" + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_config_init + * + * Function transfer the parameters from the reverb config handle to the shoebox + * calibration data structure. + *-----------------------------------------------------------------------------------------*/ + +void shoebox_config_init( + shoebox_config_t *cal, + RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ +) +{ + int32_t wall_idx; + + cal->room_L = hRenderConfig->roomAcoustics.dimensions.x; + cal->room_W = hRenderConfig->roomAcoustics.dimensions.y; + cal->room_H = hRenderConfig->roomAcoustics.dimensions.z; + + /* Absorption Coefficients */ + /* Convention: [Front wall, Back wall, Left wall, Right wall, Ceiling, Floor] */ + for ( wall_idx = 0; wall_idx < 6; wall_idx++ ) + { + cal->abs_coeff[wall_idx] = hRenderConfig->roomAcoustics.AbsCoeff[wall_idx]; + } + + /* Listener position (only X and Y can be pos. or neg. ) */ + cal->list_orig[0] = hRenderConfig->roomAcoustics.ListenerOrigin.x; + cal->list_orig[1] = hRenderConfig->roomAcoustics.ListenerOrigin.y; + cal->list_orig[2] = hRenderConfig->roomAcoustics.ListenerOrigin.z; +} + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_init + * + * Function initializes the shoebox operating parameters by setting limits and defaults, + * also contains the calibration structure. + *-----------------------------------------------------------------------------------------*/ + +void shoebox_init( + shoebox_obj_t *obj, + shoebox_config_t *cal ) +{ + uint16_t i; + + /* Add cal to obj struct */ + obj->cal = *cal; + /* Add defaults */ + obj->max_bands = ER_MAX_BANDS; + obj->MAX_SOURCES = ER_MAX_SOURCES; + obj->REF_ORDER = ER_REF_ORDER; + + /* Positions */ + set_f( &obj->src_pos[0], 0.0f, 75U ); + set_f( &obj->src_dist[0], 0.0f, 25U ); + + for ( i = 0; i < 3; i++ ) + { + obj->list_pos[i] = cal->list_orig[i]; + } + + /* Pointer */ + obj->nSrc = 0.0f; // --> To update for ISM in future versions + + /* Flags */ + obj->isCartesian = 1; + obj->isRelative = 1; + obj->isZHeight = ER_IS_Z_HEIGHT; + obj->isRadians = 1; + + /* Params */ + obj->radius = ER_RADIUS; + obj->min_wall_dist = ER_MIN_WALL_DIST; + obj->soundspeed = ER_SOUND_SPEED; + obj->air_coeff = ER_AIR_COEFF; +} + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_set_abscoeff + * + * Utility function to reassign the absorption coefficient of a target surface manually. + * The order convention for the surface index is [ front wall, back wall, left wall, + * right wall, ceiling, floor ]. + *-----------------------------------------------------------------------------------------*/ + +void shoebox_set_abscoeff( + shoebox_obj_t *obj, + int32_t surface_idx, + float coeff ) +{ + if ( ( coeff >= 0.0f ) && ( coeff <= 1.0f ) && ( surface_idx >= 0 ) && ( surface_idx <= 5 ) ) + { + obj->cal.abs_coeff[surface_idx] = coeff; + } +} + + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_bound + * + * SHOEBOX_BOUND takes in CARTESIAN coordinates of either a receiver or + * source and checks if it is within the virtual room boundaries established + * by the surface parameters. If object is out of bounds, then new cartesian + * coordinates are established to collapse the object position. + *-----------------------------------------------------------------------------------------*/ + + +static void shoebox_bound( + shoebox_obj_t *obj, + float *out_pos ) +{ + float out_tmp; + int32_t i; + + out_tmp = ( obj->cal.room_L / 2.0f ) - obj->min_wall_dist; + if ( ( out_pos[0] > out_tmp ) || ( out_pos[0] < ( ( ( -obj->cal.room_L ) / 2.0f ) + obj->min_wall_dist ) ) ) + { + if ( out_pos[0] < 0.0f ) + { + i = -1; + } + else + { + i = ( out_pos[0] > 0.0f ) ? ( (int32_t) 1 ) : ( (int32_t) 0 ); + } + out_pos[0] = out_tmp * ( (float) i ); + } + out_tmp = ( obj->cal.room_W / 2.0f ) - obj->min_wall_dist; + if ( ( out_pos[1] > out_tmp ) || ( out_pos[1] < ( ( ( -obj->cal.room_W ) / 2.0f ) + obj->min_wall_dist ) ) ) + { + if ( out_pos[1] < 0.0f ) + { + i = -1; + } + else + { + i = ( out_pos[1] > 0.0f ) ? ( (int32_t) 1 ) : ( (int32_t) 0 ); + } + out_pos[1] = out_tmp * ( (float) i ); + } + out_tmp = ( obj->cal.room_H / 2.0f ) - obj->min_wall_dist; + if ( ( out_pos[2] > out_tmp ) || ( out_pos[2] < ( ( ( -obj->cal.room_H ) / 2.0f ) + obj->min_wall_dist ) ) ) + { + if ( out_pos[2] < 0.0f ) + { + i = -1; + } + else + { + i = ( out_pos[2] > 0.0f ) ? ( (int32_t) 1 ) : ( (int32_t) 0 ); + } + out_pos[2] = out_tmp * ( (float) i ); + } +} + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_get_coord + * + * Transform relative spherical coordinate to 3D cartesian point + *-----------------------------------------------------------------------------------------*/ + +static void shoebox_get_coord( + shoebox_obj_t *obj, + float *fcnOutput_data, + const float src_pos_data[], + float *tmp_pos, + float out_tmp, + int32_t coord, + int32_t loop_ub, + int32_t k, + uint16_t isRelative ) +{ + float tmp_data[75]; + float rcoselev; + int32_t tmp_size_idx_1; + int32_t n; + + tmp_size_idx_1 = 3; + if ( obj->isCartesian == 0.0f ) + { + /* CONVERT SPHERICAL */ + if ( obj->isRadians == 0.0f ) + { + for ( n = 0; n < loop_ub; n++ ) + { + fcnOutput_data[n] = 0.0174532924F * src_pos_data[k + n]; + } + } + tmp_data[2] = fcnOutput_data[2] * sinf( fcnOutput_data[1] ); + rcoselev = fcnOutput_data[2] * cosf( fcnOutput_data[1] ); + tmp_data[0] = rcoselev * cosf( fcnOutput_data[0] ); + tmp_data[1] = rcoselev * sinf( fcnOutput_data[0] ); + } + else + { + /* CARTESIAN CASE */ + tmp_size_idx_1 = loop_ub; + for ( n = 0; n < loop_ub; n++ ) + { + tmp_data[n] = src_pos_data[k + n]; + } + if ( obj->isZHeight != 0.0f ) + { + /* FIX Z COORDINATE */ + tmp_data[2] = src_pos_data[k + 2] - ( obj->cal.room_H / 2.0f ); + } + } + for ( k = 0; k < tmp_size_idx_1; k++ ) + { + obj->src_pos[( coord + k ) - 1] = tmp_data[k]; + } + /* CENTER TO LISTENER */ + if ( ( out_tmp + 1.0f ) > ( ( out_tmp + 1.0f ) + 2.0f ) ) + { + k = 1; + } + else + { + k = (int32_t) ( (float) ( out_tmp + 1.0f ) ); + } + tmp_pos[0] = obj->src_pos[k - 1]; + tmp_pos[1] = obj->src_pos[k]; + tmp_pos[2] = obj->src_pos[k + 1]; + if ( isRelative != 0.0f ) + { + tmp_pos[0] += obj->list_pos[0]; + tmp_pos[1] += obj->list_pos[1]; + tmp_pos[2] += obj->list_pos[2]; + } +} + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_get_euclidian_distance_internal + * + * Get 3D source distance from receiver + *-----------------------------------------------------------------------------------------*/ + +static float shoebox_get_euclidian_distance_internal( + shoebox_obj_t *obj, + float *tmp_pos, + float *scale ) +{ + float absxk, out_tmp, t; + + absxk = fabsf( obj->list_pos[0] - tmp_pos[0] ); + if ( absxk > 1.29246971E-26F ) + { + out_tmp = 1.0f; + *scale = absxk; + } + else + { + t = absxk / 1.29246971E-26F; + out_tmp = t * t; + } + absxk = fabsf( obj->list_pos[1] - tmp_pos[1] ); + if ( absxk > *scale ) + { + t = *scale / absxk; + out_tmp = ( ( out_tmp * t ) * t ) + 1.0f; + *scale = absxk; + } + else + { + t = absxk / *scale; + out_tmp += t * t; + } + absxk = fabsf( obj->list_pos[2] - tmp_pos[2] ); + if ( absxk > *scale ) + { + t = *scale / absxk; + out_tmp = ( ( out_tmp * t ) * t ) + 1.0f; + *scale = absxk; + } + else + { + t = absxk / *scale; + out_tmp += t * t; + } + return out_tmp; +} + + +/*-----------------------------------------------------------------------------------------* + * Function shoebox_set_scene + * + * Initial scene setup returning computed reflection (arrival times, DOA and gain). + *-----------------------------------------------------------------------------------------*/ + + +void shoebox_set_scene( + shoebox_obj_t *obj, + shoebox_output_t *ER_PARAMS, + const float list_pos[3], + const float src_pos_data[], + uint16_t isCartesian, + uint16_t isRelative ) +{ + float tmp_pos[3]; + float out_tmp; + int32_t i, j, k, n; + int32_t loop_ub; + /* ------------- SET FLAGS ------------- */ + obj->isCartesian = isCartesian; + obj->isRelative = isRelative; + /* ------------- CHECK DIMENSIONS ------------- */ + if ( ER_PARAMS->n_sources > obj->MAX_SOURCES ) + { + obj->nSrc = obj->MAX_SOURCES; + } + else + { + obj->nSrc = ER_PARAMS->n_sources; + } + /* ---------- RESET DATA HOLDERS ---------- */ + set_f( &obj->src_pos[0], 0.0f, 75U ); + obj->list_pos[0] = list_pos[0]; + obj->list_pos[1] = list_pos[1]; + obj->list_pos[2] = list_pos[2]; + /* ---------- ADJUST LISTENER ------------- */ + if ( obj->isZHeight != 0 ) + { + obj->list_pos[2] = list_pos[2] - ( obj->cal.room_H / 2.0f ); + } + tmp_pos[1] = obj->list_pos[1]; + tmp_pos[2] = obj->list_pos[2]; + + shoebox_bound( obj, obj->list_pos ); + + /* ---------- SOURCE LOOP ------------- */ + i = (int32_t) obj->nSrc; + for ( j = 0; j < i; j++ ) + { + float fcnOutput_data[75]; + float rcoselev; + float scale; + int32_t coord; + /* idx = single(i); */ + out_tmp = 3.0f * ( ( ( (float) j ) + 1.0f ) - 1.0f ); + /* GET COORDINATE IN CARTESIAN ABSOLUTE FORMAT */ + if ( ( out_tmp + 1.0f ) > ( ( out_tmp + 1.0f ) + 2.0f ) ) + { + k = 0; + n = 0; + coord = 1; + } + else + { + k = ( (int32_t) ( (float) ( out_tmp + 1.0f ) ) ) - 1; + n = (int32_t) ( (float) ( ( out_tmp + 1.0f ) + 2.0f ) ); + coord = (int32_t) ( (float) ( out_tmp + 1.0f ) ); + } + loop_ub = n - k; + for ( n = 0; n < loop_ub; n++ ) + { + fcnOutput_data[n] = src_pos_data[k + n]; + } + + + shoebox_get_coord( obj, fcnOutput_data, src_pos_data, tmp_pos, out_tmp, coord, loop_ub, k, isRelative ); + + shoebox_bound( obj, tmp_pos ); + + scale = 1.29246971E-26F; + + out_tmp = shoebox_get_euclidian_distance_internal( obj, tmp_pos, &scale ); + + obj->src_dist[( (int32_t) ( (float) ( ( (float) j ) + 1.0f ) ) ) - 1] = scale * sqrtf( out_tmp ); + + /* COMPUTE PATTERNS */ + /* NOTE: CONVERT INTO OWN FUNCTION */ + + /* SHOEBOX_COMPUTE: fills an input structure (4 array fields of length NxR ) with the */ + /* Early reflection metadata (time of arrival, gain, az, el). */ + /* */ + /* Input: */ + /* 1. obj : Module data holder */ + /* 2. ER_struct : Early reflection structure */ + /* 3. src_num : Index of source to compute patterns for */ + /* ------ */ + out_tmp = obj->src_dist[( (int32_t) ( (float) ( ( (float) j ) + 1.0f ) ) ) - 1]; + for ( loop_ub = 0; loop_ub < 6; loop_ub++ ) + { + float im_pos[3]; + float path_dist; + /* Retrieve coordinate and surface sign */ + coord = ( (int32_t) ceilf( ( ( (float) loop_ub ) + 1.0f ) / 2.0f ) ) - 1; + rcoselev = ( ( (float) loop_ub ) + 1.0f ) + ( ER_PARAMS->n_ref * ( ( ( (float) j ) + 1.0f ) - 1.0f ) ); + /* Initialize image position coordinates */ + im_pos[0] = tmp_pos[0]; + im_pos[1] = tmp_pos[1]; + im_pos[2] = tmp_pos[2]; + /* Calculate image projection coordinate based on current surface axis */ + if ( ( loop_ub + 1 ) < 3 ) + { + scale = obj->cal.room_L; + } + else if ( ( loop_ub + 1 ) < 5 ) + { + scale = obj->cal.room_W; + } + else + { + scale = obj->cal.room_H; + } + im_pos[coord] = + tmp_pos[coord] + + ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); + /* 0. Get euclidean distance from IMAGE SOURCE [N,W] to LIST */ + scale = 1.29246971E-26F; + path_dist = shoebox_get_euclidian_distance_internal( obj, im_pos, &scale ); + + path_dist = scale * sqrtf( path_dist ); + /* 1. Compute time-of arrival (TOA) */ + ER_PARAMS->times.data[( (int32_t) rcoselev ) - 1] = path_dist / obj->soundspeed; + /* 2./3. DOA */ + ER_PARAMS->az_angle.data[( (int32_t) rcoselev ) - 1] = + rad2deg( + atan2f( im_pos[1] - obj->list_pos[1], im_pos[0] - obj->list_pos[0] ) ); + ER_PARAMS->el_angle.data[( (int32_t) rcoselev ) - 1] = + rad2deg( + asinf( ( im_pos[2] - obj->list_pos[2] ) / path_dist ) ); + /* 4. Compute gain taking into account air and surface absorption */ + /* and propagation loss */ + if ( path_dist < out_tmp ) + { + path_dist = out_tmp; + } + ER_PARAMS->gains.data[( (int32_t) rcoselev ) - 1] = + ( ( 1.0f - obj->cal.abs_coeff[loop_ub] ) * ( out_tmp / path_dist ) ) - ( path_dist * obj->air_coeff ); + } + } +} + + +#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 04cfd144ed..5efc8ae118 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -534,6 +534,13 @@ typedef struct ivas_roomAcoustics_t float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ +#ifdef EARLY_REFLECTIONS + int16_t use_er; /* ER activation flag */ + int16_t lowComplexity; /* Low complexity ER flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float AbsCoeff[ER_ABS_COEFF]; /* Absorption coeffs */ + IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ +#endif } ivas_roomAcoustics_t; @@ -633,6 +640,97 @@ typedef struct ivas_reverb_state_t } REVERB_DATA, *REVERB_HANDLE; +#ifdef EARLY_REFLECTIONS +/*----------------------------------------------------------------------------------* + * Shoebox structure + *----------------------------------------------------------------------------------*/ + +/* This structure holds the original bitstream metadata */ + +typedef struct +{ + float room_L; + float room_W; + float room_H; + float abs_coeff[ER_ABS_COEFF]; + float list_orig[3]; +} shoebox_config_t; + +/* This structure holds the corrected( bounded ) source and listener positions */ + +typedef struct +{ + uint16_t isCartesian; + uint16_t isRelative; + uint16_t isZHeight; + uint16_t isRadians; + float MAX_SOURCES; + float max_bands; + float REF_ORDER; + float src_pos[75]; + float src_dist[25]; + float list_pos[3]; + float nSrc; + float radius; + float min_wall_dist; + float soundspeed; + float air_coeff; + shoebox_config_t cal; +} shoebox_obj_t; + + +typedef struct shoebox_data_t +{ + float data[150]; + int32_t size[1]; +} shoebox_data_t; + + +typedef struct +{ + uint16_t n_sources; + uint16_t n_ref; + shoebox_data_t times; + shoebox_data_t gains; + shoebox_data_t az_angle; + shoebox_data_t el_angle; +} shoebox_output_t; + +#endif + +#ifdef EARLY_REFLECTIONS +/*----------------------------------------------------------------------------------* + * Reflections structure + *----------------------------------------------------------------------------------*/ + +/* This structure holds the original source positions */ +typedef struct er_struct_t +{ + AUDIO_CONFIG mode; + int16_t nchan_out; + uint16_t use_er; + uint16_t lowComplexity; + uint16_t n_LC_sources; + uint16_t *LC_mixing; + uint16_t is_ready; + uint16_t circ_len; + uint16_t circ_insert; + uint16_t n_total_reflections; + uint16_t is_cartesian; + uint16_t is_relative; + uint32_t max_frame_size; + float output_Fs; + float source_positions[75]; + float user_origin[3]; + float *circ_buffers; + float **reflection_buffers; + uint16_t *closest_ch_idx; + shoebox_output_t shoebox_data; + shoebox_obj_t shoebox_lib; +} er_struct_t; + +#endif + /*----------------------------------------------------------------------------------* * TD ISM Object Renderer structure *----------------------------------------------------------------------------------*/ @@ -926,6 +1024,9 @@ typedef struct ivas_crend_state_t REVERB_HANDLE hReverb; int16_t delay_line_rw_index; int16_t diffuse_delay_line_rw_index; +#ifdef EARLY_REFLECTIONS + er_struct_t *reflections; +#endif } CREND_DATA, *CREND_HANDLE; diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c new file mode 100644 index 0000000000..c26a7b9156 --- /dev/null +++ b/lib_util/head_rotation_file_reader.c @@ -0,0 +1,37 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "head_rotation_file_reader.h" +#include +#include +#include +#include "prot.h" diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h new file mode 100644 index 0000000000..d4a2af84e7 --- /dev/null +++ b/lib_util/head_rotation_file_reader.h @@ -0,0 +1,38 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_HR_FILE_READER_H +#define IVAS_HR_FILE_READER_H + +#include "common_api_types.h" + +#endif /* IVAS_HR_FILE_READER_H */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 2f731585a9..614d578612 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -90,9 +90,10 @@ typedef enum _FREQ_GRID_MODE } FREQ_GRID_MODE; #endif -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS typedef struct { + uint16_t use_er; /* Activation Flag */ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ float pAbsCoeff[N_ABS_COEFFS]; /* Absorption coeffs table */ IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ @@ -107,7 +108,7 @@ typedef struct float *pRT60; /* RT60 table */ float *pDSR; /* DSR table */ float preDelay; /* Pre-delay */ -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS EarlyReflectionsConfig *pEarlyReflections; /* Early reflections configuration */ #endif } AcousticEnv; @@ -1239,6 +1240,10 @@ static ivas_error RenderConfigReader_checkValues( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; pRoom_acoustics = &hRenderConfig->room_acoustics; tab_value_err_count = 0; +#ifdef EARLY_REFLECTIONS + int16_t wall_idx; +#endif + /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) @@ -1314,6 +1319,52 @@ static ivas_error RenderConfigReader_checkValues( } #endif /* DEBUGGING */ + +#ifdef EARLY_REFLECTIONS + if ( pRoom_acoustics->use_er == 1 ) + { + /* Room dimensions */ + if ( pRoom_acoustics->dimensions.x < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.x = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.x > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.x = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.y = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.y = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.z = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.z = ER_MAX_ROOM_DIMENSION; + } + + /* Abs Coeff */ + for ( wall_idx = 0; wall_idx < ER_ABS_COEFF; wall_idx++ ) + { + if ( pRoom_acoustics->AbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) + { + pRoom_acoustics->AbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; + } + if ( pRoom_acoustics->AbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) + { + pRoom_acoustics->AbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; + } + } + } + +#endif + return IVAS_ERR_OK; } @@ -1372,7 +1423,7 @@ static ivas_error RenderConfigReader_readBinary( { uint32_t file_size; uint32_t value; -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS uint32_t signx, signy, k; #endif uint32_t i, m, n; @@ -1624,7 +1675,7 @@ static ivas_error RenderConfigReader_readBinary( { free( pRenderConfigReader->pAE[n].pRT60 ); free( pRenderConfigReader->pAE[n].pDSR ); -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) { free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); @@ -1645,7 +1696,7 @@ static ivas_error RenderConfigReader_readBinary( { pRenderConfigReader->pAE[n].pRT60 = NULL; pRenderConfigReader->pAE[n].pDSR = NULL; -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS pRenderConfigReader->pAE[n].pEarlyReflections = NULL; #endif } @@ -1706,7 +1757,7 @@ static ivas_error RenderConfigReader_readBinary( } } -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS /* Has early reflections */ if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) { @@ -1721,6 +1772,8 @@ static ivas_error RenderConfigReader_readBinary( /* Initialize memory pointers to allow safe freeing ico eg errors */ pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = NULL; + pRenderConfigReader->pAE[n].pEarlyReflections->use_er = 1; + /* Room sizes */ if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x ) ) != IVAS_ERR_OK ) { @@ -1785,7 +1838,17 @@ static ivas_error RenderConfigReader_readBinary( return error; } } - + else /* load defaults if origin is not specified in config */ + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = ER_LIST_HEIGHT; + } + /* Low complexity mode */ if ( ( error = read_bin_bool( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity ) ) != IVAS_ERR_OK ) { @@ -1870,7 +1933,7 @@ ivas_error RenderConfigReader_read( uint32_t roomAcHasFgCount, roomAcHasAcEnvCount; uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS uint32_t aeHasERsize, aeHasERabs; #endif #else @@ -1991,7 +2054,7 @@ ivas_error RenderConfigReader_read( { free( pRenderConfigReader->pAE[idx].pRT60 ); free( pRenderConfigReader->pAE[idx].pDSR ); -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS if ( pRenderConfigReader->pAE[idx].pEarlyReflections != NULL ) { free( pRenderConfigReader->pAE[idx].pEarlyReflections->pListenerOrigin ); @@ -2012,7 +2075,7 @@ ivas_error RenderConfigReader_read( { pRenderConfigReader->pAE[acIdx].pRT60 = NULL; pRenderConfigReader->pAE[acIdx].pDSR = NULL; -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL; #endif } @@ -2283,7 +2346,7 @@ ivas_error RenderConfigReader_read( pRenderConfigReader->pAE->id = idx; aeHasFgIdx = aeHasPredelay = aeHasRt60 = aeHasDsr = FALSE; -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS aeHasERsize = aeHasERabs = FALSE; #endif params_idx = 0; @@ -2350,7 +2413,7 @@ ivas_error RenderConfigReader_read( } aeHasDsr = TRUE; } -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS else if ( strcmp( item, "EARLYREFLECTIONSSIZE" ) == 0 ) { if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) @@ -2457,7 +2520,7 @@ ivas_error RenderConfigReader_read( { fprintf( stderr, "Renderer configuration: DSR missing from 'acousticEnvironment' %d.\n\n", acIdx ); } -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS if ( aeHasERsize == TRUE && aeHasERabs == FALSE ) { fprintf( stderr, "Renderer configuration: early reflections absorption coefficients missing from 'acousticEnvironment' %d.\n\n", acIdx ); @@ -2468,7 +2531,7 @@ ivas_error RenderConfigReader_read( { return IVAS_ERR_INVALID_RENDER_CONFIG; } -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS if ( aeHasERsize == TRUE && aeHasERabs == FALSE ) { return IVAS_ERR_INVALID_RENDER_CONFIG; @@ -2792,6 +2855,9 @@ ivas_error RenderConfigReader_getAcousticEnvironment( ) { uint16_t n, m; +#ifdef EARLY_REFLECTIONS + uint16_t j; +#endif if ( pRenderConfigReader == NULL || pAcEnv == NULL ) { @@ -2811,6 +2877,20 @@ ivas_error RenderConfigReader_getAcousticEnvironment( pAcEnv->pAcoustic_rt60[m] = pRenderConfigReader->pAE[n].pRT60[m]; pAcEnv->pAcoustic_dsr[m] = pRenderConfigReader->pAE[n].pDSR[m]; } + +#ifdef EARLY_REFLECTIONS + if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) + { + pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ + pAcEnv->lowComplexity = pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity; /* Low complexity flag */ + pAcEnv->dimensions = pRenderConfigReader->pAE[n].pEarlyReflections->dimensions; + pAcEnv->ListenerOrigin = *pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin; + for ( j = 0; j < QC_ABS_COEFF; j++ ) + { + pAcEnv->AbsCoeff[j] = pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j]; + } + } +#endif return IVAS_ERR_OK; } } @@ -2842,7 +2922,7 @@ void RenderConfigReader_close( /* Free the acoustic environments */ for ( n = 0; n < ( *ppRenderConfigReader )->nAE; n++ ) { -#ifdef CONTROL_METADATA_EARLY_REFLECTIONS +#ifdef EARLY_REFLECTIONS if ( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections != NULL ) { free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pListenerOrigin ); diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 16d2f67a8f..077c93f114 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -71,7 +71,7 @@ ivas_error RenderConfigReader_read( const char *pRenderConfigPath /* i : Renderer configuration file path */ #if ( defined SPLIT_REND_WITH_HEAD_ROT ) || ( defined DEBUGGING ) , - IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ + IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ #endif #else RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ diff --git a/scripts/reverb/generate_acoustic_environments_metadata.py b/scripts/reverb/generate_acoustic_environments_metadata.py index 635fbc7b4a..70de0ea89c 100644 --- a/scripts/reverb/generate_acoustic_environments_metadata.py +++ b/scripts/reverb/generate_acoustic_environments_metadata.py @@ -495,13 +495,11 @@ def generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_re + '1' # hasEarlyReflections + concatenate(lambda d : get_distance_code(d, True), [ 3.0, 4.0, 2.5 ]) # erSize (room dimensions) - - + get_count_or_index_code(0) # erFreqGridIdx + concatenate(get_absorption_code, # erAbsCoeff [ 0.8, 0.8, 0.8, 0.8, 0.2, 0.6 ]) - + '0' # hasListenerOrigin + '0' # lowComplexity + + '0' # hasDirectivity , endian='big') @@ -553,8 +551,6 @@ def generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_re + '1' # hasEarlyReflections + concatenate(lambda code : get_distance_code(code, True), [ 3.0, 4.0, 2.5 ]) # erSize (room dimensions) - - + get_count_or_index_code(0) # erFreqGridIdx + concatenate(get_absorption_code, # erAbsCoeff [ 0.8, 0.8, 0.8, 0.8, 0.2, 0.6 ]) @@ -654,11 +650,247 @@ def generate_reverb_payload_equivalent_to_rend_config_recreation_cfg(): file.close() +def generate_reverb_payload_ERstrong_LISTon_DIRoff(): + # based on config_renderer.cfg + # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values + data = bitarray( + '1' # hasAcEnv + + get_count_or_index_code(2) # fgdNrGrids + # frequency grid #1 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(1) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 10000.0 ]) + + # frequency grid #2 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(31) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, + 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, + 20000.0 ]) + + + get_count_or_index_code(1) # AcousticEnvCount + + get_id_code(0) # ID + + get_count_or_index_code(1) # FreqGridID + + get_duration_code(0.1) # (input)Predelay + + + concatenate(get_duration_code, # RT60 + [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2 ]) + + + concatenate(get_dsr_code, # DSR + [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09 ]) + + + '1' # hasEarlyReflections + + concatenate(lambda code : get_distance_code(code, True), + [ 2.0, 2.0, 3.0 ]) # room dimensions + + concatenate(get_absorption_code, # absorptionCode + [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.2 ]) + + '1' # listener origin flag + + '1' # isPositiveX + + '0' # isPositiveY + + concatenate(lambda code : get_distance_code(code, True), + [ 2.0, 2.0, 3.0 ]) # origin + + '1' # lowComplexity + + + '0' # hasDirectivity + , endian='big') + + file = open('rend_config_ERstrong_LISTon_DIRoff.dat', 'wb') + data.tofile(file) + file.close() + +def generate_reverb_payload_ERstrong_LISTon_DIRon(): + # based on config_renderer.cfg + # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values + data = bitarray( + '1' # hasAcEnv + + get_count_or_index_code(2) # fgdNrGrids + # frequency grid #1 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(1) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 10000.0 ]) + + # frequency grid #2 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(31) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, + 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, + 20000.0 ]) + + + get_count_or_index_code(1) # AcousticEnvCount + + get_id_code(0) # ID + + get_count_or_index_code(1) # FreqGridID + + get_duration_code(0.1) # (input)Predelay + + + concatenate(get_duration_code, # RT60 + [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2 ]) + + + concatenate(get_dsr_code, # DSR + [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09 ]) + + + '1' # hasEarlyReflections + + concatenate(lambda code : get_distance_code(code, True), + [ 2.0, 2.0, 3.0 ]) # room dimensions + + concatenate(get_absorption_code, # absorptionCode + [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) + + '1' # listener origin flag + + '1' # isPositiveX + + '0' # isPositiveY + + concatenate(lambda d : get_distance_code(d, True), + [ 0.1, 0.1, 1.5]) # listener origin (x, y, z) + + '1' # lowComplexity + + + '1' # hasDirectivity + , endian='big') + + file = open('rend_config_ERstrong_LISTon_DIRon.dat', 'wb') + data.tofile(file) + file.close() + +def generate_reverb_payload_ERstrong_LISToff_DIRon(): + # based on config_renderer.cfg + # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values + data = bitarray( + '1' # hasAcEnv + + get_count_or_index_code(2) # fgdNrGrids + # frequency grid #1 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(1) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 10000.0 ]) + + # frequency grid #2 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(31) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, + 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, + 20000.0 ]) + + + get_count_or_index_code(1) # AcousticEnvCount + + get_id_code(0) # ID + + get_count_or_index_code(1) # FreqGridID + + get_duration_code(0.1) # (input)Predelay + + + concatenate(get_duration_code, # RT60 + [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2 ]) + + + concatenate(get_dsr_code, # DSR + [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09 ]) + + + '1' # hasEarlyReflections + + concatenate(lambda code : get_distance_code(code, True), + [ 2.0, 2.0, 3.0 ]) # room dimensions + + concatenate(get_absorption_code, # absorptionCode + [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) + + '0' + + '1' # lowComplexity + + + '1' # hasDirectivity + , endian='big') + + file = open('rend_config_ERstrong_LISToff_DIRon.dat', 'wb') + data.tofile(file) + file.close() + +def generate_reverb_payload_ERstrong_LISToff_DIRoff(): + # based on config_renderer.cfg + # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values + data = bitarray( + '1' # hasAcEnv + + get_count_or_index_code(2) # fgdNrGrids + # frequency grid #1 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(1) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 10000.0 ]) + + # frequency grid #2 + + fgdMethod.Individual_Frequencies.value # fgdMethod + + get_count_or_index_code(31) # fgdNrBands + + + concatenate(get_frequency_code, # fgdCenterFreq + [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, + 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, + 20000.0 ]) + + + get_count_or_index_code(1) # AcousticEnvCount + + get_id_code(0) # ID + + get_count_or_index_code(1) # FreqGridID + + get_duration_code(0.1) # (input)Predelay + + + concatenate(get_duration_code, # RT60 + [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, + 0.2 ]) + + + concatenate(get_dsr_code, # DSR + [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, + 2.6267e-09 ]) + + + '1' # hasEarlyReflections + + concatenate(lambda code : get_distance_code(code, True), + [ 2.0, 2.0, 3.0 ]) # room dimensions + + concatenate(get_absorption_code, # absorptionCode + [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) + + '0' + + '0' # lowComplexity + + + '0' # hasDirectivity + , endian='big') + + file = open('rend_config_ERstrong_LISToff_DIRoff.dat', 'wb') + data.tofile(file) + file.close() + if __name__ == "__main__": #test() - generate_reverb_payload_equivalent_to_rend_config_renderer_cfg() - generate_reverb_payload_equivalent_to_rend_config_hospital_patientroom_cfg() - generate_reverb_payload_equivalent_to_rend_config_recreation_cfg() + #generate_reverb_payload_equivalent_to_rend_config_renderer_cfg() + #generate_reverb_payload_equivalent_to_rend_config_hospital_patientroom_cfg() + #generate_reverb_payload_equivalent_to_rend_config_recreation_cfg() + # generate_reverb_payload_small_ER_OFF() + # generate_reverb_payload_small_ER() + # generate_reverb_payload_aggressive_ER() + + generate_reverb_payload_ERstrong_LISTon_DIRoff() + generate_reverb_payload_ERstrong_LISTon_DIRon() + generate_reverb_payload_ERstrong_LISToff_DIRon() + generate_reverb_payload_ERstrong_LISToff_DIRoff() - #generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_no_listener_origin() - #generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_listener_origin() + generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_no_listener_origin() + generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_listener_origin() \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg new file mode 100644 index 0000000000..0b2f95a1fb --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_ERstrong_LISToff_DIRoff.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat new file mode 100644 index 0000000000..0086efc8d0 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32ff63243d32bf7297ce955137651ea168b52688ad78089c91e6c92ef453fb74 +size 91 diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg new file mode 100644 index 0000000000..b8c6a9d241 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_ERstrong_LISToff_DIRon.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat new file mode 100644 index 0000000000..eeff1f9a60 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:197e50d0904c240c8dedb3600aeb764f1c269289ac85da0c96a2359cb90a806e +size 91 diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg new file mode 100644 index 0000000000..24f9fdcb46 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_ERstrong_LISTon_DIRoff.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat new file mode 100644 index 0000000000..041d55968e --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4c5cd9dbd5102d568e2431e0b026a97ebd954f25f59741e2f4aba241f5edd47 +size 94 diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg new file mode 100644 index 0000000000..b8ddec3127 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_ERstrong_LISTon_DIRon.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat new file mode 100644 index 0000000000..9302d9a824 --- /dev/null +++ b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e98081ff16b528e988bc0a429b1f55949c264f75f696bd999078ddc7455ed69 +size 96 diff --git a/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.cfg b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.cfg new file mode 100644 index 0000000000..ead63890b5 --- /dev/null +++ b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_renderer_cfg_plus_early_reflections_listener_origin.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.dat b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.dat new file mode 100644 index 0000000000..4d16889420 --- /dev/null +++ b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_listener_origin.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff2025be8627eeaa88a58417ebf4a8bc02ef648e87897a63ef2e45a88e67565b +size 145 diff --git a/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.cfg b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.cfg new file mode 100644 index 0000000000..2f122473c6 --- /dev/null +++ b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.cfg @@ -0,0 +1,2 @@ +[general] +binaryConfig = rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.dat b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.dat new file mode 100644 index 0000000000..39b5aaf89a --- /dev/null +++ b/scripts/testv/rend_config_renderer_cfg_plus_early_reflections_no_listener_origin.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5bab8146537e4d7051a727587d950ac73e857764cb5fa1a09fdb1c4323f470ea +size 139 -- GitLab From 4b9f5b30cdec1abd722bc05dadf1de46ab329e2d Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Wed, 26 Jul 2023 02:37:31 -0400 Subject: [PATCH 02/16] changed and deleted configs --- lib_rend/ivas_er_utils.h | 54 ------------ lib_rend/ivas_reflections_utils.c | 86 ------------------- scripts/testv/rend_config_ER_v0.cfg | 38 ++++++++ scripts/testv/rend_config_ER_v0.dat | 3 + scripts/testv/rend_config_ER_v1.cfg | 37 ++++++++ scripts/testv/rend_config_ER_v1.dat | 3 + scripts/testv/rend_config_ER_v2.cfg | 38 ++++++++ scripts/testv/rend_config_ER_v2.dat | 3 + scripts/testv/rend_config_ER_v3.cfg | 38 ++++++++ scripts/testv/rend_config_ER_v3.dat | 3 + .../rend_config_ERstrong_LISToff_DIRoff.cfg | 2 - .../rend_config_ERstrong_LISToff_DIRoff.dat | 3 - .../rend_config_ERstrong_LISToff_DIRon.cfg | 2 - .../rend_config_ERstrong_LISToff_DIRon.dat | 3 - .../rend_config_ERstrong_LISTon_DIRoff.cfg | 2 - .../rend_config_ERstrong_LISTon_DIRoff.dat | 3 - .../rend_config_ERstrong_LISTon_DIRon.cfg | 2 - .../rend_config_ERstrong_LISTon_DIRon.dat | 3 - 18 files changed, 163 insertions(+), 160 deletions(-) delete mode 100644 lib_rend/ivas_er_utils.h delete mode 100644 lib_rend/ivas_reflections_utils.c create mode 100644 scripts/testv/rend_config_ER_v0.cfg create mode 100644 scripts/testv/rend_config_ER_v0.dat create mode 100644 scripts/testv/rend_config_ER_v1.cfg create mode 100644 scripts/testv/rend_config_ER_v1.dat create mode 100644 scripts/testv/rend_config_ER_v2.cfg create mode 100644 scripts/testv/rend_config_ER_v2.dat create mode 100644 scripts/testv/rend_config_ER_v3.cfg create mode 100644 scripts/testv/rend_config_ER_v3.dat delete mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg delete mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat delete mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg delete mode 100644 scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat delete mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg delete mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat delete mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg delete mode 100644 scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat diff --git a/lib_rend/ivas_er_utils.h b/lib_rend/ivas_er_utils.h deleted file mode 100644 index a278e76adc..0000000000 --- a/lib_rend/ivas_er_utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - - -#include -#include "options.h" -#include "ivas_cnst.h" - -#ifdef EARLY_REFLECTIONS - -/*---------------------------------------------------------------------------------* - * Reflections utils prototypes - *-----------------------------------------------------------------------------------*/ - -/* matrix memory handling */ -ivas_error er_init_float_matrix( - float ***mat, - uint16_t rows, - uint16_t cols ); - -ivas_error er_free_float_matrix( - float **mat, - uint16_t rows ); - -#endif diff --git a/lib_rend/ivas_reflections_utils.c b/lib_rend/ivas_reflections_utils.c deleted file mode 100644 index 331e2c312a..0000000000 --- a/lib_rend/ivas_reflections_utils.c +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include "options.h" - -#ifdef EARLY_REFLECTIONS - -#include -#include -#include -#include "prot.h" -#include "ivas_prot_rend.h" -#include "ivas_stat_rend.h" -#include "ivas_error.h" -#include "ivas_er_utils.h" -#include "wmc_auto.h" - -/* Initialize memory for a 2D matrix of floats */ -ivas_error er_init_float_matrix( float ***mat, uint16_t rows, uint16_t cols ) -{ - *mat = malloc( rows * sizeof( **mat ) ); - if ( !( *mat ) ) - { - return IVAS_ERR_FAILED_ALLOC; - } - for ( uint16_t i = 0; i < rows; i++ ) - { - ( *mat )[i] = malloc( cols * sizeof( ***mat ) ); - - if ( !( ( *mat )[i] ) ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - set_f( ( *mat )[i], 0.0f, cols ); - } - return IVAS_ERR_OK; -} - -/* Delete memory stored in a 2D matrix of floats */ -ivas_error er_free_float_matrix( float **mat, uint16_t rows ) -{ - if ( mat ) - { - for ( uint16_t i = 0; i < rows; i++ ) - { - if ( mat[i] ) - { - free( mat[i] ); - } - } - free( mat ); - } - return IVAS_ERR_OK; -} - -#endif diff --git a/scripts/testv/rend_config_ER_v0.cfg b/scripts/testv/rend_config_ER_v0.cfg new file mode 100644 index 0000000000..7248cd428e --- /dev/null +++ b/scripts/testv/rend_config_ER_v0.cfg @@ -0,0 +1,38 @@ +[roomAcoustics] +frequencyGridCount = 1; +acousticEnvironmentCount = 1; + +[frequencyGrid:0] +method = individualFrequencies; +nrBands = 24; +frequencies = [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]; + +[acousticEnvironment:0] +frequencyGridIndex = 0; +predelay = 0.108; +rt60 = [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]; + +dsr = [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]; + +earlyReflectionsSize = [ 2.0, 2.0, 3.0 ]; +absorptionCoeffs = [ 0.2, 0.1, 0.1, 0.1, 0.3, 0.1 ]; +lowComplexity = TRUE; +listenerOrigin = [ 0.0, 0.0, 1.5 ]; + +[general] +binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v0.dat b/scripts/testv/rend_config_ER_v0.dat new file mode 100644 index 0000000000..af1e7ffa16 --- /dev/null +++ b/scripts/testv/rend_config_ER_v0.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0e5cdb59fa93168feb1d4b973b1b2c2128fe103db5422b5ac4249f51bbf45a0 +size 84 diff --git a/scripts/testv/rend_config_ER_v1.cfg b/scripts/testv/rend_config_ER_v1.cfg new file mode 100644 index 0000000000..7d78f48505 --- /dev/null +++ b/scripts/testv/rend_config_ER_v1.cfg @@ -0,0 +1,37 @@ +[roomAcoustics] +frequencyGridCount = 1; +acousticEnvironmentCount = 1; + +[frequencyGrid:0] +method = individualFrequencies; +nrBands = 24; +frequencies = [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]; + +[acousticEnvironment:0] +frequencyGridIndex = 0; +predelay = 0.108; +rt60 = [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]; + +dsr = [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]; + +earlyReflectionsSize = [3.0, 3.0, 4.0]; +absorptionCoeffs = [ 0.3, 0.2, 0.2, 0.2, 0.3, 0.1 ]; +lowComplexity = FALSE; + +[general] +binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v1.dat b/scripts/testv/rend_config_ER_v1.dat new file mode 100644 index 0000000000..187af67058 --- /dev/null +++ b/scripts/testv/rend_config_ER_v1.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a92c702caf083634ffbcbd013d5c7fe2ad5bf09ebd4440c1021e9b56b3f33ae +size 80 diff --git a/scripts/testv/rend_config_ER_v2.cfg b/scripts/testv/rend_config_ER_v2.cfg new file mode 100644 index 0000000000..1a50735708 --- /dev/null +++ b/scripts/testv/rend_config_ER_v2.cfg @@ -0,0 +1,38 @@ +[roomAcoustics] +frequencyGridCount = 1; +acousticEnvironmentCount = 1; + +[frequencyGrid:0] +method = individualFrequencies; +nrBands = 24; +frequencies = [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]; + +[acousticEnvironment:0] +frequencyGridIndex = 0; +predelay = 0.108; +rt60 = [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]; + +dsr = [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]; + +earlyReflectionsSize = [3.0, 3.0, 4.0]; +absorptionCoeffs = [ 0.3, 0.2, 0.3, 0.4, 0.3, 0.4 ]; +lowComplexity = FALSE; +listenerOrigin = [0.5, -0.5, 1.5]; + +[general] +binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v2.dat b/scripts/testv/rend_config_ER_v2.dat new file mode 100644 index 0000000000..57cc0ca311 --- /dev/null +++ b/scripts/testv/rend_config_ER_v2.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75503e1e51276c3980f4bcf1a31a9fe632e3b14e88fe18652c7f17697aa580e5 +size 86 diff --git a/scripts/testv/rend_config_ER_v3.cfg b/scripts/testv/rend_config_ER_v3.cfg new file mode 100644 index 0000000000..7e7e14d7d3 --- /dev/null +++ b/scripts/testv/rend_config_ER_v3.cfg @@ -0,0 +1,38 @@ +[roomAcoustics] +frequencyGridCount = 1; +acousticEnvironmentCount = 1; + +[frequencyGrid:0] +method = individualFrequencies; +nrBands = 24; +frequencies = [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]; + +[acousticEnvironment:0] +frequencyGridIndex = 0; +predelay = 0.108; +rt60 = [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]; + +dsr = [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]; + +earlyReflectionsSize = [4.0, 4.0, 5.0]; +absorptionCoeffs = [ 0.1, 0.2, 0.2, 0.2, 0.1, 0.1 ]; +lowComplexity = TRUE; +listenerOrigin = [-1, 0.5, 1.5]; + +[general] +binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v3.dat b/scripts/testv/rend_config_ER_v3.dat new file mode 100644 index 0000000000..280cf26d0d --- /dev/null +++ b/scripts/testv/rend_config_ER_v3.dat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:425e97bd84110a35bd204a5d7f60e2e01cc2e1e96611ed3bca4b5877380194d3 +size 85 diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg deleted file mode 100644 index 0b2f95a1fb..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[general] -binaryConfig = rend_config_ERstrong_LISToff_DIRoff.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat b/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat deleted file mode 100644 index 0086efc8d0..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISToff_DIRoff.dat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:32ff63243d32bf7297ce955137651ea168b52688ad78089c91e6c92ef453fb74 -size 91 diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg deleted file mode 100644 index b8c6a9d241..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[general] -binaryConfig = rend_config_ERstrong_LISToff_DIRon.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat b/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat deleted file mode 100644 index eeff1f9a60..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISToff_DIRon.dat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:197e50d0904c240c8dedb3600aeb764f1c269289ac85da0c96a2359cb90a806e -size 91 diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg deleted file mode 100644 index 24f9fdcb46..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[general] -binaryConfig = rend_config_ERstrong_LISTon_DIRoff.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat b/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat deleted file mode 100644 index 041d55968e..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISTon_DIRoff.dat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a4c5cd9dbd5102d568e2431e0b026a97ebd954f25f59741e2f4aba241f5edd47 -size 94 diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg deleted file mode 100644 index b8ddec3127..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[general] -binaryConfig = rend_config_ERstrong_LISTon_DIRon.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat b/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat deleted file mode 100644 index 9302d9a824..0000000000 --- a/scripts/testv/rend_config_ERstrong_LISTon_DIRon.dat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9e98081ff16b528e988bc0a429b1f55949c264f75f696bd999078ddc7455ed69 -size 96 -- GitLab From 711106104cc350947c8f0703b7b77e284e5d8bbc Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Wed, 26 Jul 2023 02:39:23 -0400 Subject: [PATCH 03/16] updated branch to newer 38 version --- Workspace_msvc/lib_rend.vcxproj | 2 - lib_com/common_api_types.h | 2 +- lib_com/ivas_cnst.h | 4 +- lib_com/ivas_dirac_com.c | 16 + lib_com/ivas_prot.h | 24 ++ lib_com/ivas_spar_com.c | 4 + lib_com/lsf_tools.c | 8 +- lib_com/options.h | 7 + lib_com/pvq_com.c | 2 + lib_dec/ivas_dec.c | 16 +- lib_dec/ivas_jbm_dec.c | 20 +- lib_dec/ivas_masa_dec.c | 13 + lib_dec/ivas_qmetadata_dec.c | 58 +++- lib_dec/ivas_sba_dec.c | 24 ++ lib_dec/ivas_sba_dirac_stereo_dec.c | 7 +- lib_dec/ivas_sba_rendering_internal.c | 9 + lib_dec/ivas_spar_decoder.c | 28 +- lib_dec/ivas_spar_md_dec.c | 109 ++++++- lib_enc/ivas_qmetadata_enc.c | 65 ++++ lib_enc/lsf_msvq_ma_enc.c | 14 +- lib_rend/ivas_crend.c | 29 +- lib_rend/ivas_prot_rend.h | 6 - lib_rend/ivas_reflections.c | 52 +-- lib_rend/ivas_reverb_utils.c | 34 +- lib_rend/ivas_sba_rendering.c | 8 + lib_rend/ivas_shoebox.c | 44 +-- lib_rend/ivas_stat_rend.h | 11 +- lib_util/render_config_reader.c | 84 ++--- lib_util/render_config_reader.h | 2 +- ...generate_acoustic_environments_metadata.py | 296 +++++++++--------- 30 files changed, 684 insertions(+), 314 deletions(-) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 959734a82b..a24252a06d 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -198,7 +198,6 @@ - @@ -253,7 +252,6 @@ - diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index e44eca91a7..a51967a750 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -180,7 +180,7 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ #ifdef EARLY_REFLECTIONS int16_t use_er; /* ER activation flag */ - int16_t lowComplexity; /* Low complexity ER flag */ + int16_t lowComplexity; /* Low complexity ER flag */ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ float AbsCoeff[QC_ABS_COEFF]; /* Absorption coeffs */ IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e23552fae1..8cd5418870 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1848,7 +1848,6 @@ typedef enum * Early Reflection constants *----------------------------------------------------------------------------------*/ #define ER_ABS_COEFF 6 -#define ER_MAX_BANDS 1 #define ER_MAX_SOURCES 25 #define ER_REF_ORDER 1 #define ER_NUM_REF 6 @@ -1856,8 +1855,7 @@ typedef enum #define ER_AIR_COEFF (0.00137f) #define ER_SOUND_SPEED (343.0f) #define ER_MIN_WALL_DIST (0.1f) - -#define ER_IS_Z_HEIGHT 1 +#define ER_EUCLIDEAN_SCALE (1.29246971E-26f) #define ER_DEFAULT_ROOM_L (3.0f) #define ER_DEFAULT_ROOM_W (4.0f) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 20f4b24953..504aea5d6c 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -111,12 +111,20 @@ ivas_error ivas_dirac_config( if ( ( (Encoder_Struct *) st_ivas )->hSpar != NULL ) { hFbMdft = ( (Encoder_Struct *) st_ivas )->hSpar->hFbMixer; +#ifdef FIX_613_DIRAC_NULL_PTR_USAN + dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; +#endif } else { hFbMdft = NULL; +#ifdef FIX_613_DIRAC_NULL_PTR_USAN + dirac_to_spar_md_bands = NULL; +#endif } +#ifndef FIX_613_DIRAC_NULL_PTR_USAN dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; +#endif } else { @@ -131,13 +139,21 @@ ivas_error ivas_dirac_config( if ( ( (Decoder_Struct *) st_ivas )->hSpar != NULL ) { hFbMdft = ( (Decoder_Struct *) st_ivas )->hSpar->hFbMixer; +#ifdef FIX_613_DIRAC_NULL_PTR_USAN + dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; +#endif } else { hFbMdft = NULL; +#ifdef FIX_613_DIRAC_NULL_PTR_USAN + dirac_to_spar_md_bands = NULL; +#endif } ( (Decoder_Struct *) st_ivas )->hDirAC->hFbMdft = hFbMdft; +#ifndef FIX_613_DIRAC_NULL_PTR_USAN dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; +#endif } if ( ivas_format == SBA_FORMAT ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 66b6b68669..9867cda5d9 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4252,6 +4252,10 @@ void ivas_sba_mix_matrix_determiner( const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ +#ifdef VLBR_20MS_MD + , + const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ +#endif ); /* AGC */ @@ -4554,7 +4558,23 @@ void ivas_get_spar_md_from_dirac( int16_t ivas_get_spar_dec_md_num_subframes( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef VLBR_20MS_MD + , + const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ +#endif ); +#ifdef VLBR_20MS_MD + +ivas_error ivas_spar_md_dec_matrix_open( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels, /* i : number of internal channels */ + const int16_t num_md_sub_frames ); + +void ivas_spar_md_dec_matrix_close( + ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels ); /* i : number of internal channels */ + +#endif ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ @@ -4562,6 +4582,10 @@ ivas_error ivas_spar_md_dec_open( const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ +#ifdef VLBR_20MS_MD + , + const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ +#endif ); void ivas_spar_md_dec_close( diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 03721833b9..d597d133fd 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1766,7 +1766,11 @@ void ivas_get_spar_md_from_dirac( { for ( band = start_band; band < end_band; band++ ) { +#ifdef FIX_615_UBSAN_SPAR_TO_DIRAC + ndm = hSpar_md_cfg->num_dmx_chans_per_band[band]; +#else ndm = hSpar_md_cfg->num_dmx_chans_per_band[band - 1]; +#endif /*SPAR from DirAC*/ set_f( response_avg, 0.0f, MAX_OUTPUT_CHANNELS ); diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 2f22dafa61..42688ee145 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2072,9 +2072,13 @@ void dec_FDCNG_MSVQ_stage1( for ( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ ) { +#ifdef FIX_612_MSVQ_UBSAN_LEFTSHIFT + dct_vec[col] = (float) shl( (Word16) cbpW8[col], dct_col_shift_tab[col] ); +#else dct_vec[col] = (float) ( ( (Word16) cbpW8[col] ) << dct_col_shift_tab[col] ); - /* LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); - in BASOP: s_and(for W8->W16), shl(), sub() +#endif + /* LOGIC( 1 ) , SHIFT( 1 ); + in BASOP: s_and(for W8->W16), shl() */ } dctT2_N_apply_matrix( (const float *) dct_vec, idct_vec, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype ); diff --git a/lib_com/options.h b/lib_com/options.h index e032b4ce4c..ed4dd2a8c4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,6 +154,7 @@ #define EARLY_REFLECTIONS /* Philips/Qualcomm: early reflections extension to reverb configuration */ #define CONTROL_METADATA_DIRECTIVITY /* Ericsson: Directivity renderer configuration */ #endif +#define VLBR_20MS_MD /* Dlb: SBA VLBR 20ms Optimization*/ #define SBA_MODE_CLEANUP_2 /* Dlb : changes part of fix issue #523 for unused signaling bit in SBA SID*/ #define FIX_137_SID_MD_BITS /* Dlb: Fix issue #137 , SID bitrate mismatch correction */ #define FIX_563_PARAMMC_LIMITER /* FhG: issue 563: fix ILD limiter when coming from silence w/o transient set */ @@ -194,6 +195,11 @@ #define JBM_PARAMUPMIX /* Dlb: Issue 471: Integrate the Multichannel Parametric Upmix into the JBM path */ #define FIX_582_INDEX_OUT_OF_BOUNDS_SNS_AVQ_DEC /* FhG: fix an undefined behaviour error in SNS AVQ decoding */ #define FIX_614_ADD_TO_NULL_PTR_DIRAC_SETUP /* FhG: Issue 614: prevent adding to a null pointer in dirac setup code */ +#define UPDATE_REVERB_UTILS /* Use CLDFB HRTFs of the appropriate SBA order in get_IR_from_filter_taps() */ +#define FIX_612_MSVQ_UBSAN_LEFTSHIFT /* Eri: Issue 612 : UBSAN: left shift of negative values in 1st stage of MSVQ */ +#define FIX_621_MSVQ_UBSAN_NULL_PTR_OFFSET /* Eri: Issue 621 : UBSAN: applying non-zero offset 7200 to null pointer in lsf_msvq_ma_enc.c */ +#define FIX_600_CLEANUP_OF_MANUAL_INSTRUMENTATION /* Eri: Issue 600 : removed manual WMCtool instrumentation outside of WMC_TOOL_SKIP defines */ +#define NONBE_FIX_539_MASA_384K_CHIRP /* Nokia: issue 539, puts the normalization of the energy ratios at the correct place, affect MASA 384k only */ /* Fixes for bugs found during split rendering contribution development */ #define REND_STATIC_MEM_OPT /* Dlb: Static memory optimisation for external renderer */ @@ -208,6 +214,7 @@ #define FIX_619_ADD_UNDEF_VAL_FOR_CONCEALMENT_MODE /* FhG: fix usan error */ #define FIX_622_SILENCE_USAN_WARNING /* FhG: silenceusan warning in ifft code */ +#define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_com/pvq_com.c b/lib_com/pvq_com.c index 133b7b62f7..d655dd7d4a 100644 --- a/lib_com/pvq_com.c +++ b/lib_com/pvq_com.c @@ -200,7 +200,9 @@ static void dsDiracPerQuanta( if ( t_quanta_o > sv[nsv >> 1] ) { dsIndex = nsv - dsIndex; /*single op*/ +#ifndef FIX_600_CLEANUP_OF_MANUAL_INSTRUMENTATION ADD( 1 ); +#endif } for ( i = frQuanta[0][td] - 1; i >= 0; i-- ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5fa8d4bec4..85334346ad 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -71,6 +71,9 @@ ivas_error ivas_dec( float pan_left, pan_right; ivas_error error; float *p_output[MAX_OUTPUT_CHANNELS]; +#ifdef VLBR_20MS_MD + int16_t num_md_sub_frames; +#endif error = IVAS_ERR_OK; @@ -388,7 +391,12 @@ ivas_error ivas_dec( } ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -411,7 +419,13 @@ ivas_error ivas_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { +#ifdef VLBR_20MS_MD + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); +#else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); +#endif } else if ( st_ivas->renderer_type != RENDERER_DISABLE ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 40f077c3c8..98b0672af3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -82,6 +82,9 @@ ivas_error ivas_jbm_dec_tc( AUDIO_CONFIG output_config; ivas_error error; float *p_output[MAX_TRANSPORT_CHANNELS]; +#ifdef VLBR_20MS_MD + int16_t num_md_sub_frames; +#endif error = IVAS_ERR_OK; @@ -259,7 +262,12 @@ ivas_error ivas_jbm_dec_tc( } ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -282,7 +290,17 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { +#ifdef VLBR_20MS_MD + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); +#else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); +#endif } else { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index d44d81d54e..78758be569 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1177,7 +1177,20 @@ void ivas_spar_param_to_masa_param_mapping( } else { + +#ifdef VLBR_20MS_MD + mixer_mat_index = ( ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) == 1 ) + ? 0 + : ( sf - SPAR_META_DELAY_SUBFRAMES ); +#else + mixer_mat_index = sf - SPAR_META_DELAY_SUBFRAMES; +#endif for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) { for ( i = 0; i < FOA_CHANNELS; i++ ) diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index a2d6d1502c..3e978a59b9 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -908,6 +908,60 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } if ( hQMetaData->no_directions == 2 ) { +#ifdef NONBE_FIX_539_MASA_384K_CHIRP + float ratioSum; + if ( bits_sph_idx == 16 ) + { + for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) + { + for ( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) + { + hQMetaData->q_direction[1].band_data[b].energy_ratio[m] = 1.0f - diffuseness_reconstructions_hr[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]]; + + /* Scale energy ratios that sum to over one */ + ratioSum = hQMetaData->q_direction[0].band_data[b].energy_ratio[m] + hQMetaData->q_direction[1].band_data[b].energy_ratio[m]; + + if ( ratioSum > 1.0f ) + { + hQMetaData->q_direction[0].band_data[b].energy_ratio[m] /= ratioSum; + hQMetaData->q_direction[1].band_data[b].energy_ratio[m] /= ratioSum; + } + } + } + } + else + { + int16_t pos_2dir_band[MASA_MAXIMUM_CODING_SUBBANDS]; + d = 0; + for ( b = hQMetaData->q_direction[0].cfg.start_band; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) + { + if ( hQMetaData->twoDirBands[b] == 1 ) + { + pos_2dir_band[d] = b; + d++; + } + else + { + pos_2dir_band[d] = 0; + } + } + for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) + { + for ( m = 0; m < hQMetaData->q_direction[1].cfg.nblocks; m++ ) + { + hQMetaData->q_direction[1].band_data[b].energy_ratio[m] = 1.0f - diffuseness_reconstructions_hr[hQMetaData->q_direction[1].band_data[b].energy_ratio_index[m]]; + + ratioSum = hQMetaData->q_direction[0].band_data[pos_2dir_band[b]].energy_ratio[m] + hQMetaData->q_direction[1].band_data[b].energy_ratio[m]; + + if ( ratioSum > 1.0f ) + { + hQMetaData->q_direction[0].band_data[pos_2dir_band[b]].energy_ratio[m] /= ratioSum; + hQMetaData->q_direction[1].band_data[b].energy_ratio[m] /= ratioSum; + } + } + } + } +#else #ifdef FIX_566_2DIR_MASA_384K float ratioSum; for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) @@ -938,6 +992,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } +#endif #endif } @@ -1085,7 +1140,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } - +#ifndef NONBE_FIX_539_MASA_384K_CHIRP /* Scale energy ratios that sum to over one */ for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { @@ -1101,6 +1156,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( } } } +#endif } #ifdef DEBUG_MODE_QMETADATA diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index cacb0621fc..fb97faf0de 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -110,6 +110,9 @@ ivas_error ivas_sba_dec_reconfigure( int16_t sba_dirac_stereo_flag_old; int32_t ivas_total_brate; int32_t last_ivas_total_brate; +#ifdef VLBR_20MS_MD + int16_t num_channels, num_md_sub_frames; +#endif RENDERER_TYPE old_renderer_type; @@ -181,6 +184,27 @@ ivas_error ivas_sba_dec_reconfigure( } } +#ifdef VLBR_20MS_MD + else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) + { + + num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; + + ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); + + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ); + if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, + num_md_sub_frames ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); } else diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 6c1649d087..f743f2072b 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -885,7 +885,12 @@ void ivas_sba_dirac_stereo_dec( ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 6f3dd13b7a..643c7b5a6c 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -578,6 +578,10 @@ void ivas_sba_mix_matrix_determiner( const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ +#ifdef VLBR_20MS_MD + , + const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ +#endif ) { int16_t i, ch; @@ -621,8 +625,13 @@ void ivas_sba_mix_matrix_determiner( /* Mixing matrix determiner */ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; +#ifdef VLBR_20MS_MD + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, + num_md_sub_frames ); +#else ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif return; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index cf5e2e11a2..79ed6c7cf3 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -114,7 +114,12 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate /* i : IVAS last active bitrate */ +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -725,7 +730,12 @@ static void ivas_spar_dec_MD( bfi = st_ivas->bfi; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; @@ -1200,7 +1210,12 @@ void ivas_spar_dec_set_render_params( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); ivas_spar_dec_set_render_map( st_ivas, n_cldfb_slots ); @@ -1431,9 +1446,12 @@ void ivas_spar_dec_upmixer_sf( num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - +#ifdef VLBR_20MS_MD + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ); +#else num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate ); - +#endif slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_idx_start = hSpar->slots_rendered; for ( i = 0; i < nchan_internal; i++ ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index a4ee09adc1..a1d3e98392 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -106,15 +106,21 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder * * Allocate and initialize SPAR MD decoder matrices *------------------------------------------------------------------------*/ - -static ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames /* i : number of MD subframes */ -) +#ifdef VLBR_20MS_MD +ivas_error ivas_spar_md_dec_matrix_open +#else +static ivas_error ivas_spar_md_dec_matrix_open +#endif + ( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels, /* i : number of internal channels */ + const int16_t num_md_sub_frames /* i : number of MD subframes */ + ) { int16_t i, j; - +#ifdef VLBR_20MS_MD + int16_t k; +#endif if ( ( hMdDec->spar_md.band_coeffs = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * num_md_sub_frames * sizeof( ivas_band_coeffs_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" ); @@ -251,7 +257,22 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } } +#ifdef VLBR_20MS_MD + for ( i = 0; i < num_channels; i++ ) + { + for ( j = 0; j < num_channels; j++ ) + { + for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_prev.C_re[i][j][k] = 0.0f; + hMdDec->spar_coeffs_prev.P_re[i][j][k] = 0.0f; + hMdDec->spar_coeffs_tar.C_re[i][j][k] = 0.0f; + hMdDec->spar_coeffs_tar.P_re[i][j][k] = 0.0f; + } + } + } +#endif return IVAS_ERR_OK; } @@ -266,6 +287,10 @@ static ivas_error ivas_spar_md_dec_matrix_open( int16_t ivas_get_spar_dec_md_num_subframes( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef VLBR_20MS_MD + , + const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ +#endif ) { int16_t num_subframes; @@ -279,6 +304,14 @@ int16_t ivas_get_spar_dec_md_num_subframes( } } +#ifdef VLBR_20MS_MD + if ( ( ivas_total_brate <= IVAS_SID_5k2 && ivas_last_active_brate < IVAS_24k4 ) || ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate < IVAS_24k4 ) ) + { + + num_subframes = 1; + } +#endif + return ( num_subframes ); } @@ -295,6 +328,10 @@ ivas_error ivas_spar_md_dec_open( const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ +#ifdef VLBR_20MS_MD + , + const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ +#endif ) { ivas_spar_md_dec_state_t *hMdDec; @@ -308,7 +345,12 @@ ivas_error ivas_spar_md_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD decoder" ); } - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + last_active_ivas_total_brate /* i : IVAS last active bitrate */ +#endif + ); if ( ( error = ivas_spar_md_dec_matrix_open( hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { @@ -346,11 +388,15 @@ ivas_error ivas_spar_md_dec_open( * * Deallocate SPAR MD decoder matrices *------------------------------------------------------------------------*/ - -static void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ -) +#ifdef VLBR_20MS_MD +void ivas_spar_md_dec_matrix_close +#else +static void ivas_spar_md_dec_matrix_close +#endif + ( + ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ + const int16_t num_channels /* i : number of internal channels */ + ) { int16_t i, j; @@ -493,7 +539,11 @@ ivas_error ivas_spar_md_dec_init( const int16_t sba_order /* i : SBA order */ ) { +#ifdef VLBR_20MS_MD + int16_t i, j; +#else int16_t i, j, k; +#endif int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; @@ -535,7 +585,7 @@ ivas_error ivas_spar_md_dec_init( set_s( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS ); hMdDec->spar_plc_num_lost_frames = 0; hMdDec->spar_plc_enable_fadeout_flag = 1; - +#ifndef VLBR_20MS_MD for ( i = 0; i < num_channels; i++ ) { for ( j = 0; j < num_channels; j++ ) @@ -579,7 +629,7 @@ ivas_error ivas_spar_md_dec_init( } } } - +#endif hMdDec->dtx_md_smoothing_cntr = 1; ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); @@ -701,7 +751,12 @@ void ivas_spar_md_dec_process( num_md_chs = ivas_sba_get_nchan_metadata( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ); ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, #ifndef FIX_280_PLANAR_CP @@ -3179,6 +3234,18 @@ void ivas_spar_to_dirac( } } +#ifdef VLBR_20MS_MD + int16_t num_md_sub_frames; + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, + end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); +#else + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; if ( st_ivas->hQMetaData->useLowerRes ) { @@ -3187,12 +3254,16 @@ void ivas_spar_to_dirac( ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_subframes, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); - +#endif if ( st_ivas->hQMetaData->useLowerRes && dtx_vad ) { for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ ) { +#ifdef VLBR_20MS_MD + for ( block = 1; block < num_md_sub_frames; block++ ) +#else for ( block = 1; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) +#endif { for ( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */ { @@ -3206,7 +3277,11 @@ void ivas_spar_to_dirac( } } /* expand DirAC TC 20ms MD for residual channels to all subframes*/ +#ifdef VLBR_20MS_MD + for ( block = 0; block < num_md_sub_frames; block++ ) +#else for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) +#endif { for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ ) { diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index de0c9196d4..122bbf2283 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -1558,6 +1558,70 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( if ( hQMetaData->no_directions == 2 ) { +#ifdef NONBE_FIX_539_MASA_384K_CHIRP + float ratioSum; + if ( bits_dir_hr == 16 ) + { + for ( j = hQMetaData->q_direction[1].cfg.start_band; j < hQMetaData->q_direction[1].cfg.nbands; j++ ) + { + for ( k = 0; k < hQMetaData->q_direction[1].cfg.nblocks; k++ ) + { + index = masa_sq( 1.0f - hQMetaData->q_direction[1].band_data[j].energy_ratio[k], diffuseness_thresholds_hr, HR_MASA_ER_LEVELS ); + push_next_indice( hMetaData, index, MASA_BITS_ER_HR ); + hQMetaData->q_direction[1].band_data[j].energy_ratio_index[k] = index; + hQMetaData->q_direction[1].band_data[j].energy_ratio[k] = 1.0f - diffuseness_reconstructions_hr[index]; + + ratioSum = hQMetaData->q_direction[0].band_data[j].energy_ratio[k] + hQMetaData->q_direction[1].band_data[j].energy_ratio[k]; + if ( ratioSum > 1.0f ) + { + hQMetaData->q_direction[0].band_data[j].energy_ratio[k] /= ratioSum; + hQMetaData->q_direction[1].band_data[j].energy_ratio[k] /= ratioSum; + } + + needed_bits[1] += MASA_BITS_ER_HR; + hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; + } + } + } + else + { + int16_t pos_2dir_band[MASA_MAXIMUM_CODING_SUBBANDS]; + k = 0; + for ( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; j++ ) + { + if ( hQMetaData->twoDirBands[j] == 1 ) + { + pos_2dir_band[k] = j; + k++; + } + else + { + pos_2dir_band[k] = 0; + } + } + for ( j = hQMetaData->q_direction[1].cfg.start_band; j < hQMetaData->q_direction[1].cfg.nbands; j++ ) + { + for ( k = 0; k < hQMetaData->q_direction[1].cfg.nblocks; k++ ) + { + index = masa_sq( 1.0f - hQMetaData->q_direction[1].band_data[j].energy_ratio[k], diffuseness_thresholds_hr, HR_MASA_ER_LEVELS ); + push_next_indice( hMetaData, index, MASA_BITS_ER_HR ); + hQMetaData->q_direction[1].band_data[j].energy_ratio_index[k] = index; + hQMetaData->q_direction[1].band_data[j].energy_ratio[k] = 1.0f - diffuseness_reconstructions_hr[index]; + + ratioSum = hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio[k] + hQMetaData->q_direction[1].band_data[j].energy_ratio[k]; + + if ( ratioSum > 1.0f ) + { + hQMetaData->q_direction[0].band_data[pos_2dir_band[j]].energy_ratio[k] /= ratioSum; + hQMetaData->q_direction[1].band_data[j].energy_ratio[k] /= ratioSum; + } + + needed_bits[1] += MASA_BITS_ER_HR; + hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; + } + } + } +#else #ifdef FIX_566_2DIR_MASA_384K float ratioSum; #endif @@ -1586,6 +1650,7 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( hQMetaData->q_direction[1].band_data[j].bits_sph_idx[k] = bits_dir_hr; } } +#endif } return; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 349fb4f60f..cbc57a3b7b 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -148,7 +148,11 @@ int16_t msvq_stage1_dct_search( for ( c2 = 0; c2 < cols_per_segment[segm]; c2++ ) { #define WMC_TOOL_SKIP +#ifdef FIX_612_MSVQ_UBSAN_LEFTSHIFT + tmp = dct_target[c2] - (float) shl( (Word16) cbpW8[c2], dct_col_shift_tab[c2] ); /* note: BASOP shift left defined for signed integers */ +#else tmp = dct_target[c2] - (float) ( ( (Word16) cbpW8[c2] ) << dct_col_shift_tab[c2] ); /* Word8 storage MSE inner loop */ +#endif LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ @@ -555,7 +559,15 @@ void msvq_enc( { /* Subtract codebook entry from residual vector of parent node */ p1 = resid[0] + parents[c] * N; - p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ +#ifdef FIX_621_MSVQ_UBSAN_NULL_PTR_OFFSET + p2 = NULL; + if ( cb_stage != NULL ) + { + p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ + } +#else + p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */ +#endif if ( s == 0 && applyDCT_flag != 0 ) { p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ); /*ptr init of stage 1 */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 5bc950dfd1..48916bf10e 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1071,10 +1071,13 @@ static ivas_error ivas_er_init( for ( i = 0; i < 3; i++ ) { reflections->user_origin[i] = 0.0f; + if ( i == 2 ) + { + reflections->user_origin[i] = ER_LIST_HEIGHT; + } } reflections->circ_buffers = NULL; - reflections->reflection_buffers = NULL; reflections->closest_ch_idx = NULL; ivas_shoebox_output_init( &reflections->shoebox_data ); @@ -1332,14 +1335,6 @@ ivas_error ivas_rend_openCrend( #ifdef EARLY_REFLECTIONS if ( hRendCfg->roomAcoustics.use_er == 1 ) { -#ifdef DEBUG_QC_ER - hRendCfg->roomAcoustics.dimensions.x = ER_DEFAULT_ROOM_L; - hRendCfg->roomAcoustics.dimensions.y = ER_DEFAULT_ROOM_W; - hRendCfg->roomAcoustics.dimensions.z = ER_DEFAULT_ROOM_H; - hRendCfg->roomAcoustics.ListenerOrigin.x = ER_LIST_ORIGIN_X; - hRendCfg->roomAcoustics.ListenerOrigin.y = ER_LIST_ORIGIN_Y; - hRendCfg->roomAcoustics.ListenerOrigin.z = ER_LIST_HEIGHT; -#endif /* Allocate memory for reflections */ hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); @@ -1353,7 +1348,7 @@ ivas_error ivas_rend_openCrend( /* Set sample rate and frame size */ hCrend->reflections->output_Fs = (float) output_Fs; - hCrend->reflections->max_frame_size = (int16_t)(output_Fs / FRAMES_PER_SEC); + hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ); /* Init Shoebox */ shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); @@ -1491,20 +1486,6 @@ void ivas_rend_closeCrend( hCrend->reflections->circ_buffers = NULL; } - if ( hCrend->reflections->reflection_buffers != NULL ) - { - for ( i = 0; i < hCrend->reflections->n_total_reflections; i++ ) - { - if ( hCrend->reflections->reflection_buffers[i] ) - { - free( hCrend->reflections->reflection_buffers[i] ); - hCrend->reflections->reflection_buffers[i] = NULL; - } - } - free( hCrend->reflections->reflection_buffers ); - hCrend->reflections->reflection_buffers = NULL; - } - free( hCrend->reflections ); hCrend->reflections = NULL; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 32bda7212f..bcf91ccc74 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -895,12 +895,6 @@ void shoebox_init( shoebox_config_t *cal ); -void shoebox_set_abscoeff( - shoebox_obj_t *obj, - int32_t surface_idx, - float coeff -); - void shoebox_set_scene ( shoebox_obj_t *obj, shoebox_output_t *ER_PARAMS, diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index e0428789f1..a254b9c90c 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -43,7 +43,6 @@ #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "ivas_er_utils.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #ifdef DEBUGGING @@ -51,8 +50,8 @@ #endif uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; -uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4}; -uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1}; +uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4 }; +uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1 }; uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; @@ -69,6 +68,7 @@ ivas_error er_init( { ivas_error error; IVAS_REND_AudioConfig outRendConfig; + uint8_t i; /* Set to defaults for shoebox */ reflections->is_ready = 0; @@ -80,6 +80,15 @@ ivas_error er_init( reflections->user_origin[1] = 0.0f; reflections->user_origin[2] = ER_LIST_HEIGHT; + /* Store scene origin if present */ + if ( reflections->shoebox_lib.cal.list_orig != NULL ) + { + for ( i = 0; i < 3; i++ ) + { + reflections->user_origin[i] = reflections->shoebox_lib.cal.list_orig[i]; + } + } + /* Init Shoebox */ shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); @@ -102,8 +111,8 @@ ivas_error er_init( } set_s( (int16_t *) reflections->closest_ch_idx, 0, reflections->n_total_reflections ); - outRendConfig = getRendAudioConfigFromIvasAudioConfig(reflections->mode); - if ( ( error = getAudioConfigNumChannels( outRendConfig, &( reflections->nchan_out ) ) ) != IVAS_ERR_OK) + outRendConfig = getRendAudioConfigFromIvasAudioConfig( reflections->mode ); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &( reflections->nchan_out ) ) ) != IVAS_ERR_OK ) { return error; } @@ -237,17 +246,18 @@ ivas_error er_encoder_init( { ivas_error error = IVAS_ERR_OK; uint16_t i, j, src_idx; + uint16_t min_index = 0; float p_x, p_y, p_z; float p_x_src, p_y_src, p_z_src; float tmp; - float dist, min_dist = 0, min_index = 0; + float dist, min_dist = 0; if ( !reflections ) { error = IVAS_ERR_FAILED_ALLOC; return error; } - + if ( getAudioConfigType( reflections->mode ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { /* Compute MC-snap location (closest channel position to reflection direction) */ @@ -295,7 +305,7 @@ ivas_error er_encoder_init( reflections->closest_ch_idx[i] = (uint16_t) min_index; } } - + return error; } @@ -325,7 +335,7 @@ ivas_error er_compute_reflections( /* Run shoebox with current reflection parameters */ shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), - reflections->user_origin, reflections->source_positions, + reflections->shoebox_lib.cal.list_orig, reflections->source_positions, reflections->is_cartesian, reflections->is_relative ); /* Convert reflection times in seconds to samples and keep track of max */ @@ -386,17 +396,8 @@ ivas_error er_compute_reflections( /* Initialize circular buffer insertion point */ reflections->circ_insert = reflections->circ_len - (uint16_t) reflections->max_frame_size; - /* Free stale reflection if previously allocated */ - if ( reflections->reflection_buffers ) - { - er_free_float_matrix( reflections->reflection_buffers, - reflections->n_total_reflections ); - } - /* Allocate reflection buffers */ + /* Get total reflections number */ reflections->n_total_reflections = reflections->shoebox_data.n_sources * reflections->shoebox_data.n_ref; - error = er_init_float_matrix( &( reflections->reflection_buffers ), - reflections->n_total_reflections, - (uint16_t) reflections->max_frame_size ); /* Check that reflection buffers were allocated */ if ( error != IVAS_ERR_OK ) @@ -443,7 +444,6 @@ ivas_error er_process( /* Ensure all reflection memory is allocated */ if ( !reflections->circ_buffers || - !reflections->reflection_buffers || !reflections->is_ready ) { return IVAS_ERR_INIT_ERROR; @@ -453,10 +453,10 @@ ivas_error er_process( n_ref = reflections->shoebox_data.n_ref; /* If low complexity ER are requested only compute ER for n_LC_sources */ - if (reflections->lowComplexity) + if ( reflections->lowComplexity ) { n_ref_sources = reflections->n_LC_sources; - } + } else { n_ref_sources = reflections->shoebox_data.n_sources; @@ -475,7 +475,7 @@ ivas_error er_process( /* Skip LFE from input buffer */ in_ch_idx = ( i >= LFE_CHANNEL ) ? i + 1 : i; samp_idx = reflections->circ_insert; - + /* If less than number of reflection sources, overwrite buffer */ if ( i == buf_ch_idx ) { @@ -483,7 +483,7 @@ ivas_error er_process( { buffer_ch[samp_idx++] = io[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; - } + } } /* Accumulate with buffer for low complexity mixed sources */ else @@ -518,12 +518,12 @@ ivas_error er_process( /* Determine start idx of reflection in circ buffer based on current insert idx and reflection delay */ samp_idx = (int) reflections->circ_insert - ref_delay; - if (samp_idx < 0 ) + if ( samp_idx < 0 ) { samp_idx = (int) reflections->circ_len + samp_idx; } - /* Pull reflection from circ buffer and apply gain, storing in reflection buffer */ + /* Pull reflection from circ buffer and apply gain */ for ( k = 0; k < subframe_size; k++ ) { io[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 6ff101bec5..b821521b68 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -52,7 +52,9 @@ #define FFT_SPECTRUM_SIZE ( 1 + ( RV_FILTER_MAX_FFT_SIZE / 2 ) ) #define N_INITIAL_IGNORED_FRAMES 4 -#define NUM_CLDFB_TAPES 7 +#ifndef UPDATE_REVERB_UTILS +#define NUM_CLDFB_TAPES 7 +#endif /*-----------------------------------------------------------------------------------------* * Local function prototypes @@ -225,7 +227,11 @@ static void get_IR_from_filter_taps( output_sample_idx = 0; /* Assign CLDFB taps */ +#ifdef UPDATE_REVERB_UTILS + if ( input_audio_config == AUDIO_CONFIG_HOA3 ) +#else if ( input_audio_config == AUDIO_CONFIG_FOA || input_audio_config == AUDIO_CONFIG_HOA2 || input_audio_config == AUDIO_CONFIG_HOA3 ) +#endif { for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) { @@ -235,6 +241,28 @@ static void get_IR_from_filter_taps( convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_HOA3[band_idx][hrtf_idx]; } } +#ifdef UPDATE_REVERB_UTILS + else if ( input_audio_config == AUDIO_CONFIG_HOA2 ) + { + for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) + { + convolver_state.filter_taps_left_re[band_idx] = hHrtfFastConv->leftHRIRReal_HOA2[band_idx][hrtf_idx]; + convolver_state.filter_taps_left_im[band_idx] = hHrtfFastConv->leftHRIRImag_HOA2[band_idx][hrtf_idx]; + convolver_state.filter_taps_right_re[band_idx] = hHrtfFastConv->rightHRIRReal_HOA2[band_idx][hrtf_idx]; + convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_HOA2[band_idx][hrtf_idx]; + } + } + else if ( input_audio_config == AUDIO_CONFIG_FOA ) + { + for ( band_idx = 0; band_idx < BINAURAL_CONVBANDS; band_idx++ ) + { + convolver_state.filter_taps_left_re[band_idx] = hHrtfFastConv->leftHRIRReal_FOA[band_idx][hrtf_idx]; + convolver_state.filter_taps_left_im[band_idx] = hHrtfFastConv->leftHRIRImag_FOA[band_idx][hrtf_idx]; + convolver_state.filter_taps_right_re[band_idx] = hHrtfFastConv->rightHRIRReal_FOA[band_idx][hrtf_idx]; + convolver_state.filter_taps_right_im[band_idx] = hHrtfFastConv->rightHRIRImag_FOA[band_idx][hrtf_idx]; + } + } +#endif else { array_idx = 0; @@ -313,7 +341,11 @@ static void get_IR_from_filter_taps( } } +#ifdef UPDATE_REVERB_UTILS + ivas_cldfb_convolver( &convolver_state, out_CLDFB_real, out_CLDFB_imag, real_buffer_in, imag_buffer_in, BINAURAL_CONVBANDS, BINAURAL_NTAPS ); +#else ivas_cldfb_convolver( &convolver_state, out_CLDFB_real, out_CLDFB_imag, real_buffer_in, imag_buffer_in, BINAURAL_CONVBANDS, NUM_CLDFB_TAPES ); +#endif ppRealBuf[0] = out_CLDFB_real[0]; ppImagBuf[0] = out_CLDFB_imag[0]; diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 0974677922..f4f627daab 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -67,6 +67,11 @@ void ivas_sba_prototype_renderer( int16_t out_ch, in_ch; int16_t firstInCh, inChEnd, firstOutCh, outChEnd; int16_t slot_idx_start, md_idx; +#ifdef VLBR_20MS_MD + int16_t num_md_sub_frames; + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ); +#endif push_wmops( "ivas_sba_prototype_renderer" ); @@ -148,6 +153,9 @@ void ivas_sba_prototype_renderer( { /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ int16_t md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME; +#ifdef VLBR_20MS_MD + md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? md_sf : 0; +#endif hSpar->i_subframe++; hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index b0adf65a96..e8bcb0b7ae 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -40,7 +40,6 @@ #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "prot.h" -#include "ivas_er_utils.h" #include "wmc_auto.h" /*-----------------------------------------------------------------------------------------* @@ -90,7 +89,7 @@ void shoebox_init( /* Add cal to obj struct */ obj->cal = *cal; /* Add defaults */ - obj->max_bands = ER_MAX_BANDS; + obj->max_bands = 1; obj->MAX_SOURCES = ER_MAX_SOURCES; obj->REF_ORDER = ER_REF_ORDER; @@ -104,12 +103,12 @@ void shoebox_init( } /* Pointer */ - obj->nSrc = 0.0f; // --> To update for ISM in future versions + obj->nSrc = 0.0f; /* Flags */ obj->isCartesian = 1; obj->isRelative = 1; - obj->isZHeight = ER_IS_Z_HEIGHT; + obj->isZHeight = 1; obj->isRadians = 1; /* Params */ @@ -119,26 +118,6 @@ void shoebox_init( obj->air_coeff = ER_AIR_COEFF; } -/*-----------------------------------------------------------------------------------------* - * Function shoebox_set_abscoeff - * - * Utility function to reassign the absorption coefficient of a target surface manually. - * The order convention for the surface index is [ front wall, back wall, left wall, - * right wall, ceiling, floor ]. - *-----------------------------------------------------------------------------------------*/ - -void shoebox_set_abscoeff( - shoebox_obj_t *obj, - int32_t surface_idx, - float coeff ) -{ - if ( ( coeff >= 0.0f ) && ( coeff <= 1.0f ) && ( surface_idx >= 0 ) && ( surface_idx <= 5 ) ) - { - obj->cal.abs_coeff[surface_idx] = coeff; - } -} - - /*-----------------------------------------------------------------------------------------* * Function shoebox_bound * @@ -220,14 +199,14 @@ static void shoebox_get_coord( int32_t n; tmp_size_idx_1 = 3; - if ( obj->isCartesian == 0.0f ) + if ( obj->isCartesian == 0 ) { - /* CONVERT SPHERICAL */ - if ( obj->isRadians == 0.0f ) + /* Convert Spherical to Cartesian */ + if ( obj->isRadians == 0 ) { for ( n = 0; n < loop_ub; n++ ) { - fcnOutput_data[n] = 0.0174532924F * src_pos_data[k + n]; + fcnOutput_data[n] = deg2rad( src_pos_data[k + n] ); } } tmp_data[2] = fcnOutput_data[2] * sinf( fcnOutput_data[1] ); @@ -287,14 +266,14 @@ static float shoebox_get_euclidian_distance_internal( float absxk, out_tmp, t; absxk = fabsf( obj->list_pos[0] - tmp_pos[0] ); - if ( absxk > 1.29246971E-26F ) + if ( absxk > ER_EUCLIDEAN_SCALE ) { out_tmp = 1.0f; *scale = absxk; } else { - t = absxk / 1.29246971E-26F; + t = absxk / ER_EUCLIDEAN_SCALE; out_tmp = t * t; } absxk = fabsf( obj->list_pos[1] - tmp_pos[1] ); @@ -405,14 +384,13 @@ void shoebox_set_scene( shoebox_bound( obj, tmp_pos ); - scale = 1.29246971E-26F; + scale = ER_EUCLIDEAN_SCALE; out_tmp = shoebox_get_euclidian_distance_internal( obj, tmp_pos, &scale ); obj->src_dist[( (int32_t) ( (float) ( ( (float) j ) + 1.0f ) ) ) - 1] = scale * sqrtf( out_tmp ); /* COMPUTE PATTERNS */ - /* NOTE: CONVERT INTO OWN FUNCTION */ /* SHOEBOX_COMPUTE: fills an input structure (4 array fields of length NxR ) with the */ /* Early reflection metadata (time of arrival, gain, az, el). */ @@ -451,7 +429,7 @@ void shoebox_set_scene( tmp_pos[coord] + ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); /* 0. Get euclidean distance from IMAGE SOURCE [N,W] to LIST */ - scale = 1.29246971E-26F; + scale = ER_EUCLIDEAN_SCALE; path_dist = shoebox_get_euclidian_distance_internal( obj, im_pos, &scale ); path_dist = scale * sqrtf( path_dist ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 5efc8ae118..e399b323e9 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -536,7 +536,7 @@ typedef struct ivas_roomAcoustics_t float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ #ifdef EARLY_REFLECTIONS int16_t use_er; /* ER activation flag */ - int16_t lowComplexity; /* Low complexity ER flag */ + int16_t lowComplexity; /* Low complexity ER flag */ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ float AbsCoeff[ER_ABS_COEFF]; /* Absorption coeffs */ IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ @@ -664,13 +664,13 @@ typedef struct uint16_t isRelative; uint16_t isZHeight; uint16_t isRadians; - float MAX_SOURCES; - float max_bands; - float REF_ORDER; + uint16_t MAX_SOURCES; + uint16_t max_bands; + uint16_t REF_ORDER; float src_pos[75]; float src_dist[25]; float list_pos[3]; - float nSrc; + uint16_t nSrc; float radius; float min_wall_dist; float soundspeed; @@ -723,7 +723,6 @@ typedef struct er_struct_t float source_positions[75]; float user_origin[3]; float *circ_buffers; - float **reflection_buffers; uint16_t *closest_ch_idx; shoebox_output_t shoebox_data; shoebox_obj_t shoebox_lib; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 614d578612..84ac3973ad 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -93,7 +93,7 @@ typedef enum _FREQ_GRID_MODE #ifdef EARLY_REFLECTIONS typedef struct { - uint16_t use_er; /* Activation Flag */ + uint16_t use_er; /* Activation Flag */ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ float pAbsCoeff[N_ABS_COEFFS]; /* Absorption coeffs table */ IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ @@ -1484,14 +1484,14 @@ static ivas_error RenderConfigReader_readBinary( /* Allocate memory for the frequency grids */ if ( nFG > 0 ) { - if ( pRenderConfigReader->nFG > 0 ) + for ( n = 0; n < pRenderConfigReader->nFG; n++ ) { - for ( n = 0; n < pRenderConfigReader->nFG; n++ ) - { - free( pRenderConfigReader->pFG[n].pFc ); - } - free( pRenderConfigReader->pFG ); + free( pRenderConfigReader->pFG[n].pFc ); } + free( pRenderConfigReader->pFG ); + + pRenderConfigReader->nFG = nFG; + if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; @@ -1501,7 +1501,6 @@ static ivas_error RenderConfigReader_readBinary( /* Initialize memory pointers to allow safe freeing ico errors */ pRenderConfigReader->pFG[n].pFc = NULL; } - pRenderConfigReader->nFG = nFG; } /* Loop through the frequency grids read from the binary stream */ @@ -1669,28 +1668,26 @@ static ivas_error RenderConfigReader_readBinary( /* Allocate memory for the acoustic environments array */ if ( nAE > 0 ) { - if ( pRenderConfigReader->nAE > 0 ) + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { - for ( n = 0; n < pRenderConfigReader->nAE; n++ ) - { - free( pRenderConfigReader->pAE[n].pRT60 ); - free( pRenderConfigReader->pAE[n].pDSR ); + free( pRenderConfigReader->pAE[n].pRT60 ); + free( pRenderConfigReader->pAE[n].pDSR ); #ifdef EARLY_REFLECTIONS - if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) - { - free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); - free( pRenderConfigReader->pAE[n].pEarlyReflections ); - } -#endif + if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) + { + free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); + free( pRenderConfigReader->pAE[n].pEarlyReflections ); } - free( pRenderConfigReader->pAE ); +#endif } + free( pRenderConfigReader->pAE ); + + pRenderConfigReader->nAE = nAE; if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } - pRenderConfigReader->nAE = nAE; /* Initialize memory pointers to allow safe freeing ico errors */ for ( n = 0; n < nAE; n++ ) { @@ -1848,7 +1845,7 @@ static ivas_error RenderConfigReader_readBinary( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = ER_LIST_ORIGIN_Y; pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = ER_LIST_HEIGHT; } - + /* Low complexity mode */ if ( ( error = read_bin_bool( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity ) ) != IVAS_ERR_OK ) { @@ -2063,21 +2060,23 @@ ivas_error RenderConfigReader_read( #endif } free( pRenderConfigReader->pAE ); + pRenderConfigReader->nAE = nAE; - } - /* Allocate memory for the acoustic environments array */ - if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Initialize memory pointers to allow for safe freeing */ - for ( acIdx = 0; acIdx < pRenderConfigReader->nAE; acIdx++ ) - { - pRenderConfigReader->pAE[acIdx].pRT60 = NULL; - pRenderConfigReader->pAE[acIdx].pDSR = NULL; + + /* Allocate memory for the acoustic environments array */ + if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Initialize memory pointers to allow for safe freeing */ + for ( acIdx = 0; acIdx < pRenderConfigReader->nAE; acIdx++ ) + { + pRenderConfigReader->pAE[acIdx].pRT60 = NULL; + pRenderConfigReader->pAE[acIdx].pDSR = NULL; #ifdef EARLY_REFLECTIONS - pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL; + pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL; #endif + } } acIdx = 0; roomAcHasAcEnvCount = TRUE; @@ -2536,6 +2535,10 @@ ivas_error RenderConfigReader_read( { return IVAS_ERR_INVALID_RENDER_CONFIG; } + else if ( aeHasERsize == TRUE && aeHasERabs == TRUE ) + { + pRenderConfigReader->pAE[acIdx].pEarlyReflections->use_er = 1; + } #endif free( pValue ); @@ -2881,9 +2884,20 @@ ivas_error RenderConfigReader_getAcousticEnvironment( #ifdef EARLY_REFLECTIONS if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) { - pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ + pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ pAcEnv->lowComplexity = pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity; /* Low complexity flag */ pAcEnv->dimensions = pRenderConfigReader->pAE[n].pEarlyReflections->dimensions; + /* Use default listener origin position if non provided */ + if ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin == NULL ) + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = ER_LIST_HEIGHT; + } pAcEnv->ListenerOrigin = *pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin; for ( j = 0; j < QC_ABS_COEFF; j++ ) { diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 077c93f114..16d2f67a8f 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -71,7 +71,7 @@ ivas_error RenderConfigReader_read( const char *pRenderConfigPath /* i : Renderer configuration file path */ #if ( defined SPLIT_REND_WITH_HEAD_ROT ) || ( defined DEBUGGING ) , - IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ + IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ #endif #else RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ diff --git a/scripts/reverb/generate_acoustic_environments_metadata.py b/scripts/reverb/generate_acoustic_environments_metadata.py index 70de0ea89c..955ad8819b 100644 --- a/scripts/reverb/generate_acoustic_environments_metadata.py +++ b/scripts/reverb/generate_acoustic_environments_metadata.py @@ -57,9 +57,13 @@ max_quantization_error = { def update_quantization_error(name, quantized_value, value): - max_quantization_error[name] = max(abs(quantized_value - value) / value, max_quantization_error[name]) - if print_quantized: - print(' {}: {}'.format(name, quantized_value)) + if value == 0: + if quantized_value != 0: + print(' {}: value = 0, quantized value = {}'.format(name, quantized_value)) + else: + max_quantization_error[name] = max(abs(quantized_value - value) / value, max_quantization_error[name]) + if print_quantized: + print(' {}: {}'.format(name, quantized_value)) def get_id_code(id): @@ -650,247 +654,245 @@ def generate_reverb_payload_equivalent_to_rend_config_recreation_cfg(): file.close() -def generate_reverb_payload_ERstrong_LISTon_DIRoff(): +def generate_reverb_payload_ER_v0(): # based on config_renderer.cfg # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values data = bitarray( '1' # hasAcEnv - + get_count_or_index_code(2) # fgdNrGrids - # frequency grid #1 + + get_count_or_index_code(1) # fgdNrGrids + # frequency grid + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(1) # fgdNrBands - - + concatenate(get_frequency_code, # fgdCenterFreq - [ 10000.0 ]) + + get_count_or_index_code(24) # fgdNrBands - # frequency grid #2 - + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(31) # fgdNrBands + + concatenate(get_frequency_code, # fgdCenterFreq + [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]) - + concatenate(get_frequency_code, # fgdCenterFreq - [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, - 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, - 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, - 20000.0 ]) - - + get_count_or_index_code(1) # AcousticEnvCount + + get_count_or_index_code(1) # AcousticEnvCount + get_id_code(0) # ID - + get_count_or_index_code(1) # FreqGridID + + get_count_or_index_code(0) # FreqGridID + get_duration_code(0.1) # (input)Predelay + concatenate(get_duration_code, # RT60 - [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2 ]) + [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]) + concatenate(get_dsr_code, # DSR - [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09 ]) + [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]) + '1' # hasEarlyReflections + concatenate(lambda code : get_distance_code(code, True), [ 2.0, 2.0, 3.0 ]) # room dimensions + concatenate(get_absorption_code, # absorptionCode - [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.2 ]) + [ 0.2, 0.1, 0.1, 0.1, 0.3, 0.1 ]) + '1' # listener origin flag + '1' # isPositiveX - + '0' # isPositiveY - + concatenate(lambda code : get_distance_code(code, True), - [ 2.0, 2.0, 3.0 ]) # origin + + '1' # isPositiveY + + concatenate(lambda d : get_distance_code(d, True), + [ 0.0, 0.0, 1.5 ]) # listener origin (x, y, z) + '1' # lowComplexity - - + '0' # hasDirectivity + + '0' # directivity , endian='big') - file = open('rend_config_ERstrong_LISTon_DIRoff.dat', 'wb') + file = open('rend_config_ER_v0.dat', 'wb') data.tofile(file) file.close() -def generate_reverb_payload_ERstrong_LISTon_DIRon(): + +def generate_reverb_payload_ER_v1(): # based on config_renderer.cfg # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values data = bitarray( '1' # hasAcEnv - + get_count_or_index_code(2) # fgdNrGrids - # frequency grid #1 + + get_count_or_index_code(1) # fgdNrGrids + # frequency grid + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(1) # fgdNrBands + + get_count_or_index_code(24) # fgdNrBands - + concatenate(get_frequency_code, # fgdCenterFreq - [ 10000.0 ]) + + concatenate(get_frequency_code, # fgdCenterFreq + [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]) - # frequency grid #2 - + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(31) # fgdNrBands - - + concatenate(get_frequency_code, # fgdCenterFreq - [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, - 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, - 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, - 20000.0 ]) - - + get_count_or_index_code(1) # AcousticEnvCount + + get_count_or_index_code(1) # AcousticEnvCount + get_id_code(0) # ID - + get_count_or_index_code(1) # FreqGridID + + get_count_or_index_code(0) # FreqGridID + get_duration_code(0.1) # (input)Predelay + concatenate(get_duration_code, # RT60 - [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2 ]) + [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]) + concatenate(get_dsr_code, # DSR - [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09 ]) + [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]) + '1' # hasEarlyReflections + concatenate(lambda code : get_distance_code(code, True), - [ 2.0, 2.0, 3.0 ]) # room dimensions + [ 3.0, 3.0, 4.0 ]) # room dimensions + concatenate(get_absorption_code, # absorptionCode - [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) - + '1' # listener origin flag - + '1' # isPositiveX - + '0' # isPositiveY - + concatenate(lambda d : get_distance_code(d, True), - [ 0.1, 0.1, 1.5]) # listener origin (x, y, z) - + '1' # lowComplexity - - + '1' # hasDirectivity + [ 0.3, 0.2, 0.2, 0.2, 0.3, 0.1 ]) + + '0' # listener origin flag + + '0' # lowComplexity + + '0' # directivity , endian='big') - file = open('rend_config_ERstrong_LISTon_DIRon.dat', 'wb') + file = open('rend_config_ER_v1.dat', 'wb') data.tofile(file) file.close() -def generate_reverb_payload_ERstrong_LISToff_DIRon(): +def generate_reverb_payload_ER_v2(): # based on config_renderer.cfg # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values data = bitarray( '1' # hasAcEnv - + get_count_or_index_code(2) # fgdNrGrids - # frequency grid #1 + + get_count_or_index_code(1) # fgdNrGrids + # frequency grid + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(1) # fgdNrBands + + get_count_or_index_code(24) # fgdNrBands - + concatenate(get_frequency_code, # fgdCenterFreq - [ 10000.0 ]) + + concatenate(get_frequency_code, # fgdCenterFreq + [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]) - # frequency grid #2 - + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(31) # fgdNrBands - - + concatenate(get_frequency_code, # fgdCenterFreq - [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, - 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, - 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, - 20000.0 ]) - - + get_count_or_index_code(1) # AcousticEnvCount + + get_count_or_index_code(1) # AcousticEnvCount + get_id_code(0) # ID - + get_count_or_index_code(1) # FreqGridID + + get_count_or_index_code(0) # FreqGridID + get_duration_code(0.1) # (input)Predelay + concatenate(get_duration_code, # RT60 - [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2 ]) + [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]) + concatenate(get_dsr_code, # DSR - [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09 ]) + [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]) + '1' # hasEarlyReflections + concatenate(lambda code : get_distance_code(code, True), - [ 2.0, 2.0, 3.0 ]) # room dimensions + [ 3.0, 3.0, 4.0 ]) # room dimensions + concatenate(get_absorption_code, # absorptionCode - [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) - + '0' - + '1' # lowComplexity - - + '1' # hasDirectivity + [ 0.3, 0.2, 0.3, 0.4, 0.3, 0.4 ]) + + '1' # listener origin flag + + '1' # isPositiveX + + '0' # isPositiveY + + concatenate(lambda d : get_distance_code(d, True), + [ 0.5, 0.5, 1.5]) # listener origin (x, y, z) + + '0' # lowComplexity + + '0' # directivity , endian='big') - file = open('rend_config_ERstrong_LISToff_DIRon.dat', 'wb') + file = open('rend_config_ER_v2.dat', 'wb') data.tofile(file) file.close() -def generate_reverb_payload_ERstrong_LISToff_DIRoff(): + +def generate_reverb_payload_ER_v3(): # based on config_renderer.cfg # note that because of encoding, resolution is lost and behaviour may not be bit-exact compared to .cfg file based values data = bitarray( '1' # hasAcEnv - + get_count_or_index_code(2) # fgdNrGrids - # frequency grid #1 + + get_count_or_index_code(1) # fgdNrGrids + # frequency grid + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(1) # fgdNrBands + + get_count_or_index_code(24) # fgdNrBands - + concatenate(get_frequency_code, # fgdCenterFreq - [ 10000.0 ]) + + concatenate(get_frequency_code, # fgdCenterFreq + [50.0, 63.0, 80.0, 100.0, + 125.0, 160.0, 200.0, 250.0, + 315.0, 400.0, 500.0, 630.0, + 800.0, 1000.0, 1250.0, 1600.0, + 2000.0, 2500.0, 3150.0, 4000.0, + 5000.0, 6300.0, 8000.0, 10000.0]) - # frequency grid #2 - + fgdMethod.Individual_Frequencies.value # fgdMethod - + get_count_or_index_code(31) # fgdNrBands - - + concatenate(get_frequency_code, # fgdCenterFreq - [ 20.0, 25.0, 31.5, 40.0, 50.0, 63.0, 80.0, 100.0, 125.0, 160.0, - 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, - 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0, 12500.0, 16000.0, - 20000.0 ]) - - + get_count_or_index_code(1) # AcousticEnvCount + + get_count_or_index_code(1) # AcousticEnvCount + get_id_code(0) # ID - + get_count_or_index_code(1) # FreqGridID + + get_count_or_index_code(0) # FreqGridID + get_duration_code(0.1) # (input)Predelay + concatenate(get_duration_code, # RT60 - [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, - 0.2 ]) + [0.87, 0.66, 0.47, 0.41, + 0.32, 0.37, 0.28, 0.30, + 0.29, 0.29, 0.28, 0.30, + 0.31, 0.34, 0.34, 0.34, + 0.34, 0.33, 0.32, 0.29, + 0.28, 0.24, 0.24, 0.2]) + concatenate(get_dsr_code, # DSR - [ 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, 2.6267e-09, - 2.6267e-09 ]) + [2.511887e-07, 1e-07, 1.2589251e-07, 1e-07, + 5.01187e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 6.309576e-08, 5.01187e-08, 7.9432844e-08, 1e-07, + 5.01187e-08, 1e-07, 7.9432844e-08, 6.309576e-08, + 7.9432844e-08, 5.01187e-08, 6.309576e-08, 3.9810708e-08, + 3.9810708e-08, 2.511887e-08, 1.9952632e-08, 1.2589251e-08]) + '1' # hasEarlyReflections + concatenate(lambda code : get_distance_code(code, True), - [ 2.0, 2.0, 3.0 ]) # room dimensions + [4.0, 4.0, 5.0]) # room dimensions + concatenate(get_absorption_code, # absorptionCode - [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]) - + '0' - + '0' # lowComplexity - - + '0' # hasDirectivity + [0.1, 0.2, 0.2, 0.2, 0.1, 0.1]) + + '1' # listener origin flag + + '0' # isPositiveX + + '1' # isPositiveY + + concatenate(lambda d : get_distance_code(d, True), + [ 1.0, 0.5, 1.5]) # listener origin (x, y, z) + + '1' # lowComplexity + + '0' # directivity , endian='big') - file = open('rend_config_ERstrong_LISToff_DIRoff.dat', 'wb') + file = open('rend_config_ER_v3.dat', 'wb') data.tofile(file) file.close() + if __name__ == "__main__": #test() #generate_reverb_payload_equivalent_to_rend_config_renderer_cfg() #generate_reverb_payload_equivalent_to_rend_config_hospital_patientroom_cfg() #generate_reverb_payload_equivalent_to_rend_config_recreation_cfg() - # generate_reverb_payload_small_ER_OFF() - # generate_reverb_payload_small_ER() + # generate_reverb_payload_aggressive_ER() - generate_reverb_payload_ERstrong_LISTon_DIRoff() - generate_reverb_payload_ERstrong_LISTon_DIRon() - generate_reverb_payload_ERstrong_LISToff_DIRon() - generate_reverb_payload_ERstrong_LISToff_DIRoff() + generate_reverb_payload_ER_v0() + generate_reverb_payload_ER_v1() + generate_reverb_payload_ER_v2() + generate_reverb_payload_ER_v3() - generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_no_listener_origin() - generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_listener_origin() \ No newline at end of file + # generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_no_listener_origin() + # generate_reverb_payload_equivalent_to_rend_config_renderer_cfg_plus_early_reflections_listener_origin() \ No newline at end of file -- GitLab From 83dca6d6470a375303c150f0ca3776483ef151be Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Fri, 28 Jul 2023 17:24:35 -0400 Subject: [PATCH 04/16] changed configuration files to comment out binary format, following email exchange on contribution 38 BE merge --- scripts/testv/rend_config_ER_v0.cfg | 4 ++-- scripts/testv/rend_config_ER_v1.cfg | 4 ++-- scripts/testv/rend_config_ER_v2.cfg | 4 ++-- scripts/testv/rend_config_ER_v3.cfg | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/testv/rend_config_ER_v0.cfg b/scripts/testv/rend_config_ER_v0.cfg index 7248cd428e..017a37f5c0 100644 --- a/scripts/testv/rend_config_ER_v0.cfg +++ b/scripts/testv/rend_config_ER_v0.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.2, 0.1, 0.1, 0.1, 0.3, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [ 0.0, 0.0, 1.5 ]; -[general] -binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file +# [general] +# binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v1.cfg b/scripts/testv/rend_config_ER_v1.cfg index 7d78f48505..06896ef814 100644 --- a/scripts/testv/rend_config_ER_v1.cfg +++ b/scripts/testv/rend_config_ER_v1.cfg @@ -33,5 +33,5 @@ earlyReflectionsSize = [3.0, 3.0, 4.0]; absorptionCoeffs = [ 0.3, 0.2, 0.2, 0.2, 0.3, 0.1 ]; lowComplexity = FALSE; -[general] -binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file +# [general] +# binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v2.cfg b/scripts/testv/rend_config_ER_v2.cfg index 1a50735708..e5cbc5b8ef 100644 --- a/scripts/testv/rend_config_ER_v2.cfg +++ b/scripts/testv/rend_config_ER_v2.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.3, 0.2, 0.3, 0.4, 0.3, 0.4 ]; lowComplexity = FALSE; listenerOrigin = [0.5, -0.5, 1.5]; -[general] -binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file +# [general] +# binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v3.cfg b/scripts/testv/rend_config_ER_v3.cfg index 7e7e14d7d3..12987522b0 100644 --- a/scripts/testv/rend_config_ER_v3.cfg +++ b/scripts/testv/rend_config_ER_v3.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.1, 0.2, 0.2, 0.2, 0.1, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [-1, 0.5, 1.5]; -[general] -binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file +# [general] +# binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file -- GitLab From 6e92cb7591ef981c61d2129b5a671f1bb5434c22 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Fri, 28 Jul 2023 18:35:30 -0400 Subject: [PATCH 05/16] resolved pointer warning --- lib_rend/ivas_reflections.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index a254b9c90c..70fa244eb0 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -81,12 +81,9 @@ ivas_error er_init( reflections->user_origin[2] = ER_LIST_HEIGHT; /* Store scene origin if present */ - if ( reflections->shoebox_lib.cal.list_orig != NULL ) + for ( i = 0; i < 3; i++ ) { - for ( i = 0; i < 3; i++ ) - { - reflections->user_origin[i] = reflections->shoebox_lib.cal.list_orig[i]; - } + reflections->user_origin[i] = reflections->shoebox_lib.cal.list_orig[i]; } /* Init Shoebox */ -- GitLab From 7f6eb74abcba61a0b3de9ed3652f014c0f22e11c Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Mon, 31 Jul 2023 14:28:31 -0400 Subject: [PATCH 06/16] fixed use_er initialization and warnings --- lib_rend/ivas_reflections.c | 2 +- lib_util/render_config_reader.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 70fa244eb0..5dcbf97767 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -255,7 +255,7 @@ ivas_error er_encoder_init( return error; } - if ( getAudioConfigType( reflections->mode ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + if (getAudioConfigType(getRendAudioConfigFromIvasAudioConfig(reflections->mode)) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { /* Compute MC-snap location (closest channel position to reflection direction) */ for ( i = 0; i < reflections->n_total_reflections; i++ ) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index e3b38e12ac..f73e025837 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2884,7 +2884,6 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; pAcEnv->inputPreDelay = pRenderConfigReader->pAE[n].preDelay; - for ( m = 0; m < pAcEnv->nBands; m++ ) { pAcEnv->pFc_input[m] = pRenderConfigReader->pAE[n].pFG->pFc[m]; @@ -2893,6 +2892,8 @@ ivas_error RenderConfigReader_getAcousticEnvironment( } #ifdef EARLY_REFLECTIONS + pAcEnv->use_er = 0; + /* If ER are allocated then propagate parameters */ if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) { pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ -- GitLab From aee445590838bf0d65412470c7385aaa8da43a66 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Mon, 31 Jul 2023 20:36:53 -0400 Subject: [PATCH 07/16] second attempt towards initialization error --- lib_dec/lib_dec.c | 1 + lib_rend/ivas_reflections.c | 2 +- lib_util/render_config_reader.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 48cca35a7e..6658aed5a7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1557,6 +1557,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.room_acoustics.inputPreDelay; #ifdef EARLY_REFLECTIONS + hRenderConfig->roomAcoustics.use_er = 0; if ( renderConfig.room_acoustics.use_er == 1 ) { hRenderConfig->roomAcoustics.use_er = renderConfig.room_acoustics.use_er; diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 5dcbf97767..2692d11b24 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -255,7 +255,7 @@ ivas_error er_encoder_init( return error; } - if (getAudioConfigType(getRendAudioConfigFromIvasAudioConfig(reflections->mode)) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + if ( getAudioConfigType( getRendAudioConfigFromIvasAudioConfig( reflections->mode ) ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { /* Compute MC-snap location (closest channel position to reflection direction) */ for ( i = 0; i < reflections->n_total_reflections; i++ ) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index f73e025837..3b04177b81 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2892,7 +2892,6 @@ ivas_error RenderConfigReader_getAcousticEnvironment( } #ifdef EARLY_REFLECTIONS - pAcEnv->use_er = 0; /* If ER are allocated then propagate parameters */ if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) { -- GitLab From 020dd44fabb5f9cc2fbba6c9c3d181c56d342d2e Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Mon, 31 Jul 2023 21:43:49 -0400 Subject: [PATCH 08/16] extended fix to lib_rend --- lib_rend/lib_rend.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ffe5404124..bc89c5d317 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4960,6 +4960,19 @@ int16_t IVAS_REND_FeedRenderConfig( mvr2r( renderConfig.room_acoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 ); +#ifdef EARLY_REFLECTIONS + hRenderConfig->roomAcoustics.use_er = 0; + if (renderConfig.room_acoustics.use_er == 1) + { + hRenderConfig->roomAcoustics.use_er = renderConfig.room_acoustics.use_er; + hRenderConfig->roomAcoustics.lowComplexity = renderConfig.room_acoustics.lowComplexity; + hRenderConfig->roomAcoustics.dimensions = renderConfig.room_acoustics.dimensions; + hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.room_acoustics.ListenerOrigin; + + mvr2r(renderConfig.room_acoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, ER_ABS_COEFF); + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT hRenderConfig->split_rend_config = renderConfig.split_rend_config; /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ -- GitLab From 5e8bc1b7cc9aefd4cb877e8f7b3b6f46603f5baf Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Mon, 31 Jul 2023 21:48:59 -0400 Subject: [PATCH 09/16] added getConfig ER params in lib_rend --- lib_rend/lib_rend.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index bc89c5d317..f82dd7bf51 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4902,6 +4902,11 @@ int16_t IVAS_REND_GetRenderConfig( hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; #endif +#ifdef EARLY_REFLECTIONS + hRCout->room_acoustics.use_er = hRCin->roomAcoustics.use_er; + hRCout->room_acoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; +#endif + return IVAS_ERR_OK; } @@ -4962,14 +4967,14 @@ int16_t IVAS_REND_FeedRenderConfig( #ifdef EARLY_REFLECTIONS hRenderConfig->roomAcoustics.use_er = 0; - if (renderConfig.room_acoustics.use_er == 1) + if ( renderConfig.room_acoustics.use_er == 1 ) { hRenderConfig->roomAcoustics.use_er = renderConfig.room_acoustics.use_er; hRenderConfig->roomAcoustics.lowComplexity = renderConfig.room_acoustics.lowComplexity; hRenderConfig->roomAcoustics.dimensions = renderConfig.room_acoustics.dimensions; hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.room_acoustics.ListenerOrigin; - mvr2r(renderConfig.room_acoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, ER_ABS_COEFF); + mvr2r( renderConfig.room_acoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, ER_ABS_COEFF ); } #endif @@ -8543,7 +8548,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, -- GitLab From bc26cc222c763f242eb66aeac3d05e1b46368556 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Tue, 1 Aug 2023 14:47:42 -0400 Subject: [PATCH 10/16] added initialization for when no config is specified --- lib_rend/ivas_render_config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 9bd86138e1..7f1648a614 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -49,6 +49,10 @@ #define IVAS_REVERB_DEFAULT_PRE_DELAY 0.016f #define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f +#ifdef EARLY_REFLECTIONS +#define IVAS_REVERB_DEFAULT_USE_ER 0 +#endif + /*-----------------------------------------------------------------------* * ivas_render_config_open() @@ -117,6 +121,9 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_INPUT_DELAY; +#ifdef EARLY_REFLECTIONS + ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; +#endif set_zero( &( *hRenderConfig )->roomAcoustics.pFc_input[0], CLDFB_NO_CHANNELS_MAX ); set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60[0], CLDFB_NO_CHANNELS_MAX ); set_zero( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr[0], CLDFB_NO_CHANNELS_MAX ); -- GitLab From 7baa8c2b58e7fd287abdb081587915d4120d8ff3 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Tue, 1 Aug 2023 19:31:14 -0400 Subject: [PATCH 11/16] testing lib_rend line reformat to match main --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f82dd7bf51..fb7f4062f3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8548,7 +8548,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, -- GitLab From d7d3ab21914d095800610fb386d9403ac6e22974 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Tue, 1 Aug 2023 19:50:03 -0400 Subject: [PATCH 12/16] removing head_rotation_file_reader files --- lib_util/head_rotation_file_reader.c | 37 --------------------------- lib_util/head_rotation_file_reader.h | 38 ---------------------------- 2 files changed, 75 deletions(-) delete mode 100644 lib_util/head_rotation_file_reader.c delete mode 100644 lib_util/head_rotation_file_reader.h diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c deleted file mode 100644 index c26a7b9156..0000000000 --- a/lib_util/head_rotation_file_reader.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include "head_rotation_file_reader.h" -#include -#include -#include -#include "prot.h" diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h deleted file mode 100644 index d4a2af84e7..0000000000 --- a/lib_util/head_rotation_file_reader.h +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef IVAS_HR_FILE_READER_H -#define IVAS_HR_FILE_READER_H - -#include "common_api_types.h" - -#endif /* IVAS_HR_FILE_READER_H */ -- GitLab From f4052f3883e32f34d642be8add7f91ee95ba2906 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Wed, 2 Aug 2023 19:24:14 -0400 Subject: [PATCH 13/16] clang formatting --- lib_util/render_config_reader.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 104c37c25e..6c6693c2b0 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1703,10 +1703,10 @@ static ivas_error RenderConfigReader_readBinary( free( pRenderConfigReader->pAE[n].pRT60 ); free( pRenderConfigReader->pAE[n].pDSR ); #ifdef EARLY_REFLECTIONS - if (pRenderConfigReader->pAE[n].pEarlyReflections != NULL) + if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) { - free(pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin); - free(pRenderConfigReader->pAE[n].pEarlyReflections); + free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); + free( pRenderConfigReader->pAE[n].pEarlyReflections ); } #endif } @@ -1790,13 +1790,13 @@ static ivas_error RenderConfigReader_readBinary( /*****************************************/ /* Has early reflections */ - if ((error = read_bin_bool(pRenderConfigReader, &value)) != IVAS_ERR_OK) + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) { return error; } - if (value == true) + if ( value == true ) { - if ((pRenderConfigReader->pAE[n].pEarlyReflections = (EarlyReflectionsConfig *)malloc(sizeof(EarlyReflectionsConfig))) == NULL) + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections = (EarlyReflectionsConfig *) malloc( sizeof( EarlyReflectionsConfig ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -1806,72 +1806,72 @@ static ivas_error RenderConfigReader_readBinary( pRenderConfigReader->pAE[n].pEarlyReflections->use_er = 1; /* Room sizes */ - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x ) ) != IVAS_ERR_OK ) { return error; } - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y ) ) != IVAS_ERR_OK ) { return error; } - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z ) ) != IVAS_ERR_OK ) { return error; } - for (k = 0; k < N_ABS_COEFFS; k++) + for ( k = 0; k < N_ABS_COEFFS; k++ ) { - if ((error = get_bin_absorption(pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[k])) != IVAS_ERR_OK) + if ( ( error = get_bin_absorption( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[k] ) ) != IVAS_ERR_OK ) { return error; } } /* Has listener origin */ - if ((error = read_bin_bool(pRenderConfigReader, &value)) != IVAS_ERR_OK) + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) { return error; } - if (value == true) + if ( value == true ) { - if ((pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc(sizeof(IVAS_VECTOR3))) == NULL) + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } - if ((error = read_bin_bits(pRenderConfigReader, &signx, 1)) != IVAS_ERR_OK) + if ( ( error = read_bin_bits( pRenderConfigReader, &signx, 1 ) ) != IVAS_ERR_OK ) { return error; } - if ((error = read_bin_bits(pRenderConfigReader, &signy, 1)) != IVAS_ERR_OK) + if ( ( error = read_bin_bits( pRenderConfigReader, &signy, 1 ) ) != IVAS_ERR_OK ) { return error; } - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x ) ) != IVAS_ERR_OK ) { return error; } - if (signx == 0) + if ( signx == 0 ) { pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x *= -1.0f; } - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y ) ) != IVAS_ERR_OK ) { return error; } - if (signy == 0) + if ( signy == 0 ) { pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y *= -1.0f; } - if ((error = get_bin_distance(pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z)) != IVAS_ERR_OK) + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z ) ) != IVAS_ERR_OK ) { return error; } } else /* load defaults if origin is not specified in config */ { - if ((pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc(sizeof(IVAS_VECTOR3))) == NULL) + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -1881,7 +1881,7 @@ static ivas_error RenderConfigReader_readBinary( } /* Low complexity mode */ - if ((error = read_bin_bool(pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity)) != IVAS_ERR_OK) + if ( ( error = read_bin_bool( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From b3be069506f418a875552fc69b184e9668c1992e Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Tue, 8 Aug 2023 15:47:20 -0400 Subject: [PATCH 14/16] updated test configs and self_test --- scripts/config/self_test.prm | 16 ++++++++++++++++ scripts/testv/rend_config_ER_v0.cfg | 4 ++-- scripts/testv/rend_config_ER_v1.cfg | 4 ++-- scripts/testv/rend_config_ER_v2.cfg | 4 ++-- scripts/testv/rend_config_ER_v3.cfg | 4 ++-- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 205ff96f18..810bbcff48 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1167,6 +1167,22 @@ ../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit ../IVAS_dec -render_config testv/rend_config_renderer.cfg BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_Config_renderer.tst +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections +../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit +../IVAS_dec -render_config testv/rend_config_ER_v1.cfg BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_ER_v1.tst + +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections, listener origin +../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit +../IVAS_dec -render_config testv/rend_config_ER_v2.cfg BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_ER_v2.tst + +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections, low complexity, listener origin +../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit +../IVAS_dec -render_config testv/rend_config_ER_v3.cfg BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_ER_v3.tst + +// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections, head rotation +../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit +../IVAS_dec -render_config testv/rend_config_ER_v1.cfg -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_ER_v1.tst + // Multi-channel 5_1 bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, 7_1_4 out ../IVAS_cod -mc 5_1 ../scripts/switchPaths/sw_mctech_5fr.bin 48 testv/stv51MC48c.wav bit ../IVAS_dec 7_1_4 48 bit testv/stv51MC48c.wav_sw_48-48_7_1_4.tst diff --git a/scripts/testv/rend_config_ER_v0.cfg b/scripts/testv/rend_config_ER_v0.cfg index 017a37f5c0..7248cd428e 100644 --- a/scripts/testv/rend_config_ER_v0.cfg +++ b/scripts/testv/rend_config_ER_v0.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.2, 0.1, 0.1, 0.1, 0.3, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [ 0.0, 0.0, 1.5 ]; -# [general] -# binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file +[general] +binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v1.cfg b/scripts/testv/rend_config_ER_v1.cfg index 06896ef814..7d78f48505 100644 --- a/scripts/testv/rend_config_ER_v1.cfg +++ b/scripts/testv/rend_config_ER_v1.cfg @@ -33,5 +33,5 @@ earlyReflectionsSize = [3.0, 3.0, 4.0]; absorptionCoeffs = [ 0.3, 0.2, 0.2, 0.2, 0.3, 0.1 ]; lowComplexity = FALSE; -# [general] -# binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file +[general] +binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v2.cfg b/scripts/testv/rend_config_ER_v2.cfg index e5cbc5b8ef..1a50735708 100644 --- a/scripts/testv/rend_config_ER_v2.cfg +++ b/scripts/testv/rend_config_ER_v2.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.3, 0.2, 0.3, 0.4, 0.3, 0.4 ]; lowComplexity = FALSE; listenerOrigin = [0.5, -0.5, 1.5]; -# [general] -# binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file +[general] +binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v3.cfg b/scripts/testv/rend_config_ER_v3.cfg index 12987522b0..7e7e14d7d3 100644 --- a/scripts/testv/rend_config_ER_v3.cfg +++ b/scripts/testv/rend_config_ER_v3.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.1, 0.2, 0.2, 0.2, 0.1, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [-1, 0.5, 1.5]; -# [general] -# binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file +[general] +binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file -- GitLab From 7a8c6e9c32a1b90e785e0ef5501f48b14012b5eb Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Wed, 9 Aug 2023 18:19:45 -0400 Subject: [PATCH 15/16] commented out .dat reference in ER config files --- scripts/testv/rend_config_ER_v0.cfg | 4 ++-- scripts/testv/rend_config_ER_v1.cfg | 4 ++-- scripts/testv/rend_config_ER_v2.cfg | 4 ++-- scripts/testv/rend_config_ER_v3.cfg | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/testv/rend_config_ER_v0.cfg b/scripts/testv/rend_config_ER_v0.cfg index 7248cd428e..1d3e6fa4f8 100644 --- a/scripts/testv/rend_config_ER_v0.cfg +++ b/scripts/testv/rend_config_ER_v0.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.2, 0.1, 0.1, 0.1, 0.3, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [ 0.0, 0.0, 1.5 ]; -[general] -binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file +#[general] +#binaryConfig = rend_config_ER_v0.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v1.cfg b/scripts/testv/rend_config_ER_v1.cfg index 7d78f48505..3a6228e863 100644 --- a/scripts/testv/rend_config_ER_v1.cfg +++ b/scripts/testv/rend_config_ER_v1.cfg @@ -33,5 +33,5 @@ earlyReflectionsSize = [3.0, 3.0, 4.0]; absorptionCoeffs = [ 0.3, 0.2, 0.2, 0.2, 0.3, 0.1 ]; lowComplexity = FALSE; -[general] -binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file +#[general] +#binaryConfig = rend_config_ER_v1.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v2.cfg b/scripts/testv/rend_config_ER_v2.cfg index 1a50735708..2d504af6ba 100644 --- a/scripts/testv/rend_config_ER_v2.cfg +++ b/scripts/testv/rend_config_ER_v2.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.3, 0.2, 0.3, 0.4, 0.3, 0.4 ]; lowComplexity = FALSE; listenerOrigin = [0.5, -0.5, 1.5]; -[general] -binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file +#[general] +#binaryConfig = rend_config_ER_v2.dat; \ No newline at end of file diff --git a/scripts/testv/rend_config_ER_v3.cfg b/scripts/testv/rend_config_ER_v3.cfg index 7e7e14d7d3..a70c644a8a 100644 --- a/scripts/testv/rend_config_ER_v3.cfg +++ b/scripts/testv/rend_config_ER_v3.cfg @@ -34,5 +34,5 @@ absorptionCoeffs = [ 0.1, 0.2, 0.2, 0.2, 0.1, 0.1 ]; lowComplexity = TRUE; listenerOrigin = [-1, 0.5, 1.5]; -[general] -binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file +#[general] +#binaryConfig = rend_config_ER_v3.dat; \ No newline at end of file -- GitLab From 811b4fbf0e4258653f4635a84601db1009f4a571 Mon Sep 17 00:00:00 2001 From: "Genovese, Andrea Felice" Date: Wed, 9 Aug 2023 19:16:20 -0400 Subject: [PATCH 16/16] fixed test case for rotation compatibility --- lib_rend/ivas_reflections.c | 9 +++++++++ scripts/config/self_test.prm | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 2692d11b24..bfeaf87ff0 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -223,6 +223,15 @@ ivas_error er_set_reflections_mode( reflections->source_positions[2 + ( 3 * ch )] = ER_RADIUS; } break; + case AUDIO_CONFIG_HOA3: + reflections->use_er = 0; + break; + case AUDIO_CONFIG_HOA2: + reflections->use_er = 0; + break; + case AUDIO_CONFIG_FOA: + reflections->use_er = 0; + break; default: reflections->mode = AUDIO_CONFIG_INVALID; return IVAS_ERROR( IVAS_ERR_INVALID_ER_PARAM, "Unsupported reflections mode" ); diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 810bbcff48..c6cca46962 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1179,9 +1179,9 @@ ../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit ../IVAS_dec -render_config testv/rend_config_ER_v3.cfg BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_ER_v3.tst -// Multi-channel 7_1_4 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections, head rotation -../IVAS_cod -mc 7_1_4 512000 48 testv/stv714MC48c.wav bit -../IVAS_dec -render_config testv/rend_config_ER_v1.cfg -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_REVERB 48 bit testv/stv714MC48c.wav_MC714_512000_48-48_MC_ER_v1.tst +// Multi-channel 5_1 at 512 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM out Config early reflections, head rotation +../IVAS_cod -mc 5_1 512000 48 testv/stv51MC48c.wav bit +../IVAS_dec -render_config testv/rend_config_ER_v1.cfg -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_REVERB 48 bit testv/stv51MC48c.wav_MC51_512000_48-48_MC_ER_v1_hrot.tst // Multi-channel 5_1 bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, 7_1_4 out ../IVAS_cod -mc 5_1 ../scripts/switchPaths/sw_mctech_5fr.bin 48 testv/stv51MC48c.wav bit -- GitLab