From 315a71fbea459db6ff1ff938cc1f87a419c15c9f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 24 Jan 2023 16:06:21 +0100 Subject: [PATCH 01/24] Added radius and orientation encoding to metadata under define TD5 --- Workspace_msvc/Workspace_msvc.sln | 10 - apps/decoder.c | 19 ++ apps/renderer.c | 5 + lib_com/common_api_types.h | 8 + lib_com/ivas_cnst.h | 11 + lib_com/ivas_ism_config.c | 6 + lib_com/ivas_prot.h | 15 + lib_com/ivas_rom_com.h | 4 +- lib_com/ivas_stat_com.h | 27 +- lib_com/options.h | 1 + lib_dec/ivas_ism_metadata_dec.c | 320 ++++++++++++++++- lib_dec/ivas_stat_dec.h | 6 + lib_dec/lib_dec.c | 24 +- lib_dec/lib_dec.h | 5 + lib_enc/ivas_ism_metadata_enc.c | 456 ++++++++++++++++++++++++- lib_enc/lib_enc.c | 6 +- lib_rend/ivas_lib_rend_internal.h | 3 + lib_rend/ivas_objectRenderer.c | 97 +++++- lib_rend/ivas_objectRenderer_hrFilt.c | 11 + lib_rend/ivas_objectRenderer_sfx.c | 11 +- lib_rend/ivas_objectRenderer_sources.c | 18 +- lib_rend/ivas_objectRenderer_vec.c | 24 +- lib_rend/ivas_render_config.c | 7 + lib_rend/ivas_stat_rend.h | 10 +- lib_util/head_rotation_file_reader.c | 25 +- lib_util/head_rotation_file_reader.h | 9 +- lib_util/ism_file_reader.c | 25 +- lib_util/ism_file_writer.c | 19 +- lib_util/render_config_reader.c | 9 + 29 files changed, 1144 insertions(+), 47 deletions(-) diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index 32f41bb6dd..169de8644d 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -25,8 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\.clang-format = ..\.clang-format EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ivas_crend_unit_test", "..\scripts\ivas_pytests\tests\unit_tests\crend\ivas_crend_unit_test.vcxproj", "{32354377-ACA7-40F9-9A0E-87FC956F0B78}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -118,14 +116,6 @@ Global {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Unittests|Win32.ActiveCfg = Unittests|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Unittests|Win32.Build.0 = Unittests|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Unittests|x64.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Debug|Win32.ActiveCfg = Debug|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Debug|x64.ActiveCfg = Debug|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Release|Win32.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Release|x64.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|Win32.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|Win32.Build.0 = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|x64.ActiveCfg = Release|Win32 - {32354377-ACA7-40F9-9A0E-87FC956F0B78}.Unittests|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/apps/decoder.c b/apps/decoder.c index 88f7322691..7288e40d06 100755 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -378,9 +378,17 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef TD5 + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL ) +#else if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) +#endif { +#ifdef TD5 + fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL and BINAURAL_ROOM. Exiting. \n\n" ); +#else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n\n" ); +#endif goto cleanup; } @@ -1262,6 +1270,9 @@ static ivas_error decodeG192( ivas_error error = IVAS_ERR_UNKNOWN; uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; +#ifdef TD5 + float Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES][3]; +#endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -1332,13 +1343,21 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef TD5 + if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, Pos ) ) != IVAS_ERR_OK ) +#else if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } +#ifdef TD5 + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, Pos ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/renderer.c b/apps/renderer.c index 8446b4ad99..ed7bb74616 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -892,7 +892,12 @@ int main( if ( headRotReader != NULL ) { IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#ifdef TD5 + float Pos[RENDERER_HEAD_POSITIONS_PER_FRAME][3]; + HeadRotationFileReading( headRotReader, quatBuffer, Pos ); +#else HeadRotationFileReading( headRotReader, quatBuffer, frame ); +#endif IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ); } else diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index b6d4a21c5d..7486bc271a 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -75,6 +75,11 @@ typedef struct _IVAS_ISM_METADATA float radius; float spread; float gainFactor; +#ifdef TD5 + /* Add azimuth/elevation for orientation here */ + float azimuth_orientation; /* azimuth orientation value */ + float elevation_orientation; /* elevation orientation value */ +#endif } IVAS_ISM_METADATA; typedef struct @@ -116,6 +121,9 @@ typedef struct _IVAS_RENDER_CONFIG IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics; +#ifdef TD5 + float directivity[3]; +#endif } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; typedef struct _IVAS_LS_CUSTOM_LAYOUT diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ceeb78b282..e869abdcab 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -321,6 +321,12 @@ typedef enum #define ISM_Q_STEP 2.5f #define ISM_Q_STEP_BORDER 5.0f +#ifdef TD5 +#define ISM_RADIUS_NBITS 6 +#define ISM_RADIUS_MIN 0.0f +#define ISM_RADIUS_DELTA 0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ +#endif // To do TD5 + /* Parametric ISM */ #define MAX_PARAM_ISM_NBANDS 11 #define MAX_PARAM_ISM_NBANDS_WB 9 @@ -355,7 +361,12 @@ enum IND_ISM_AZIMUTH = TAG_ISM_LOOP_START, IND_ISM_ELEVATION_DIFF_FLAG = TAG_ISM_LOOP_START, IND_ISM_ELEVATION = TAG_ISM_LOOP_START, +#ifdef TD5 + IND_ISM_RADIUS_DIFF_FLAG = TAG_ISM_LOOP_START, + IND_ISM_RADIUS = TAG_ISM_LOOP_START, +#endif // TD5 TAG_ISM_LOOP_END = TAG_ISM_LOOP_START + 100, /* IVAS_fmToDo: to be reviewed once the final metadata are defined */ + /* --------- end of loop for objects ----------- */ ISM_MAX_NUM_INDICES diff --git a/lib_com/ivas_ism_config.c b/lib_com/ivas_ism_config.c index a666c5594e..591b826f7a 100644 --- a/lib_com/ivas_ism_config.c +++ b/lib_com/ivas_ism_config.c @@ -329,6 +329,11 @@ void ivas_ism_reset_metadata( { hIsmMeta->azimuth = 0.0f; hIsmMeta->elevation = 0.0f; +#ifdef TD5 + hIsmMeta->azimuth_orientation = 0.0f; + hIsmMeta->elevation_orientation = 0.0f; + hIsmMeta->radius = 0.0f; +#endif // TD5 return; } @@ -459,6 +464,7 @@ void ivas_param_ism_config( hParamIsm->last_az_sgn[i] = 1; hParamIsm->last_el_diff[i] = 0; hParamIsm->last_el_sgn[i] = 1; + // To do TD5 ?? } return; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8b4d2b08ce..b9090dcb46 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -828,6 +828,12 @@ ivas_error set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* i/o: ISM metadata handle */ float azimuth, /* i : azimuth */ float elevation /* i : elevation */ +#ifdef TD5 + , + float radius_meta, /* i : radius */ + float azimuth_orientation, /* i : azimuth_orientation */ + float elevation_orientation /* i : elevation_orientation */ +#endif /* TD5 */ ); ivas_error create_ism_metadata_enc( @@ -5192,6 +5198,10 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem( const float *UpVec_p, /* i : Up vector */ const float *RightVec_p, /* i : Right vector */ float *MappedVec_p /* o : Transformed vector */ +#ifdef TD5 + , + float *LisRelPosAbs /* o : Transformed vector without orientation */ +#endif // TD5 ); /*! r: Flag if the orientation has been updated */ @@ -5257,7 +5267,12 @@ void TDREND_firfilt( const int16_t intp_count, /* i : interpolation count */ float *mem, /* i/o: filter memory */ const int16_t subframe_length, /* i : Length of signal */ +#ifdef TD5 + const int16_t filterlength, /* i : Filter length */ + const float Gain /* i : Gain */ +#else const int16_t filterlength /* i : Filter length */ +#endif ); /*----------------------------------------------------------------------------------* * Filter-bank (FB) Mixer diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 2b3755087c..0b8ba95028 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -318,7 +318,9 @@ extern const float McMASA_LFEGain_vectors[64]; extern const float ism_azimuth_borders[4]; extern const float ism_elevation_borders[4]; - +#ifdef TD5 +extern const float ism_radius_borders[4]; +#endif // TD5 /*----------------------------------------------------------------------------------* * Param ISM ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 79d29ea575..0629153f8e 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -43,7 +43,20 @@ /*----------------------------------------------------------------------------------* * Declaration of ISm common (encoder & decoder) structure *----------------------------------------------------------------------------------*/ - +#ifdef TD5 +typedef struct +{ + int16_t last_azimuth_idx; /* last frame index of coded azimuth */ + int16_t azimuth_diff_cnt; /* FEC counter of consecutive differentially azimuth coded frames */ + int16_t last_elevation_idx; /* last frame index of coded elevation */ + int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ +} ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE; +typedef struct +{ + int16_t last_radius_idx; /* last frame index of coded radius */ + int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ +} ISM_METADATA_RADIUS, *ISM_METADATA_RADIUS_HANDLE; +#endif /* ISM metadata handle (storage for one frame of read ISM metadata) */ typedef struct { @@ -52,12 +65,18 @@ typedef struct float azimuth; /* azimuth value read from the input metadata file */ float elevation; /* azimuth value read from the input metadata file */ - +#ifdef TD5 + float radius; + float azimuth_orientation; /* azimuth orientation value read from the input metadata file */ + float elevation_orientation; /* elevation orientation value read from the input metadata file */ + ISM_METADATA_ANGLE angle[2]; + ISM_METADATA_RADIUS radius_handle; /* radius value read from the input metadata file */ +#else int16_t last_azimuth_idx; /* last frame index of coded azimuth */ int16_t azimuth_diff_cnt; /* FEC counter of consecutive differentially azimuth coded frames */ int16_t last_elevation_idx; /* last frame index of coded elevation */ int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ - +#endif } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; @@ -145,7 +164,7 @@ typedef struct ivas_param_ism_data_structure int16_t flag_noisy_speech; int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE]; - + // To do TD5 ?? Radius, orientation } PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 1db2103272..32d84b05c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define LOW_RATE_TRANS_FIX /* Eri: Fix for critical item during transitions */ #define FIX_197_CREND_INTERFACE +#define TD5 /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 7a5731a286..e9cda9ec35 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -42,6 +42,14 @@ #endif #include "wmc_auto.h" +/* Local Functions */ +#ifdef TD5 +/*-----------------------------------------------------------------------* + * Local functions + *-----------------------------------------------------------------------*/ +static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, int16_t *flag_abs_azimuth ); +int16_t decode_radius( DEC_CORE_HANDLE st0, ISM_METADATA_RADIUS_HANDLE radius_handle, int16_t *flag_abs_radius ); +#endif /*-------------------------------------------------------------------------* * ivas_ism_metadata_dec() @@ -60,11 +68,24 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Config Handle */ ) { +#ifdef TD5 + int16_t ch, nb_bits_start = 0, last_bit_pos; + int16_t idx_radius; +#else int16_t ch, nb_bits_start = 0, last_bit_pos, sgn, diff; +#endif int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; DEC_CORE_HANDLE st0; +#ifdef TD5 + int16_t decode_orientation_radius_flag; + int16_t flag_abs_radius; + int16_t flag_abs_orientation; + int16_t idx_azimuth, flag_abs_azimuth; + int16_t idx_elevation; +#else int16_t idx_azimuth, nbits_diff_azimuth, flag_abs_azimuth; int16_t idx_elevation, nbits_diff_elevation; +#endif int16_t next_bit_pos_orig; uint16_t i, bstr_meta[MAX_BITS_METADATA], *bstr_orig; ISM_METADATA_HANDLE hIsmMetaData; @@ -105,7 +126,16 @@ ivas_error ivas_ism_metadata_dec( st0 = hSCE[0]->hCoreCoder[0]; ism_metadata_flag_global = 0; nchan_transport_prev = *nchan_transport; - +#ifdef TD5 + if ( ism_total_brate < IVAS_64k ) + { + decode_orientation_radius_flag = 0; + } + else + { + decode_orientation_radius_flag = 1; + } +#endif last_bit_pos = (int16_t) ( ( ism_total_brate / FRAMES_PER_SEC ) - 1 ); bstr_orig = st0->bit_stream; next_bit_pos_orig = st0->next_bit_pos; @@ -208,9 +238,47 @@ ivas_error ivas_ism_metadata_dec( } flag_abs_azimuth = 0; - +#ifdef TD5 + flag_abs_orientation = 0; + flag_abs_radius = 0; +#endif if ( hIsmMeta[ch]->ism_metadata_flag ) { + +#ifdef TD5 + decode_angle_indices( st0, &( hIsmMetaData->angle[0] ), &flag_abs_azimuth ); + idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx; + idx_elevation = hIsmMetaData->angle[0].last_elevation_idx; + + /* Azimuth/Elevation dequantization */ + if ( ism_mode == ISM_MODE_PARAM ) + { + hParamIsm->azi_index[ch] = idx_azimuth; + hParamIsm->ele_index[ch] = idx_elevation; + } + else /* ISM_MODE_DISC */ + { + hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + + if ( decode_orientation_radius_flag ) + { + decode_angle_indices( st0, &( hIsmMetaData->angle[1] ), &flag_abs_orientation ); + idx_azimuth = hIsmMetaData->angle[1].last_azimuth_idx; + idx_elevation = hIsmMetaData->angle[1].last_elevation_idx; + + hIsmMetaData->azimuth_orientation = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + hIsmMetaData->elevation_orientation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + + idx_radius = decode_radius( st0, &( hIsmMetaData->radius_handle ), &flag_abs_radius ); + hIsmMetaData->radius = usdequant( idx_radius, ISM_RADIUS_MIN, ISM_RADIUS_DELTA ); + } + else + { + hIsmMetaData->radius = 1.0f; + } + } +#else /*----------------------------------------------------------------* * Azimuth decoding and dequantization *----------------------------------------------------------------*/ @@ -254,8 +322,11 @@ ivas_error ivas_ism_metadata_dec( nbits_diff_azimuth++; } } - +#ifdef TD5 + idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx + sgn * diff; +#else idx_azimuth = hIsmMetaData->last_azimuth_idx + sgn * diff; +#endif } /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */ @@ -277,7 +348,11 @@ ivas_error ivas_ism_metadata_dec( /* sanity check in case of FER or BER */ if ( idx_azimuth < 0 || idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) { +#ifdef TD5 + idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx; +#else idx_azimuth = hIsmMetaData->last_azimuth_idx; +#endif } /* Azimuth dequantization */ @@ -333,13 +408,21 @@ ivas_error ivas_ism_metadata_dec( } } +#ifdef TD5 + idx_elevation = hIsmMetaData->angle[0].last_elevation_idx + sgn * diff; +#else idx_elevation = hIsmMetaData->last_elevation_idx + sgn * diff; +#endif } /* sanity check in case of FER or BER */ if ( idx_elevation < 0 || idx_elevation > ( 1 << ISM_ELEVATION_NBITS ) - 1 ) { +#ifdef TD5 + idx_elevation = hIsmMetaData->angle[0].last_elevation_idx; +#else idx_elevation = hIsmMetaData->last_elevation_idx; +#endif } /* Elevation dequantization */ @@ -357,17 +440,21 @@ ivas_error ivas_ism_metadata_dec( *----------------------------------------------------------------*/ /* updates */ +#ifdef TD5 + hIsmMetaData->angle[0].last_azimuth_idx = idx_azimuth; + hIsmMetaData->angle[0].last_elevation_idx = idx_elevation; +#else hIsmMetaData->last_azimuth_idx = idx_azimuth; hIsmMetaData->last_elevation_idx = idx_elevation; +#endif +#endif } - /* save number of metadata bits read */ if ( ism_mode == ISM_MODE_DISC ) { nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start; } } - if ( ism_mode == ISM_MODE_PARAM ) { hParamIsm->flag_noisy_speech = get_next_indice( st0, 1 ); @@ -443,8 +530,13 @@ ivas_error ivas_ism_metadata_dec( hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch] + hParamIsm->last_el_sgn[ch] * hParamIsm->last_el_diff[ch]; /*hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch] % hParamIsm->ele_alpha;*/ hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch]; +#ifdef TD5 + hIsmMeta[ch]->angle[0].last_azimuth_idx = hParamIsm->azi_index[ch]; + hIsmMeta[ch]->angle[0].last_elevation_idx = hParamIsm->ele_index[ch]; +#else hIsmMeta[ch]->last_azimuth_idx = hParamIsm->azi_index[ch]; hIsmMeta[ch]->last_elevation_idx = hParamIsm->ele_index[ch]; +#endif } } } @@ -456,7 +548,6 @@ ivas_error ivas_ism_metadata_dec( if ( !bfi ) { ivas_ism_config( ism_total_brate, *nchan_transport, num_obj, hIsmMeta, localVAD, ism_imp, element_brate, total_brate, nb_bits_metadata ); - for ( ch = 0; ch < *nchan_transport; ch++ ) { hIsmMeta[ch]->last_ism_metadata_flag = hIsmMeta[ch]->ism_metadata_flag; @@ -528,8 +619,14 @@ ivas_error create_ism_metadata_dec( } st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0; +#ifdef TD5 + st_ivas->hIsmMetaData[ch]->angle[0].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); + st_ivas->hIsmMetaData[ch]->angle[1].last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); +#else st_ivas->hIsmMetaData[ch]->last_azimuth_idx = 0; st_ivas->hIsmMetaData[ch]->last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); +#endif ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] ); } @@ -538,3 +635,214 @@ ivas_error create_ism_metadata_dec( return IVAS_ERR_OK; } + +#ifdef TD5 +static void decode_angle_indices( + DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + int16_t *flag_abs_azimuth /* o : Azimuth encoding mode */ +) +{ + /*----------------------------------------------------------------* + * Azimuth decoding and dequantization + *----------------------------------------------------------------*/ + int16_t idx_azimuth, nbits_diff_azimuth, diff, sgn; + int16_t idx_elevation, nbits_diff_elevation; + + /* Decode azimuth index */ + if ( get_next_indice( st0, 1 ) == 1 ) /* azimuth_abs_flag */ + { + idx_azimuth = get_next_indice( st0, ISM_AZIMUTH_NBITS ); + *flag_abs_azimuth = 1; + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_azimuth = 1; + } + else + { + nbits_diff_azimuth = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_azimuth++; + + /* read until the stop bit */ + while ( ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_azimuth++; + } + + if ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) + { + /* count stop bit */ + nbits_diff_azimuth++; + } + } + // idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx + sgn * diff; + idx_azimuth = angle->last_azimuth_idx + sgn * diff; + } + + /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */ + if ( idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + idx_azimuth -= ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* +180° -> -180° */ + } + else if ( idx_azimuth < 0 ) + { + idx_azimuth += ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* -180° -> +180° */ + } + + /* +180° == -180° */ + if ( idx_azimuth == ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + idx_azimuth = 0; + } + + /* sanity check in case of FER or BER */ + if ( idx_azimuth < 0 || idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + // idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx; + idx_azimuth = angle->last_azimuth_idx; + } + + /*----------------------------------------------------------------* + * Elevation decoding and dequantization + *----------------------------------------------------------------*/ + + /* Decode elevation index */ + if ( *flag_abs_azimuth == 0 && get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */ + { + idx_elevation = get_next_indice( st0, ISM_ELEVATION_NBITS ); + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_elevation = 1; + } + else + { + nbits_diff_elevation = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_elevation++; + + /* read until the stop bit */ + while ( ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_elevation++; + } + + if ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) + { + /* count stop bit */ + nbits_diff_elevation++; + } + } + + idx_elevation = angle->last_elevation_idx + sgn * diff; + } + + /* sanity check in case of FER or BER */ + if ( idx_elevation < 0 || idx_elevation > ( 1 << ISM_ELEVATION_NBITS ) - 1 ) + { + // idx_elevation = hIsmMetaData->angle[0].last_elevation_idx; + idx_elevation = angle->last_elevation_idx; + } + /*----------------------------------------------------------------* + * Final updates + *----------------------------------------------------------------*/ + + /* updates */ + angle->last_azimuth_idx = idx_azimuth; + angle->last_elevation_idx = idx_elevation; + return; +} + +int16_t decode_radius( + DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + ISM_METADATA_RADIUS_HANDLE radius_handle, /* i/o: radius handle */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ +) +{ + /*----------------------------------------------------------------* + * Radius decoding and dequantization + *----------------------------------------------------------------*/ + int16_t idx_radius, nbits_diff_radius, diff, sgn; + + + /* Decode radius index */ + if ( get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */ + { + *flag_abs_radius = 1; + idx_radius = get_next_indice( st0, ISM_RADIUS_NBITS ); + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_radius = 1; + } + else + { + nbits_diff_radius = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_radius++; + + /* read until the stop bit */ + while ( ( nbits_diff_radius < ISM_RADIUS_NBITS ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_radius++; + } + + if ( nbits_diff_radius < ISM_RADIUS_NBITS ) + { + /* count stop bit */ + nbits_diff_radius++; + } + } + idx_radius = radius_handle->last_radius_idx + sgn * diff; + } + + /* sanity check in case of FER or BER */ + if ( idx_radius < 0 || idx_radius > ( 1 << ISM_RADIUS_NBITS ) - 1 ) + { + idx_radius = radius_handle->last_radius_idx; + } + + /*----------------------------------------------------------------* + * Final updates + *----------------------------------------------------------------*/ + + /* updates */ + radius_handle->last_radius_idx = idx_radius; + return idx_radius; +} +#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4fceaf79f6..2a0fdc1d61 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1312,6 +1312,9 @@ typedef struct ivas_binaural_head_track_struct { int16_t num_quaternions; IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef TD5 + float Pos[MAX_PARAM_SPATIAL_SUBFRAMES][3]; +#endif float Rmat[3][3]; float Rmat_prev[3][3]; @@ -1622,6 +1625,9 @@ typedef struct ivas_render_config_t ivas_renderTypeOverride renderer_type_override; #endif ivas_roomAcoustics_t roomAcoustics; +#ifdef TD5 + float directivity[3]; // Todo: Replace with constant +#endif } RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 13a5d96953..727aded955 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -844,7 +844,13 @@ ivas_error IVAS_DEC_GetObjectMetadata( { metadata->azimuth = hIsmMeta->azimuth; metadata->elevation = hIsmMeta->elevation; +#ifdef TD5 + metadata->radius = hIsmMeta->radius; + metadata->azimuth_orientation = hIsmMeta->azimuth_orientation; + metadata->elevation_orientation = hIsmMeta->elevation_orientation; +#else metadata->radius = 0.f; +#endif // TD5 metadata->spread = 0.f; metadata->gainFactor = 1.f; } @@ -886,8 +892,13 @@ ivas_error IVAS_DEC_GetMasaMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifdef TD5 + IVAS_QUATERNION *orientation, /* i : listener orientation */ + float Pos[4][3] /* i : listener position */ +#else IVAS_QUATERNION *orientation /* i : head-tracking data */ +#endif ) { HEAD_TRACK_DATA_HANDLE hHeadTrackData; @@ -912,6 +923,11 @@ ivas_error IVAS_DEC_FeedHeadTrackData( hHeadTrackData->Quaternions[i].x = orientation[i].x; hHeadTrackData->Quaternions[i].y = orientation[i].y; hHeadTrackData->Quaternions[i].z = orientation[i].z; +#ifdef TD5 + hHeadTrackData->Pos[i][0] = Pos[i][0]; + hHeadTrackData->Pos[i][1] = Pos[i][1]; + hHeadTrackData->Pos[i][2] = Pos[i][2]; +#endif } hIvasDec->st_ivas->hHeadTrackData->num_quaternions = 0; @@ -1039,6 +1055,9 @@ ivas_error IVAS_DEC_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->room_acoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->room_acoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->room_acoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef TD5 + mvr2r( hRCin->directivity, hRCout->directivity, 3 ); +#endif return IVAS_ERR_OK; } @@ -1083,6 +1102,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( 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 ); +#ifdef TD5 + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 ); +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 1af44bb43f..4999e93eb8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -177,7 +177,12 @@ ivas_error IVAS_DEC_GetMasaMetadata( /*! r: error code */ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifdef TD5 + IVAS_QUATERNION *orientation, /* i : listener orientation */ + float Pos[4][3] /* i : listener position */ +#else IVAS_QUATERNION *orientation /* i : head-tracking data */ +#endif ); /*! r: error code */ diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index efec918914..3e6a6cbe43 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -53,11 +53,22 @@ #define ISM_MAX_AZIMUTH_DIFF_IDX ( ISM_AZIMUTH_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_MAX_ELEVATION_DIFF_IDX ( ISM_ELEVATION_NBITS - 1 /*zero*/ - 1 /*sign*/ ) +#ifdef TD5 +#define ISM_MAX_RADIUS_DIFF_IDX ( ISM_RADIUS_NBITS - 1 /*zero*/ - 1 /*sign*/ ) +#endif // TD5 #define ISM_FEC_MAX 10 #define INTER_OBJECT_PARAM_CHECK ( ( ISM_FEC_MAX / 2 ) - 2 ) /* note: constant must be less than (ISM_FEC_MAX / number of coded parameters) */ +#ifdef TD5 +/*-----------------------------------------------------------------------* + * Local functions + *-----------------------------------------------------------------------*/ +static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const int16_t last_ism_metadata_flag, const int16_t ini_frame, const int16_t idx_azimuth_abs, const int16_t idx_elevation_abs, int16_t *flag_abs_azimuth, int16_t *flag_abs_elevation ); +static void encode_radius( BSTR_ENC_HANDLE hBstr, ISM_METADATA_RADIUS_HANDLE radius_handle, const int16_t last_ism_metadata_flag, const int16_t idx_radius_abs, int16_t *flag_abs_radius ); + +#endif /*-------------------------------------------------------------------------* * set_ism_metadata() @@ -69,7 +80,14 @@ ivas_error set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, float azimuth, - float elevation ) + float elevation +#ifdef TD5 + , + float radius_meta, + float azimuth_orientation, + float elevation_orientation +#endif /* TD5 */ +) { if ( hIsmMeta == NULL ) { @@ -81,7 +99,12 @@ ivas_error set_ism_metadata( /* save read metadata parameters to the internal codec structure */ hIsmMeta->azimuth = azimuth; hIsmMeta->elevation = elevation; - + /* TD5 azimuth_orientation, elevation_orientation*/ +#ifdef TD5 + hIsmMeta->radius = radius_meta; + hIsmMeta->azimuth_orientation = azimuth_orientation; + hIsmMeta->elevation_orientation = elevation_orientation; +#endif /* TD5 */ return IVAS_ERR_OK; } @@ -157,8 +180,16 @@ ivas_error ivas_ism_metadata_enc( ) { int16_t i, ch, nb_bits_start = 0, diff; +#ifdef TD5 + int16_t idx_azimuth_abs = 0, flag_abs_azimuth[MAX_NUM_OBJECTS]; + int16_t idx_elevation_abs = 0, flag_abs_elevation[MAX_NUM_OBJECTS]; + int16_t flag_abs_azimuth_orientation[MAX_NUM_OBJECTS]; + int16_t idx_radius_abs = 0, flag_abs_radius[MAX_NUM_OBJECTS]; + int16_t encode_orientation_radius_flag; +#else int16_t idx_azimuth, idx_azimuth_abs = 0, flag_abs_azimuth[MAX_NUM_OBJECTS], nbits_diff_azimuth; int16_t idx_elevation, idx_elevation_abs = 0, flag_abs_elevation[MAX_NUM_OBJECTS], nbits_diff_elevation; +#endif float valQ; ISM_METADATA_HANDLE hIsmMetaData; int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; @@ -197,6 +228,19 @@ ivas_error ivas_ism_metadata_enc( set_s( nb_bits_metadata, 0, nchan_transport ); set_s( flag_abs_azimuth, 0, num_obj ); set_s( flag_abs_elevation, 0, num_obj ); +#ifdef TD5 + if ( ism_total_brate < IVAS_64k ) + { + encode_orientation_radius_flag = 0; + } + else + { + encode_orientation_radius_flag = 1; + } + set_s( flag_abs_azimuth_orientation, 0, num_obj ); + set_s( flag_abs_radius, 0, num_obj ); +#endif + /*----------------------------------------------------------------* * Set Metadata presence / importance flag @@ -215,8 +259,18 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { /* send metadata even in inactive segments when noise is audible and metadata are changing */ +#ifdef TD5 + diff = (int16_t) fabsf( hIsmMeta[ch]->azimuth - ism_dequant_meta( hIsmMeta[ch]->angle[0].last_azimuth_idx, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ) ); + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->elevation - ism_dequant_meta( hIsmMeta[ch]->angle[0].last_elevation_idx, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ) ) ); + if ( encode_orientation_radius_flag ) + { + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->azimuth_orientation - ism_dequant_meta( hIsmMeta[ch]->angle[1].last_azimuth_idx, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ) ) ); + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->elevation_orientation - ism_dequant_meta( hIsmMeta[ch]->angle[1].last_elevation_idx, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ) ) ); + } +#else diff = (int16_t) fabsf( hIsmMeta[ch]->azimuth - ism_dequant_meta( hIsmMeta[ch]->last_azimuth_idx, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ) ); diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->elevation - ism_dequant_meta( hIsmMeta[ch]->last_elevation_idx, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ) ) ); +#endif if ( hSCE[ch]->hCoreCoder[0]->lp_noise > 15 && diff >= 10 ) { @@ -317,6 +371,39 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag ) { + +#ifdef TD5 + /*----------------------------------------------------------------* + * Obtain quantizer indices for azimuth and elevation + *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_DISC ) + { + idx_azimuth_abs = ism_quant_meta( hIsmMetaData->azimuth, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + idx_elevation_abs = ism_quant_meta( hIsmMetaData->elevation, &valQ, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + } + else /* ISM_MODE_PARAM */ + { + idx_azimuth_abs = hParamIsm->azi_index[ch]; + idx_elevation_abs = hParamIsm->ele_index[ch]; + } + + encode_angle_indices( hBstr, &( hIsmMetaData->angle[0] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); + + /* Encode orientation and radius, if above certain bit rate etc, discrete ISM */ + if ( ism_mode == ISM_MODE_DISC && encode_orientation_radius_flag ) + { + idx_azimuth_abs = ism_quant_meta( hIsmMetaData->azimuth_orientation, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + idx_elevation_abs = ism_quant_meta( hIsmMetaData->elevation_orientation, &valQ, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_RADIUS_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS ); + encode_angle_indices( hBstr, &( hIsmMetaData->angle[1] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth_orientation[ch], &flag_abs_elevation[ch] ); + encode_radius( hBstr, &( hIsmMetaData->radius_handle ), hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] ); + } + /* save number of metadata bits written */ + if ( ism_mode == ISM_MODE_DISC ) + { + nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; + } +#else /*----------------------------------------------------------------* * Azimuth quantization and encoding *----------------------------------------------------------------*/ @@ -561,6 +648,7 @@ ivas_error ivas_ism_metadata_enc( { nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; } +#endif } } @@ -621,12 +709,20 @@ ivas_error ivas_ism_metadata_enc( if ( abs_next % ISM_NUM_PARAM == 0 ) { +#ifdef TD5 + hIsmMeta[ch]->angle[0].azimuth_diff_cnt = abs_num - 1; +#else hIsmMeta[ch]->azimuth_diff_cnt = abs_num - 1; +#endif } if ( abs_next % ISM_NUM_PARAM == 1 ) { +#ifdef TD5 + hIsmMeta[ch]->angle[0].elevation_diff_cnt = abs_num - 1; +#else hIsmMeta[ch]->elevation_diff_cnt = abs_num - 1; +#endif /*hIsmMeta[ch]->elevation_diff_cnt = min( hIsmMeta[ch]->elevation_diff_cnt, ISM_FEC_MAX );*/ } @@ -757,10 +853,24 @@ ivas_error create_ism_metadata_enc( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) ); } +#ifdef TD5 + st_ivas->hIsmMetaData[ch]->angle[0].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].azimuth_diff_cnt = ISM_FEC_MAX; + st_ivas->hIsmMetaData[ch]->angle[0].last_elevation_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].elevation_diff_cnt = ISM_FEC_MAX - 1; + st_ivas->hIsmMetaData[ch]->radius_handle.last_radius_idx = 0; + st_ivas->hIsmMetaData[ch]->radius_handle.radius_diff_cnt = ISM_FEC_MAX - 2; + // To do TD5 --- + st_ivas->hIsmMetaData[ch]->angle[1].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[1].azimuth_diff_cnt = ISM_FEC_MAX - 2; + st_ivas->hIsmMetaData[ch]->angle[1].last_elevation_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[1].elevation_diff_cnt = ISM_FEC_MAX - 2; +#else st_ivas->hIsmMetaData[ch]->last_azimuth_idx = 0; st_ivas->hIsmMetaData[ch]->azimuth_diff_cnt = ISM_FEC_MAX; st_ivas->hIsmMetaData[ch]->last_elevation_idx = 0; st_ivas->hIsmMetaData[ch]->elevation_diff_cnt = ISM_FEC_MAX - 1; +#endif st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0; ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] ); @@ -770,3 +880,345 @@ ivas_error create_ism_metadata_enc( return IVAS_ERR_OK; } + +#ifdef TD5 +static void encode_radius( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + ISM_METADATA_RADIUS_HANDLE radius_handle, /* i/o: radius handle */ + const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ + const int16_t idx_radius_abs, /* i : Azimuth index */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ +) +{ + int16_t idx_radius, nbits_diff_radius, diff; + + + /*----------------------------------------------------------------* + * Radius index encoding + *----------------------------------------------------------------*/ + idx_radius = idx_radius_abs; + + nbits_diff_radius = 0; + + *flag_abs_radius = 0; /* differential coding by default */ + + if ( radius_handle->radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_radius = 1; + } + + diff = idx_radius_abs - radius_handle->last_radius_idx; + + /* try differential coding */ + if ( *flag_abs_radius == 0 ) + { + if ( diff == 0 ) + { + idx_radius = 0; + nbits_diff_radius = 1; + } + else if ( ABSVAL( diff ) <= ISM_MAX_RADIUS_DIFF_IDX ) + { + idx_radius = 1 << 1; + nbits_diff_radius = 1; + + if ( diff < 0 ) + { + idx_radius += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_radius += 0; /* positive sign */ + } + + idx_radius = idx_radius << diff; + nbits_diff_radius++; + + /* unary coding of "diff */ + idx_radius += ( ( 1 << diff ) - 1 ); + nbits_diff_radius += diff; + + if ( nbits_diff_radius < ISM_RADIUS_NBITS ) + { + /* add stop bit */ + idx_radius = idx_radius << 1; + nbits_diff_radius++; + } + } + else + { + *flag_abs_radius = 1; + } + } + + /* update counter */ + if ( *flag_abs_radius == 0 ) + { + radius_handle->radius_diff_cnt++; + radius_handle->radius_diff_cnt = min( radius_handle->radius_diff_cnt, ISM_FEC_MAX ); + } + else + { + radius_handle->radius_diff_cnt = 0; + } + + /* Write radius */ + push_indice( hBstr, IND_ISM_RADIUS_DIFF_FLAG, *flag_abs_radius, 1 ); + + if ( *flag_abs_radius ) + { + push_indice( hBstr, IND_ISM_RADIUS, idx_radius, ISM_RADIUS_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_RADIUS, idx_radius, nbits_diff_radius ); + } + + /*----------------------------------------------------------------* + * Updates + *----------------------------------------------------------------*/ + radius_handle->last_radius_idx = idx_radius_abs; + return; +} + +static void encode_angle_indices( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ + const int16_t ini_frame, /* i : initialization frames counter */ + const int16_t idx_azimuth_abs, /* i : Azimuth index */ + const int16_t idx_elevation_abs, /* i : Elevation index */ + int16_t *flag_abs_azimuth, /* o : Azimuth encoding mode */ + int16_t *flag_abs_elevation /* o : Elevation encoding mode */ +) +{ + int16_t idx_azimuth, nbits_diff_azimuth, diff; + int16_t idx_elevation, nbits_diff_elevation; + + + /*----------------------------------------------------------------* + * Azimuth index encoding + *----------------------------------------------------------------*/ + + idx_azimuth = idx_azimuth_abs; + + nbits_diff_azimuth = 0; + + *flag_abs_azimuth = 0; /* differential coding by default */ + if ( angle->azimuth_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_azimuth = 1; + } + + /* try differential coding */ + if ( *flag_abs_azimuth == 0 ) + { + diff = idx_azimuth_abs - angle->last_azimuth_idx; + + /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */ + if ( abs( diff ) > ( ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) - ISM_MAX_AZIMUTH_DIFF_IDX ) + { + if ( diff > 0 ) + { + diff -= ( 1 << ISM_AZIMUTH_NBITS ) - 1; + } + else + { + diff += ( 1 << ISM_AZIMUTH_NBITS ) - 1; + } + } + + if ( diff == 0 ) + { + idx_azimuth = 0; + nbits_diff_azimuth = 1; + } + else if ( ABSVAL( diff ) < ISM_MAX_AZIMUTH_DIFF_IDX ) /* when diff bits >= abs bits, prefer abs */ + { + idx_azimuth = 1 << 1; + nbits_diff_azimuth = 1; + + if ( diff < 0 ) + { + idx_azimuth += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_azimuth += 0; /* positive sign */ + } + + idx_azimuth = idx_azimuth << diff; + nbits_diff_azimuth++; + + /* unary coding of "diff */ + idx_azimuth += ( ( 1 << diff ) - 1 ); + nbits_diff_azimuth += diff; + + if ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) + { + /* add stop bit - only for codewords shorter than ISM_AZIMUTH_NBITS */ + idx_azimuth = idx_azimuth << 1; + nbits_diff_azimuth++; + } + } + else + { + *flag_abs_azimuth = 1; + } + } + + /* update counter */ + if ( *flag_abs_azimuth == 0 ) + { + angle->azimuth_diff_cnt++; + angle->elevation_diff_cnt = min( angle->elevation_diff_cnt, ISM_FEC_MAX ); + } + else + { + angle->azimuth_diff_cnt = 0; + } + + /* Write azimuth */ + push_indice( hBstr, IND_ISM_AZIMUTH_DIFF_FLAG, *flag_abs_azimuth, 1 ); + + if ( *flag_abs_azimuth ) + { + push_indice( hBstr, IND_ISM_AZIMUTH, idx_azimuth, ISM_AZIMUTH_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_AZIMUTH, idx_azimuth, nbits_diff_azimuth ); + } + + /*----------------------------------------------------------------* + * Elevation index encoding + *----------------------------------------------------------------*/ + idx_elevation = idx_elevation_abs; + + nbits_diff_elevation = 0; + + *flag_abs_elevation = 0; /* differential coding by default */ + if ( angle->elevation_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_elevation = 1; + } + + /* note: elevation is coded starting from the second frame only (it is meaningless in the init_frame) */ + if ( ini_frame == 0 ) + { + *flag_abs_elevation = 1; + angle->last_elevation_idx = idx_elevation_abs; + } + + diff = idx_elevation_abs - angle->last_elevation_idx; + + /* avoid absolute coding of elevation if absolute coding was already used for azimuth */ + if ( *flag_abs_azimuth == 1 ) + { + int16_t diff_orig = diff; + + *flag_abs_elevation = 0; + + + if ( diff >= 0 ) + { + diff = min( diff, ISM_MAX_ELEVATION_DIFF_IDX ); + } + else + { + diff = -1 * min( -diff, ISM_MAX_ELEVATION_DIFF_IDX ); + } + + if ( last_ism_metadata_flag == 0 || abs( diff_orig - diff ) > ISM_MAX_ELEVATION_DIFF_IDX ) + { + angle->elevation_diff_cnt = ISM_FEC_MAX - 1; + } + } + + /* try differential coding */ + if ( *flag_abs_elevation == 0 ) + { + if ( diff == 0 ) + { + idx_elevation = 0; + nbits_diff_elevation = 1; + } + else if ( ABSVAL( diff ) <= ISM_MAX_ELEVATION_DIFF_IDX ) + { + idx_elevation = 1 << 1; + nbits_diff_elevation = 1; + + if ( diff < 0 ) + { + idx_elevation += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_elevation += 0; /* positive sign */ + } + + idx_elevation = idx_elevation << diff; + nbits_diff_elevation++; + + /* unary coding of "diff */ + idx_elevation += ( ( 1 << diff ) - 1 ); + nbits_diff_elevation += diff; + + if ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) + { + /* add stop bit */ + idx_elevation = idx_elevation << 1; + nbits_diff_elevation++; + } + } + else + { + *flag_abs_elevation = 1; + } + } + + /* update counter */ + if ( *flag_abs_elevation == 0 ) + { + angle->elevation_diff_cnt++; + angle->elevation_diff_cnt = min( angle->elevation_diff_cnt, ISM_FEC_MAX ); + } + else + { + angle->elevation_diff_cnt = 0; + } + + /* Write elevation */ + if ( *flag_abs_azimuth == 0 ) /* do not write "flag_abs_elevation" if "flag_abs_azimuth == 1" */ + { + push_indice( hBstr, IND_ISM_ELEVATION_DIFF_FLAG, *flag_abs_elevation, 1 ); + } + + if ( *flag_abs_elevation ) + { + push_indice( hBstr, IND_ISM_ELEVATION, idx_elevation, ISM_ELEVATION_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_ELEVATION, idx_elevation, nbits_diff_elevation ); + } + + /*----------------------------------------------------------------* + * Updates + *----------------------------------------------------------------*/ + + angle->last_azimuth_idx = idx_azimuth_abs; + angle->last_elevation_idx = idx_elevation_abs; + + return; +} +#endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 4cd70f61fc..f1ed1a9431 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -425,8 +425,12 @@ ivas_error IVAS_ENC_FeedObjectMetadata( { return IVAS_ERR_INDEX_OUT_OF_BOUNDS; } - + /* TD5 azimuth_orientation, elevation_orientation*/ +#ifdef TD5 + error = set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation, metadata.radius, metadata.azimuth_orientation, metadata.elevation_orientation ); +#else error = set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation ); +#endif /*TD5 */ if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index 3d784d9bb3..b7e34271de 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -46,6 +46,9 @@ typedef struct { int8_t headRotEnabled; IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#ifdef TD5 + float Pos[RENDERER_HEAD_POSITIONS_PER_FRAME][3]; +#endif float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; } IVAS_REND_HeadRotData; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 10617d3c62..56605794ec 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -53,13 +53,21 @@ static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRe static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, +#ifdef TD5 + const IVAS_QUATERNION *headPosition, + const float *Pos ); +#else const IVAS_QUATERNION *headPosition ); +#endif static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const int16_t lfe_idx, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); +#ifdef TD5 +static void angles_to_vec( const float radius, const float azimuth, const float elevation, float *vec ); +#endif /*---------------------------------------------------------------------* * ivas_td_binaural_open() @@ -168,9 +176,13 @@ ivas_error ivas_td_binaural_open( for ( nS = 0; nS < nchan_rend; nS++ ) { /* Set source positions according to loudspeaker layout */ +#ifdef TD5 + angles_to_vec( 1.0f, ls_azimuth[nS], ls_elevation[nS], Pos ); +#else Pos[0] = cosf( ls_elevation[nS] * PI_OVER_180 ) * cosf( ls_azimuth[nS] * PI_OVER_180 ); Pos[1] = cosf( ls_elevation[nS] * PI_OVER_180 ) * sinf( ls_azimuth[nS] * PI_OVER_180 ); Pos[2] = sinf( ls_elevation[nS] * PI_OVER_180 ); +#endif Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; @@ -186,6 +198,20 @@ ivas_error ivas_td_binaural_open( TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); } } +#ifdef TD5 + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + DirAtten_p = hBinRendererTd->DirAtten_p; + DirAtten_p->ConeInnerAngle = st_ivas->hRenderConfig->directivity[0]; + DirAtten_p->ConeOuterAngle = st_ivas->hRenderConfig->directivity[1]; + DirAtten_p->ConeOuterGain = st_ivas->hRenderConfig->directivity[2]; + + for ( nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); + } + } +#endif st_ivas->hBinRendererTd = hBinRendererTd; @@ -261,7 +287,12 @@ void ObjRenderIVASFrame( /* Update the listener's location/orientation */ TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, +#ifdef TD5 + ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL, + ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos[subframe_idx] : NULL ); +#else ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL ); +#endif if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { @@ -416,17 +447,24 @@ static void TDREND_Update_object_positions( /* Update the source positions */ /* Source position and direction */ +#ifdef TD5 + angles_to_vec( hIsmMetaData[nS]->radius, hIsmMetaData[nS]->azimuth, hIsmMetaData[nS]->elevation, Pos ); + angles_to_vec( 1.0f, hIsmMetaData[nS]->azimuth_orientation, hIsmMetaData[nS]->elevation_orientation, Dir ); +#else Pos[0] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * cosf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); Pos[1] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * sinf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); Pos[2] = sinf( hIsmMetaData[nS]->elevation * PI_OVER_180 ); Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; +#endif +#ifndef TD5 /* Source directivity info */ DirAtten_p->ConeInnerAngle = 360.0f; DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterGain = 1.0f; +#endif TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); @@ -448,19 +486,30 @@ static void TDREND_Update_object_positions( static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ - const IVAS_QUATERNION *headPosition /* i : Head Position */ +#ifdef TD5 + const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ + const float *Pos /* i : Listener position */ +#else + const IVAS_QUATERNION *headPosition /* i : Head Position */ +#endif ) { +#ifdef TD5 + float Pos_p[3]; +#else float Pos[3]; +#endif float FrontVec[3]; float UpVec[3]; float Rmat[3][3]; /* Update the listener's location/orientation */ +#ifndef TD5 /* Listener at the origin */ Pos[0] = 0.0f; Pos[1] = 0.0f; Pos[2] = 0.0f; +#endif if ( headRotEnabled ) { @@ -474,6 +523,12 @@ static void TDREND_Update_listener_orientation( UpVec[0] = Rmat[2][0]; UpVec[1] = Rmat[2][1]; UpVec[2] = Rmat[2][2]; +#ifdef TD5 + /* Input position */ + Pos_p[0] = Pos[0]; + Pos_p[1] = Pos[1]; + Pos_p[2] = Pos[2]; +#endif } else { @@ -485,10 +540,20 @@ static void TDREND_Update_listener_orientation( UpVec[0] = 0.0f; UpVec[1] = 0.0f; UpVec[2] = 1.0f; +#ifdef TD5 + /* Listener at the origin */ + Pos_p[0] = 0.0f; + Pos_p[1] = 0.0f; + Pos_p[2] = 0.0f; +#endif } /* Set the listener position and orientation:*/ +#ifdef TD5 + TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos_p ); +#else TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos ); +#endif TDREND_MIX_LIST_SetOrient( hBinRendererTd, FrontVec, UpVec ); return; @@ -609,9 +674,13 @@ ivas_error ivas_rend_TDObjRendOpen( for ( nS = 0; nS < nchan_rend; nS++ ) { /* Set source positions according to loudspeaker layout */ +#ifdef TD5 + angles_to_vec( 1.0f, ls_azimuth[nS], ls_elevation[nS], Pos ); +#else Pos[0] = cosf( ls_elevation[nS] * PI_OVER_180 ) * cosf( ls_azimuth[nS] * PI_OVER_180 ); Pos[1] = cosf( ls_elevation[nS] * PI_OVER_180 ) * sinf( ls_azimuth[nS] * PI_OVER_180 ); Pos[2] = sinf( ls_elevation[nS] * PI_OVER_180 ); +#endif Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; @@ -712,7 +781,11 @@ ivas_error ivas_rend_TDObjRenderFrame( for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Update the listener's location/orientation */ +#ifdef TD5 + TDREND_Update_listener_orientation( pTDRend->hBinRendererTd, headRotData->headRotEnabled, ( headRotData != NULL ) ? &headRotData->headPositions[subframe_idx] : NULL, ( headRotData != NULL ) ? headRotData->Pos[subframe_idx] : NULL ); +#else TDREND_Update_listener_orientation( pTDRend->hBinRendererTd, headRotData->headRotEnabled, ( headRotData != NULL ) ? &headRotData->headPositions[subframe_idx] : NULL ); +#endif /* TODO tmu : pass down renderer config struct */ // if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) ) @@ -739,3 +812,25 @@ ivas_error ivas_rend_TDObjRenderFrame( return IVAS_ERR_OK; } + +#ifdef TD5 +/*---------------------------------------------------------------------* + * angles_to_vec() + * + * Convert azimuth and elevation angles to position/orientation vector + *---------------------------------------------------------------------*/ + +static void angles_to_vec( + const float radius, /* i : radius */ + const float azimuth, /* i : Azimuth angle */ + const float elevation, /* i : Elevation angle */ + float *vec /* o : Pos/Dir vector */ +) +{ + vec[0] = radius * cosf( elevation * PI_OVER_180 ) * cosf( azimuth * PI_OVER_180 ); + vec[1] = radius * cosf( elevation * PI_OVER_180 ) * sinf( azimuth * PI_OVER_180 ); + vec[2] = radius * sinf( elevation * PI_OVER_180 ); + + return; +} +#endif diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index f71ae77a13..b9083b6d8a 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -353,10 +353,21 @@ ivas_error TDREND_REND_RenderSourceHRFilt( { float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; +#ifdef TD5 + float Gain; + + Gain = ( *Src_p->SrcRend_p->DirGain_p ) * ( *Src_p->SrcRend_p->DistGain_p ); +#endif TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); +#ifdef TD5 + TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength, Gain ); + TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength, Gain ); +#else TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength ); +#endif + /* Copy to accumulative output frame */ v_add( LeftOutputFrame, output_buf[0], output_buf[0], subframe_length ); v_add( RightOutputFrame, output_buf[1], output_buf[1], subframe_length ); diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 11b9893800..a17fc0b7ef 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -233,7 +233,12 @@ void TDREND_firfilt( const int16_t intp_count, /* i : interpolation count */ float *mem, /* i/o: filter memory */ const int16_t subframe_length, /* i : Length of signal */ - const int16_t filterlength /* i : Filter length */ +#ifdef TD5 + const int16_t filterlength, /* i : Filter length */ + const float Gain /* i : Gain */ +#else + const int16_t filterlength /* i : Filter length */ +#endif ) { float buffer[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 + L_SUBFRAME5MS_48k]; @@ -259,7 +264,11 @@ void TDREND_firfilt( { tmp += ( *p_filter++ ) * ( *p_tmp-- ); } +#ifdef TD5 + signal[i] = tmp * Gain; +#else signal[i] = tmp; +#endif if ( i < intp_count ) { diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 1c29e58bc3..d592536c15 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -261,6 +261,9 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( TDREND_MIX_Listener_t *Listener_p; TDREND_HRFILT_FiltSet_t *HrFiltSet_p; float ListRelPos[3], ListRelDist; +#ifdef TD5 + float ListRelPosAbs[3]; /* Relative position, ignoring orientation of listener */ +#endif float Azim, Elev; float hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; float hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; @@ -282,19 +285,26 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( break; case TDREND_POSTYPE_ABSOLUTE: /* Absolute position */ +#ifdef TD5 + TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos, ListRelPosAbs ); +#else TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos ); +#endif break; default: /* Illegal position type */ #ifdef DEBUGGING printf( "Warning! TDREND_SRC_REND_UpdateFiltersFromSpatialParams: Invalid position type. Assuming absolute position!\n" ); #endif /* Assume absolute position */ +#ifdef TD5 + TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos, ListRelPosAbs ); +#else TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos ); +#endif // TD5 break; } ListRelDist = TDREND_SPATIAL_VecNorm( ListRelPos ); - /* 2. Evaluate the Elevation and Azimuth angles */ if ( ( ListRelPos[0] == 0 ) && ( ListRelPos[1] == 0 ) && ( ListRelPos[2] == 0 ) ) { @@ -315,7 +325,11 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( *SrcRend_p->DirGain_p = 1.0f; if ( SrcSpatial_p->DirAttenEnabled ) { - *SrcRend_p->DirGain_p = TDREND_SRC_SPATIAL_GetDirGain( &SrcSpatial_p->DirAtten, SrcSpatial_p->Front_p, ListRelPos ); +#ifdef TD5 + *SrcRend_p->DirGain_p = TDREND_SRC_SPATIAL_GetDirGain(&SrcSpatial_p->DirAtten, SrcSpatial_p->Front_p, ListRelPosAbs); +#else + *SrcRend_p->DirGain_p = TDREND_SRC_SPATIAL_GetDirGain(&SrcSpatial_p->DirAtten, SrcSpatial_p->Front_p, ListRelPos); +#endif // TD5 } /* Distance gain */ diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index 17f5f229d1..e266107181 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -111,19 +111,29 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem( const float *UpVec_p, /* i : Up vector */ const float *RightVec_p, /* i : Right vector */ float *MappedVec_p /* o : Transformed vector */ +#ifdef TD5 + , + float *LisRelPosAbs /* o : Transformed vector without orientation */ +#endif // TD5 ) { +#ifdef TD5 + v_sub(Vec_p, TranslVec_p, LisRelPosAbs, 3); + /* Evalute the relative Vec in the coordinates of the Orientation vectors, */ +/* which form an orthonormal basis */ + MappedVec_p[0] = dotp(LisRelPosAbs, DirVec_p, 3); + MappedVec_p[1] = dotp(LisRelPosAbs, RightVec_p, 3); + MappedVec_p[2] = dotp(LisRelPosAbs, UpVec_p, 3); +#else float RelVec[3]; - /* Evaluate Vec relative to the new origin given by TranslVec */ v_sub( Vec_p, TranslVec_p, RelVec, 3 ); - /* Evalute the relative Vec in the coordinates of the Orientation vectors, */ - /* which form an orthonormal basis */ - MappedVec_p[0] = dotp( RelVec, DirVec_p, 3 ); - MappedVec_p[1] = dotp( RelVec, RightVec_p, 3 ); - MappedVec_p[2] = dotp( RelVec, UpVec_p, 3 ); - +/* which form an orthonormal basis */ + MappedVec_p[0] = dotp(RelVec, DirVec_p, 3); + MappedVec_p[1] = dotp(RelVec, RightVec_p, 3); + MappedVec_p[2] = dotp(RelVec, UpVec_p, 3); +#endif // TD5 return; } diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 0e9e089b93..6d72372e01 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -104,6 +104,7 @@ ivas_error ivas_render_config_init_from_rom( const int16_t room_flag_on /* i : room effect on/off flag */ ) { + if ( hRenderConfig == NULL || *hRenderConfig == NULL ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); @@ -126,5 +127,11 @@ ivas_error ivas_render_config_init_from_rom( mvr2r( ivas_reverb_default_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_N_BANDS ); mvr2r( ivas_reverb_default_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_N_BANDS ); +#ifdef TD5 + ( *hRenderConfig )->directivity[0] = 360.0f; /* Front cone */ + ( *hRenderConfig )->directivity[1] = 360.0f; /* Back cone */ + ( *hRenderConfig )->directivity[2] = 1.0f; /* Back attenuation */ +#endif + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b710202ce3..9d0140065d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -145,6 +145,9 @@ typedef struct { int8_t headRotEnabled; IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#ifdef TD5 + float Pos[RENDERER_HEAD_POSITIONS_PER_FRAME][3]; +#endif float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; } IVAS_REND_HeadRotData; @@ -468,6 +471,9 @@ typedef struct ivas_binaural_head_track_struct { int16_t num_quaternions; IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef TD5 + float Pos[MAX_PARAM_SPATIAL_SUBFRAMES][3]; +#endif float Rmat[3][3]; float Rmat_prev[3][3]; @@ -502,7 +508,9 @@ typedef struct ivas_render_config_t ivas_renderTypeOverride renderer_type_override; #endif ivas_roomAcoustics_t roomAcoustics; - +#ifdef TD5 + float directivity[3]; // Todo: Replace with constant +#endif } RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE; diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index cd1dd7bcf3..0823ce5f15 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -94,22 +94,38 @@ ivas_error HeadRotationFileReader_open( ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ - const int32_t frame_dec /* i : decoded frame number */ +#ifdef TD5 + IVAS_QUATERNION *Quaternions, /* o : listener orientation */ + float Pos[4][3] /* o : listener position */ +#else + IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ + const int32_t frame_dec /* i : decoded frame number */ +#endif ) { uint16_t i; float w, x, y, z; +#ifdef TD5 + float posx, posy, posz; +#endif for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { +#ifdef TD5 + if ( 7 != fscanf( headRotReader->trajFile, "%f,%f,%f,%f,%f,%f,%f", &w, &x, &y, &z, &posx, &posy, &posz ) ) +#else if ( 4 != fscanf( headRotReader->trajFile, "%f,%f,%f,%f", &w, &x, &y, &z ) ) +#endif { if ( feof( headRotReader->trajFile ) ) { rewind( headRotReader->trajFile ); headRotReader->fileRewind = true; +#ifdef TD5 + return HeadRotationFileReading( headRotReader, Quaternions, Pos ); +#else return HeadRotationFileReading( headRotReader, Quaternions, frame_dec ); +#endif } return IVAS_ERR_FAILED_FILE_PARSE; } @@ -121,6 +137,11 @@ ivas_error HeadRotationFileReading( Quaternions[i].x = x; Quaternions[i].y = y; Quaternions[i].z = z; +#ifdef TD5 + Pos[i][0] = posx; + Pos[i][1] = posy; + Pos[i][2] = posz; +#endif } return IVAS_ERR_OK; diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h index 6664908b00..4c6a2212dc 100644 --- a/lib_util/head_rotation_file_reader.h +++ b/lib_util/head_rotation_file_reader.h @@ -60,8 +60,13 @@ ivas_error HeadRotationFileReader_open( ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ - const int32_t frame_dec /* i : decoded frame number */ +#ifdef TD5 + IVAS_QUATERNION *Quaternions, /* o : listener orientation */ + float Pos[4][3] /* o : listener position */ +#else + IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ + const int32_t frame_dec /* i : decoded frame number */ +#endif ); /*-----------------------------------------------------------------------* diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index b511b30499..7ffa227739 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -37,8 +37,12 @@ #include -#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ -#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ +#ifdef TD5 +#define NUM_ISM_METADATA_PER_LINE 7 /* Number of ISM metadata per line in a metadata file */ +#else +#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#endif struct IsmFileReader @@ -146,6 +150,11 @@ ivas_error IsmFileReader_readNextFrame( ismMetadata->radius = meta_prm[2]; ismMetadata->spread = meta_prm[3]; ismMetadata->gainFactor = meta_prm[4]; +#ifdef TD5 + /* Add azimuth/elevation for orientation here */ + ismMetadata->azimuth_orientation = meta_prm[5]; + ismMetadata->elevation_orientation = meta_prm[6]; +#endif /* verify whether the read metadata values are in an expected range */ if ( ismMetadata->azimuth > 180 || ismMetadata->azimuth < -180 ) @@ -172,6 +181,18 @@ ivas_error IsmFileReader_readNextFrame( { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } +#ifdef TD5 + /* TO DO TD5 Verify azimuth/elevation_orientation */ + if ( ismMetadata->azimuth_orientation > 180 || ismMetadata->azimuth_orientation < -180 ) + { + return IVAS_ERR_ISM_INVALID_METADATA_VALUE; + } + + if ( ismMetadata->elevation_orientation > 90 || ismMetadata->elevation_orientation < -90 ) + { + return IVAS_ERR_ISM_INVALID_METADATA_VALUE; + } +#endif // TD5 return IVAS_ERR_OK; } diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index e0a910d5db..b203bdf63c 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -36,8 +36,12 @@ #include -#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ -#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ +#ifdef TD5 +#define NUM_ISM_METADATA_PER_LINE 7 /* Number of ISM metadata per line in a metadata file */ +#else +#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#endif struct IsmFileWriter @@ -121,9 +125,16 @@ ivas_error IsmFileWriter_writeFrame( /* IVAS_fmToDo: work in progress; currently position_azimuth, position_elevation, position_radius, spread, gain_factor */ #ifdef FIX_293_EXT_RENDERER_CLI - snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); +#ifdef TD5 + snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.azimuth_orientation, ismMetadata.elevation_orientation ); #else - sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); + snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); +#endif +#ifdef TD5 + sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.azimuth_orientation, ismMetadata.elevation_orientation ); +#else + sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); +#endif #endif if ( file ) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 27eed3bf14..5209dd58b1 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -523,6 +523,15 @@ ivas_error RenderConfigReader_read( errorHandler( pValue, ERROR_VALUE_INVALID ); } } +#ifdef TD5 + else if ( strcmp( item, "DIRECTIVITY" ) == 0 ) + { + if ( read_vector( pValue, 3, hRenderConfig->directivity ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#endif #ifdef DEBUGGING else { -- GitLab From e8a2a3cb416b30e932707eb8682a36edd459e94d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 15 Mar 2023 08:34:06 +0100 Subject: [PATCH 02/24] Correct bug from merge with TUNE_360_OBJECT_WITH_NOISE --- lib_enc/ivas_ism_metadata_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index ee43fee5fe..07b3b2d718 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -262,7 +262,7 @@ ivas_error ivas_ism_metadata_enc( #ifdef TD5 #ifdef TUNE_360_OBJECT_WITH_NOISE /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ - if ( localVAD[ch] == 0 && !( hSCE[ch]->hCoreCoder[0]->tcxonly ) && ( hSCE[ch]->hCoreCoder[0]->lp_noise <= 15 ) ) + if ( localVAD[ch] == 0 && !( hSCE[ch]->hCoreCoder[0]->tcxonly ) && ( hSCE[ch]->hCoreCoder[0]->lp_noise <= 10 ) ) { hIsmMeta[ch]->ism_metadata_flag = 0; } -- GitLab From 84348e6b498619aa81079157fb07062f0faeb940 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 15 Mar 2023 18:05:42 +0100 Subject: [PATCH 03/24] Added support of extended metadata and headtracking in external renderer --- apps/decoder.c | 2 +- apps/renderer.c | 73 +++++++++++++++++++++++++++- lib_com/common_api_types.h | 5 ++ lib_dec/lib_dec.c | 8 +-- lib_dec/lib_dec.h | 2 +- lib_rend/ivas_objectRenderer.c | 5 ++ lib_rend/lib_rend.c | 13 ++++- lib_rend/lib_rend.h | 5 ++ lib_util/head_rotation_file_reader.c | 8 +-- lib_util/head_rotation_file_reader.h | 2 +- 10 files changed, 109 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4d2d659d4e..875e3304a1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1384,7 +1384,7 @@ static ivas_error decodeG192( uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; #ifdef TD5 - float Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES][3] = { 0 }; /* Initialization needed for gcc */ + IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; diff --git a/apps/renderer.c b/apps/renderer.c index 72696b556d..a90e47083f 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -517,6 +517,9 @@ int main( int32_t delayTimeScale = 0; int16_t i, numChannels; ivas_error error = IVAS_ERR_OK; +#ifdef TD5 + IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#endif #ifdef WMOPS reset_wmops(); @@ -645,19 +648,31 @@ int main( } /* === Configure === */ +#ifdef TD5 + if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_InitConfig( hIvasRend, strlen( args.renderConfigFilePath ) != 0 ) ) != IVAS_ERR_OK ) { exit( -1 ); } +#endif if ( args.renderConfigFilePath[0] != '\0' ) { IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef TD5 + if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) +#else if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) +#endif { +#ifdef TD5 + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); +#else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); +#endif exit( -1 ); } @@ -889,16 +904,20 @@ int main( { IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME]; #ifdef TD5 - float Pos[RENDERER_HEAD_POSITIONS_PER_FRAME][3]; HeadRotationFileReading( headRotReader, quatBuffer, Pos ); + IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos ); #else HeadRotationFileReading( headRotReader, quatBuffer, frame ); -#endif IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ); +#endif } else { +#ifdef TD5 + IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ); +#else IVAS_REND_SetHeadRotation( hIvasRend, NULL ); +#endif } for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i ) @@ -1720,6 +1739,11 @@ void getMetadataFromFileReader( objectMetadataBuffer->positions[objIdx].azimuth = ismMetadata.azimuth; objectMetadataBuffer->positions[objIdx].elevation = ismMetadata.elevation; +#ifdef TD5 + objectMetadataBuffer->positions[objIdx].radius = ismMetadata.radius; + objectMetadataBuffer->positions[objIdx].yaw = ismMetadata.yaw; + objectMetadataBuffer->positions[objIdx].pitch = ismMetadata.pitch; +#endif return; } @@ -1774,6 +1798,11 @@ static void IsmPositionProvider_getNextFrame( { objectMetadataBuffer->positions[objIdx].azimuth = 0.0f; objectMetadataBuffer->positions[objIdx].elevation = 0.0f; +#ifdef TD5 + objectMetadataBuffer->positions[objIdx].radius = 1.0f; + objectMetadataBuffer->positions[objIdx].yaw = 0.0f; + objectMetadataBuffer->positions[objIdx].pitch = 0.0f; +#endif } /* Wrap azimuth to lie within (-180, 180] range */ @@ -1788,6 +1817,20 @@ static void IsmPositionProvider_getNextFrame( /* Clamp elevation to lie within [-90, 90] range (can't be wrapped easily) */ objectMetadataBuffer->positions[objIdx].elevation = min( max( objectMetadataBuffer->positions[objIdx].elevation, -90 ), 90 ); +#ifdef TD5 + /* Wrap yaw to lie within (-180, 180] range */ + while ( objectMetadataBuffer->positions[objIdx].yaw < 0.0f ) + { + objectMetadataBuffer->positions[objIdx].yaw += 360.0f; + } + while ( objectMetadataBuffer->positions[objIdx].yaw >= 360.0f ) + { + objectMetadataBuffer->positions[objIdx].yaw -= 360.0f; + } + + /* Clamp pitch to lie within [-90, 90] range (can't be wrapped easily) */ + objectMetadataBuffer->positions[objIdx].pitch = min( max( objectMetadataBuffer->positions[objIdx].pitch, -90 ), 90 ); +#endif } ++positionProvider->frameCounter; @@ -2049,6 +2092,32 @@ static void parseObjectPosition( exit( -1 ); } +#ifdef TD5 + readNextMetadataChunk( line, "," ); + position->radius = strtof( line, &endptr ); + + if ( *endptr != '\0' ) + { + fprintf( stderr, "Error reading metadata\n" ); + exit( -1 ); + } + + readNextMetadataChunk( line, "\n" ); + position->yaw = strtof( line, &endptr ); + if ( *endptr != '\0' ) + { + fprintf( stderr, "Error reading metadata\n" ); + exit( -1 ); + } + + readNextMetadataChunk( line, "\n" ); + position->pitch = strtof( line, &endptr ); + if ( *endptr != '\0' ) + { + fprintf( stderr, "Error reading metadata\n" ); + exit( -1 ); + } +#endif return; } diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index b2820f792c..dc1df1b5f0 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -123,6 +123,11 @@ typedef struct { float azimuth; float elevation; +#ifdef TD5 + float radius; + float yaw; + float pitch; +#endif } IVAS_REND_AudioObjectPosition; typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b4f03c8cc6..7dbcc7e5c6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -915,7 +915,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef TD5 IVAS_QUATERNION *orientation, /* i : head-tracking data, listener orientation */ - float Pos[4][3] /* i : listener position */ + IVAS_POSITION *Pos /* i : listener position */ #else IVAS_QUATERNION *orientation /* i : head-tracking data, listener orientation */ #endif @@ -944,9 +944,9 @@ ivas_error IVAS_DEC_FeedHeadTrackData( hHeadTrackData->Quaternions[i].y = orientation[i].y; hHeadTrackData->Quaternions[i].z = orientation[i].z; #ifdef TD5 - hHeadTrackData->Pos[i].x = Pos[i][0]; - hHeadTrackData->Pos[i].y = Pos[i][1]; - hHeadTrackData->Pos[i].z = Pos[i][2]; + hHeadTrackData->Pos[i].x = Pos[i].x; + hHeadTrackData->Pos[i].y = Pos[i].y; + hHeadTrackData->Pos[i].z = Pos[i].z; #endif } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index c1cfad3580..570d3f1f09 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -187,7 +187,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef TD5 IVAS_QUATERNION *orientation, /* i : head-tracking data */ - float Pos[4][3] /* i : listener position */ + IVAS_POSITION *Pos /* i : listener position */ #else IVAS_QUATERNION *orientation /* i : head-tracking data */ #endif diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 7666059421..099d9aae38 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -744,6 +744,11 @@ ivas_error ivas_td_binaural_renderer_ext( hIsmMetaData[0] = &hIsmMetaDataFrame; hIsmMetaData[0]->azimuth = currentPos->azimuth; hIsmMetaData[0]->elevation = currentPos->elevation; +#ifdef TD5 + hIsmMetaData[0]->yaw = currentPos->yaw; + hIsmMetaData[0]->pitch = currentPos->pitch; + hIsmMetaData[0]->radius = currentPos->radius; +#endif } #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1056f45e5a..21cab52a73 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3988,6 +3988,9 @@ int16_t IVAS_REND_FeedRenderConfig( } hRenderConfig = hIvasRend->hRendererConfig; +#ifdef TD5 + mvr2r(renderConfig.directivity, hRenderConfig->directivity, 3); +#endif #ifdef DEBUGGING hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) @@ -4020,8 +4023,13 @@ int16_t IVAS_REND_FeedRenderConfig( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef TD5 + const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME], /* i : head orientations for next rendering call */ + const IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : listener positions for next rendering call */ +#else const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */ +#endif ) { int16_t i; @@ -4051,6 +4059,9 @@ ivas_error IVAS_REND_SetHeadRotation( for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; ++i ) { hIvasRend->headRotData.headPositions[i] = headRot[i]; +#ifdef TD5 + hIvasRend->headRotData.Pos[i] = Pos[i]; +#endif } } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 6db5fd91dc..579dda711f 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -244,7 +244,12 @@ int16_t IVAS_REND_FeedRenderConfig( ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef TD5 + const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME], /* i : head orientations for next rendering call */ + const IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : listener positions for next rendering call */ +#else const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */ +#endif ); ivas_error IVAS_REND_GetSamples( diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index 2ef75e3488..d3a1018644 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -95,7 +95,7 @@ ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ IVAS_QUATERNION *Quaternions, /* o : head-tracking data, listener orientation */ #ifdef TD5 - float Pos[4][3] /* o : listener position */ + IVAS_POSITION *Pos /* o : listener position */ #else const int32_t frame_dec /* i : decoded frame number */ #endif @@ -141,9 +141,9 @@ ivas_error HeadRotationFileReading( Quaternions[i].y = y; Quaternions[i].z = z; #ifdef TD5 - Pos[i][0] = posx; - Pos[i][1] = posy; - Pos[i][2] = posz; + Pos[i].x = posx; + Pos[i].y = posy; + Pos[i].z = posz; #endif } diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h index 20e503f11d..6fa05caef1 100644 --- a/lib_util/head_rotation_file_reader.h +++ b/lib_util/head_rotation_file_reader.h @@ -61,7 +61,7 @@ ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ #ifdef TD5 - float Pos[4][3] /* o : listener position */ + IVAS_POSITION *Pos /* o : listener position */ #else const int32_t frame_dec /* i : decoded frame number */ #endif -- GitLab From d458cf3b6c6b688b662cab09369ede1b730fc20f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 15 Mar 2023 19:14:35 +0100 Subject: [PATCH 04/24] Clang format --- apps/decoder.c | 2 +- apps/renderer.c | 48 +++++++++++++------------- lib_dec/ivas_objectRenderer_internal.c | 3 +- lib_enc/ivas_ism_metadata_enc.c | 8 ++--- lib_rend/ivas_objectRenderer.c | 6 ++-- lib_rend/lib_rend.c | 6 ++-- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 875e3304a1..e808721f14 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1384,7 +1384,7 @@ static ivas_error decodeG192( uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; #ifdef TD5 - IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; diff --git a/apps/renderer.c b/apps/renderer.c index a90e47083f..00875cc4e3 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -657,43 +657,43 @@ int main( } #endif - if ( args.renderConfigFilePath[0] != '\0' ) - { - IVAS_RENDER_CONFIG_DATA renderConfig; + if ( args.renderConfigFilePath[0] != '\0' ) + { + IVAS_RENDER_CONFIG_DATA renderConfig; - /* sanity check */ + /* sanity check */ #ifdef TD5 - if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) + if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) #else if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) #endif - { + { #ifdef TD5 - fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); #else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); #endif - exit( -1 ); - } + exit( -1 ); + } - if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); - exit( -1 ); - } + if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); + exit( -1 ); + } - if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath ); - exit( -1 ); - } + if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath ); + exit( -1 ); + } - if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); - exit( -1 ); + if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); + exit( -1 ); + } } - } /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index c43efeece8..57ffe7e549 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -95,8 +95,7 @@ ivas_error ivas_td_binaural_renderer( #ifdef TD5 st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, output, output_frame ); -#else +#else st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame ); #endif - } diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 07b3b2d718..3472de0c5a 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -84,10 +84,10 @@ ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ #ifdef TD5 - const float elevation, /* i : elevation */ - float radius_meta, /* i : radius */ - float yaw, /* i : yaw */ - float pitch /* i : pitch */ + const float elevation, /* i : elevation */ + float radius_meta, /* i : radius */ + float yaw, /* i : yaw */ + float pitch /* i : pitch */ #else const float elevation /* i : elevation value */ #endif diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 099d9aae38..90ef392088 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -761,12 +761,12 @@ ivas_error ivas_td_binaural_renderer_ext( #endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( error = ivas_td_binaural_renderer_unwrap( reverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, - ( headRotData != NULL ) ? headRotData->headPositions : NULL, + ( headRotData != NULL ) ? headRotData->headPositions : NULL, #ifdef TD5 ( headRotData != NULL ) ? headRotData->Pos : NULL, output, output_frame ) ) != IVAS_ERR_OK ) #else output, output_frame ) ) != IVAS_ERR_OK ) -#endif +#endif { return error; } @@ -777,7 +777,7 @@ ivas_error ivas_td_binaural_renderer_ext( ( headRotData != NULL ) ? headRotData->Pos : NULL, output, output_frame ) ) != IVAS_ERR_OK ) #else output, output_frame ) ) != IVAS_ERR_OK ) -#endif +#endif { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 21cab52a73..426993c094 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1123,7 +1123,7 @@ static ivas_error setRendInputActiveIsm( if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) -#endif +#endif { return error; } @@ -3989,7 +3989,7 @@ int16_t IVAS_REND_FeedRenderConfig( hRenderConfig = hIvasRend->hRendererConfig; #ifdef TD5 - mvr2r(renderConfig.directivity, hRenderConfig->directivity, 3); + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 ); #endif #ifdef DEBUGGING hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; @@ -4023,7 +4023,7 @@ int16_t IVAS_REND_FeedRenderConfig( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ #ifdef TD5 const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME], /* i : head orientations for next rendering call */ const IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : listener positions for next rendering call */ -- GitLab From 87fac8a6383de78778d1a4a09a98feb7e478eeb9 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 16 Mar 2023 17:01:13 +0100 Subject: [PATCH 05/24] Fixes for flexible reading of metadata in META format for external renderer --- apps/renderer.c | 38 +++++++++++++++++--------------------- lib_rend/lib_rend.c | 5 +++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 00875cc4e3..3fcf5a0eeb 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2065,36 +2065,31 @@ static void parseObjectPosition( uint16_t *positionDuration ) { char *endptr; +#ifdef TD5 + int16_t read_values; + float meta_prm[7] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f }; readNextMetadataChunk( line, "," ); *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); + readNextMetadataChunk( line, "\n" ); - if ( *endptr != '\0' ) - { - fprintf( stderr, "Error reading metadata\n" ); - exit( -1 ); - } - - readNextMetadataChunk( line, "," ); - position->azimuth = strtof( line, &endptr ); + read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6] ); - if ( *endptr != '\0' ) + if ( read_values < 2 ) { fprintf( stderr, "Error reading metadata\n" ); exit( -1 ); } - readNextMetadataChunk( line, "\n" ); - position->elevation = strtof( line, &endptr ); - if ( *endptr != '\0' ) - { - fprintf( stderr, "Error reading metadata\n" ); - exit( -1 ); - } + position->azimuth = meta_prm[0]; + position->elevation = meta_prm[1]; + position->radius = meta_prm[2]; + position->yaw = meta_prm[5]; + position->pitch = meta_prm[6]; +#else -#ifdef TD5 readNextMetadataChunk( line, "," ); - position->radius = strtof( line, &endptr ); + *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); if ( *endptr != '\0' ) { @@ -2102,8 +2097,9 @@ static void parseObjectPosition( exit( -1 ); } - readNextMetadataChunk( line, "\n" ); - position->yaw = strtof( line, &endptr ); + readNextMetadataChunk( line, "," ); + position->azimuth = strtof( line, &endptr ); + if ( *endptr != '\0' ) { fprintf( stderr, "Error reading metadata\n" ); @@ -2111,7 +2107,7 @@ static void parseObjectPosition( } readNextMetadataChunk( line, "\n" ); - position->pitch = strtof( line, &endptr ); + position->elevation = strtof( line, &endptr ); if ( *endptr != '\0' ) { fprintf( stderr, "Error reading metadata\n" ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 09be168ecb..d45c2f5f78 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1005,6 +1005,11 @@ static IVAS_REND_AudioObjectPosition defaultObjectPosition( pos.azimuth = 0.0f; pos.elevation = 0.0f; +#ifdef TD5 + pos.radius = 1.0f; + pos.yaw = 0.0f; + pos.pitch = 0.0f; +#endif return pos; } -- GitLab From c1eb8dbb226b3018a110c3712b8b75bdad9d0e7f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:06:46 +0100 Subject: [PATCH 06/24] [cleanup] accept SBA_BR_SWITCHING_CLEAN_UP --- lib_com/ivas_fb_mixer.c | 28 ------- lib_com/ivas_prot.h | 12 --- lib_com/options.h | 1 - lib_dec/ivas_init_dec.c | 8 -- lib_dec/ivas_sba_dec.c | 150 ----------------------------------- lib_dec/ivas_spar_decoder.c | 20 ----- lib_enc/ivas_dirac_enc.c | 8 -- lib_enc/ivas_init_enc.c | 8 -- lib_enc/ivas_ism_param_enc.c | 8 -- lib_enc/ivas_mc_param_enc.c | 8 -- lib_enc/ivas_mcmasa_enc.c | 16 ---- lib_enc/ivas_sba_enc.c | 102 ------------------------ lib_enc/ivas_spar_encoder.c | 35 -------- 13 files changed, 404 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index c3389288de..4543955cee 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -175,10 +175,8 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -190,12 +188,10 @@ ivas_error ivas_FB_mixer_open( frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP hFbMixer = *hFbMixer_out; if ( !spar_reconfig_flag ) { -#endif if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); @@ -212,9 +208,7 @@ ivas_error ivas_FB_mixer_open( { hFbMixer->pFb = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif if ( fb_cfg->active_w_mixing == -1 ) { @@ -289,10 +283,8 @@ ivas_error ivas_FB_mixer_open( } } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif if ( fb_cfg->num_out_chans > 0 ) { const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; @@ -341,25 +333,19 @@ ivas_error ivas_FB_mixer_open( /* ignore all the deeper filter bank stuff for now */ hFbMixer->num_diff_bands = 0; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif hFbMixer->fb_cfg = fb_cfg; -#ifdef SBA_BR_SWITCHING_CLEAN_UP set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); if ( !spar_reconfig_flag ) { -#endif if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif *hFbMixer_out = hFbMixer; @@ -376,10 +362,8 @@ ivas_error ivas_FB_mixer_open( void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -439,10 +423,8 @@ void ivas_FB_mixer_close( hFbMixer->prior_mixer[0][0] = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif if ( fb_cfg->num_out_chans > 0 ) { num_bands = hFbMixer->pFb->filterbank_num_bands; @@ -476,9 +458,7 @@ void ivas_FB_mixer_close( free( hFbMixer->pFb ); hFbMixer->pFb = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif if ( hFbMixer->fb_cfg != NULL ) { @@ -486,15 +466,11 @@ void ivas_FB_mixer_close( hFbMixer->fb_cfg = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif free( hFbMixer ); hFbMixer = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; @@ -1074,10 +1050,6 @@ static ivas_error ivas_filterbank_setup( IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg; error = IVAS_ERR_OK; -#ifndef SBA_BR_SWITCHING_CLEAN_UP - set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans ); - set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans ); -#endif if ( pCfg->num_out_chans > 0 ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6711b998c9..c77c7e03d6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3751,18 +3751,14 @@ void FdCngDecodeDiracMDCTStereoSID( ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); ivas_error ivas_spar_enc( @@ -3775,19 +3771,15 @@ ivas_error ivas_spar_enc( ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); ivas_error ivas_spar_dec( @@ -4972,19 +4964,15 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_fb_mixer_pcm_ingest( diff --git a/lib_com/options.h b/lib_com/options.h index 298fe1391f..5120a1bc0b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define SBA_BR_SWITCHING_CLEAN_UP /*Issue 114: Clean up changes for the SBA reconfiguation functions*/ #define LOW_RATE_TRANS_CORE_CODER /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */ #define FIX_197_CREND_INTERFACE #define FIX_329_ENABLE_TD_RENDERER_REVERB_MC /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 25813f34b2..e6c5f28a21 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -863,11 +863,7 @@ ivas_error ivas_init_decoder( { if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1727,11 +1723,7 @@ void ivas_destroy_dec( /* Spar handle */ if ( st_ivas->hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 ); -#else - ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs ); -#endif st_ivas->hSpar = NULL; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 525e775eb9..76ac3578f9 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -65,9 +65,7 @@ ivas_error ivas_sba_dec_reconfigure( RENDERER_TYPE old_renderer_type; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; -#endif error = IVAS_ERR_OK; @@ -112,11 +110,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs ); -#else ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 ); -#endif st_ivas->hSpar = NULL; if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK ) @@ -128,78 +122,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t sba_order_internal; -#else - int16_t i, sba_order_internal, nchan_internal; - DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC; -#endif SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); -#ifndef SBA_BR_SWITCHING_CLEAN_UP - nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); - if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) - { - // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !! - IVAS_FB_CFG *fb_cfg; - int16_t active_w_mixing; - - /* MD handle */ - ivas_spar_md_dec_close( &hSpar->hMdDec ); - - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) - { - return error; - } - hSpar->hMdDec->td_decorr_flag = 1; - hSpar->hMdDec->table_idx = -1; - - /* TD decorr. */ - ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); - - if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, hDecoderConfig->output_Fs ); - - /* set FB config. */ - active_w_mixing = -1; - if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, nchan_internal, active_w_mixing, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - fb_cfg->pcm_offset = NS2SA( hDecoderConfig->output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); - fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; - - /* FB mixer handle */ - if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, hDecoderConfig->output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* mixer_mat intitialization */ - for ( i = 0; i < nchan_internal; i++ ) - { - for ( int16_t j = 0; j < nchan_internal; j++ ) - { - for ( int16_t b = 0; b < IVAS_MAX_NUM_BANDS; b++ ) - { - hSpar->hMdDec->mixer_mat[i][j][b] = 0.0f; - for ( int16_t i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ ) - { - hSpar->hMdDec->mixer_mat_prev[i_ts][i][j][b] = 0.0f; - } - } - } - } - hSpar->i_subframe = 0; - } -#else if ( hSpar != NULL ) { if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) ) @@ -230,61 +157,6 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = 0; -#endif -#ifndef SBA_BR_SWITCHING_CLEAN_UP - /* PCA handle */ - if ( hSpar != NULL ) - { - if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) - { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); - } - - ivas_pca_dec_init( hSpar->hPCA ); - } - else if ( hSpar->hPCA != NULL ) - { - free( st_ivas->hSpar->hPCA ); - hSpar->hPCA = NULL; - } - } - - if ( hSpar == NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) - { - if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - hSpar = st_ivas->hSpar; - } - st_ivas->sba_dirac_stereo_flag = 0; - - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - 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 ); - - if ( hDirAC == NULL && st_ivas->sba_mode == SBA_MODE_DIRAC ) - { - if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - hDirAC = st_ivas->hDirAC; - } - - if ( hDirAC != NULL && sba_mode_old == st_ivas->sba_mode ) - { - ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ); - } - - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } if ( st_ivas->nchan_transport == 1 ) @@ -351,7 +223,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; @@ -393,27 +264,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } -#else - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) ) - { - DIRAC_CONFIG_FLAG flag_config; - - flag_config = DIRAC_OPEN; - if ( st_ivas->hDirAC != NULL ) - { - flag_config = DIRAC_RECONFIGURE; - if ( sba_mode_old != st_ivas->sba_mode && st_ivas->sba_mode != SBA_MODE_SPAR ) - { - flag_config = DIRAC_RECONFIGURE_MODE; - } - } - - if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) ) { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7515300681..dbab951140 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -62,10 +62,8 @@ static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { SPAR_DEC_HANDLE hSpar; @@ -78,20 +76,16 @@ ivas_error ivas_spar_dec_open( error = IVAS_ERR_OK; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; if ( !spar_reconfig_flag ) { -#endif /* SPAR decoder handle */ if ( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -119,11 +113,7 @@ ivas_error ivas_spar_dec_open( fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -199,10 +189,8 @@ ivas_error ivas_spar_dec_open( void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { if ( hSpar != NULL ) @@ -214,11 +202,7 @@ void ivas_spar_dec_close( ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs, spar_reconfig_flag ); -#else - ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); -#endif /* AGC */ ivas_spar_agc_dec_close( &hSpar->hAgcDec ); @@ -230,15 +214,11 @@ void ivas_spar_dec_close( hSpar->hPCA = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif free( hSpar ); hSpar = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index a143ff37d2..61edd0b9a9 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -104,11 +104,7 @@ ivas_error ivas_dirac_enc_open( return error; } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -261,11 +257,7 @@ void ivas_dirac_enc_close( if ( hDirAC->hFbMixer != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); -#endif } for ( i = 0; i < DIRAC_MAX_ANA_CHANS; i++ ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index cce80138cb..c729511e70 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -462,11 +462,7 @@ ivas_error ivas_init_encoder( if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -966,11 +962,7 @@ void ivas_destroy_enc( /* SPAR handle */ if ( st_ivas->hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); -#else - ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp ); -#endif st_ivas->hSpar = NULL; } diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index ef66df5a90..2397e68eaf 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -281,11 +281,7 @@ ivas_error ivas_param_ism_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -324,11 +320,7 @@ void ivas_param_ism_enc_close( const int32_t input_Fs /* i : input sampling_rate */ ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); -#endif if ( hDirAC->hParamIsm != NULL ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 9b1241f234..e51887d455 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -146,11 +146,7 @@ ivas_error ivas_param_mc_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -369,11 +365,7 @@ void ivas_param_mc_enc_close( { ivas_param_mc_metadata_close( &hParamMC->hMetadataPMC ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate, 0 ); -#else - ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate ); -#endif free( hParamMC ); diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 153bc3ecad..b79f4b62e4 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -194,11 +194,7 @@ ivas_error ivas_mcmasa_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -228,11 +224,7 @@ ivas_error ivas_mcmasa_enc_open( return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -508,19 +500,11 @@ void ivas_mcmasa_enc_close( } } -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs ); -#endif if ( !hMcMasa->separateChannelEnabled ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs ); -#endif } /* intensity 3-dim */ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index e878d74183..d9cd39f7c0 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -123,11 +123,9 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; #endif -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t spar_reconfig_flag; spar_reconfig_flag = 0; -#endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -210,11 +208,7 @@ ivas_error ivas_sba_enc_reconfigure( { if ( st_ivas->hSpar == NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -223,7 +217,6 @@ ivas_error ivas_sba_enc_reconfigure( ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) { if ( hDirAC->sba_synchro_buffer[n] != NULL ) @@ -233,16 +226,11 @@ ivas_error ivas_sba_enc_reconfigure( } } hDirAC->num_samples_synchro_delay = 0; -#endif } else { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); -#else - ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp ); -#endif st_ivas->hSpar = NULL; } @@ -264,60 +252,12 @@ ivas_error ivas_sba_enc_reconfigure( { if ( hDirAC->hFbMixer != NULL ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs ); -#else ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); -#endif hDirAC->hFbMixer = NULL; } if ( sba_mode_old == SBA_MODE_SPAR ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - IVAS_FB_CFG *fb_cfg; - int16_t nchan_internal, sba_order_internal; - int16_t table_idx, active_w_mixing; - - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); - - /* Covar. State handle */ - ivas_spar_covar_enc_close( &hSpar->hCovEnc, hSpar->hFbMixer->fb_cfg->num_in_chans ); - - /* MD handle */ - ivas_spar_md_enc_close( &hSpar->hMdEnc ); - - if ( ( error = ivas_spar_md_enc_open( &( hSpar->hMdEnc ), hEncoderConfig, sba_order_internal ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*Initialization*/ - hSpar->hMdEnc->table_idx = -1; - - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, hEncoderConfig->input_Fs ); - - table_idx = ivas_get_spar_table_idx( ivas_total_brate, sba_order_internal, SPAR_CONFIG_BW, NULL, NULL ); - active_w_mixing = ivas_spar_br_table_consts[table_idx].active_w; - if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, st_ivas->nchan_transport, active_w_mixing, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; - - if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Covar. State handle */ - if ( ( error = ivas_spar_covar_enc_open( &( hSpar->hCovEnc ), hSpar->hFbMixer->pFb, hEncoderConfig->input_Fs, nchan_internal ) ) != IVAS_ERR_OK ) - { - return error; - } -#else spar_reconfig_flag = 1; ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); @@ -325,7 +265,6 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } -#endif } } else @@ -340,11 +279,7 @@ ivas_error ivas_sba_enc_reconfigure( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -368,43 +303,6 @@ ivas_error ivas_sba_enc_reconfigure( } } } -#ifndef SBA_BR_SWITCHING_CLEAN_UP - /* initialize delay for SPAR/DirAC delay synchronization */ - if ( ( st_ivas->sba_mode == SBA_MODE_DIRAC ) && ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) ) - { - if ( hDirAC->num_samples_synchro_delay == 0 ) - { - hDirAC->num_samples_synchro_delay = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); - - for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - if ( ( hDirAC->sba_synchro_buffer[n] = (float *) malloc( hDirAC->num_samples_synchro_delay * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hDirAC synchro buffer\n" ) ); - } - set_zero( hDirAC->sba_synchro_buffer[n], hDirAC->num_samples_synchro_delay ); - } - for ( ; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - hDirAC->sba_synchro_buffer[n] = NULL; - } - } - } - else - { - for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - if ( hDirAC->sba_synchro_buffer[n] != NULL ) - { - free( hDirAC->sba_synchro_buffer[n] ); - hDirAC->sba_synchro_buffer[n] = NULL; - } - } - hDirAC->num_samples_synchro_delay = 0; - } - - -#endif } if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b156c524d2..e5ed9ff9ff 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -59,10 +59,8 @@ static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_ ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { SPAR_ENC_HANDLE hSpar; @@ -75,20 +73,16 @@ ivas_error ivas_spar_enc_open( hEncoderConfig = st_ivas->hEncoderConfig; error = IVAS_ERR_OK; -#ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; if ( !spar_reconfig_flag ) { -#endif /* SPAR encoder handle */ if ( ( hSpar = (SPAR_ENC_HANDLE) malloc( sizeof( SPAR_ENC_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder" ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif input_Fs = hEncoderConfig->input_Fs; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -114,11 +108,7 @@ ivas_error ivas_spar_enc_open( fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -129,18 +119,14 @@ ivas_error ivas_spar_enc_open( return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif /* Transient Detector handle */ if ( ( error = ivas_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif /* initialization */ hSpar->hMdEnc->table_idx = -1; @@ -194,10 +180,8 @@ ivas_error ivas_spar_enc_open( * Allocate and initialize Front-VAD handle *-----------------------------------------------------------------*/ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif hSpar->front_vad_flag = 0; hSpar->front_vad_dtx_flag = 0; hSpar->force_front_vad = 0; @@ -233,9 +217,7 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD = NULL; hSpar->hFrontVad = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif /*-----------------------------------------------------------------* * Final assignment @@ -257,20 +239,16 @@ void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { int16_t num_chans; if ( hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif /* core-coder-VAD handle */ if ( hSpar->hCoreCoderVAD != NULL ) { @@ -284,9 +262,7 @@ void ivas_spar_enc_close( front_vad_destroy( &hSpar->hFrontVad ); hSpar->hFrontVad = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; assert( num_chans <= nchan_inp ); @@ -298,14 +274,7 @@ void ivas_spar_enc_close( ivas_spar_covar_enc_close( &hSpar->hCovEnc, num_chans ); /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs, spar_reconfig_flag ); -#else - ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); - - /* Trans Det handle */ - ivas_transient_det_close( &hSpar->hTranDet ); -#endif /* AGC */ ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); @@ -317,17 +286,13 @@ void ivas_spar_enc_close( hSpar->hPCA = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { /* Trans Det handle */ ivas_transient_det_close( &hSpar->hTranDet ); -#endif free( hSpar ); hSpar = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; -- GitLab From d86d7699aa3c5b49c57f9fe0ca0b3ba62e78b3f7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:07:35 +0100 Subject: [PATCH 07/24] [cleanup] accept LOW_RATE_TRANS_CORE_CODER --- lib_com/ivas_prot.h | 5 ----- lib_com/options.h | 1 - lib_enc/ivas_core_pre_proc_front.c | 9 --------- lib_enc/ivas_cpe_enc.c | 8 -------- lib_enc/ivas_ism_enc.c | 8 -------- lib_enc/ivas_sce_enc.c | 11 ----------- 6 files changed, 42 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c77c7e03d6..8982d3d4d6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -202,12 +202,7 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ -#ifdef LOW_RATE_TRANS_CORE_CODER const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#else - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t ivas_format /* i : IVAS format */ -#endif ); ivas_error pre_proc_ivas( diff --git a/lib_com/options.h b/lib_com/options.h index 5120a1bc0b..27cd0adef4 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define LOW_RATE_TRANS_CORE_CODER /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */ #define FIX_197_CREND_INTERFACE #define FIX_329_ENABLE_TD_RENDERER_REVERB_MC /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */ #define FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 000fbab33e..971d47c0f9 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -107,12 +107,7 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ -#ifdef LOW_RATE_TRANS_CORE_CODER const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#else - const int32_t ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */ - const int16_t ivas_format /* i : IVAS format */ -#endif ) { @@ -811,11 +806,7 @@ ivas_error pre_proc_front_ivas( } } /* Switch to ACELP for non-harmonic transient signals */ -#ifdef LOW_RATE_TRANS_CORE_CODER else if ( ( ( element_mode >= IVAS_CPE_DFT && element_brate <= IVAS_16k4 ) || ( element_mode == IVAS_SCE && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC ) -#else - else if ( ( ( ivas_format == STEREO_FORMAT && element_brate <= IVAS_16k4 ) || ( ivas_format == ISM_FORMAT && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC ) -#endif { if ( element_mode == IVAS_SCE ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8339b03399..323d99ae3a 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -429,19 +429,11 @@ ivas_error ivas_cpe_enc( for ( n = 0; n < n_CoreChannels; n++ ) { -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_total_brate ); -#else - error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], - &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], - &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 85b8e0c4aa..7cfe962bc7 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -158,19 +158,11 @@ ivas_error ivas_ism_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, st_ivas->hEncoderConfig->ivas_total_brate ); -#else - error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], - &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], - &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], - fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 195fc01cf7..48bea12e53 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -180,21 +180,12 @@ ivas_error ivas_sce_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, st_ivas->hEncoderConfig->ivas_total_brate ); -#else - error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], - &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], - &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], - fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -260,10 +251,8 @@ ivas_error ivas_sce_enc( hSCE->last_element_brate = hSCE->element_brate; -#ifdef LOW_RATE_TRANS_CORE_CODER /* Store previous attack detection flag */ st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; -#endif #ifdef DEBUG_MODE_INFO { -- GitLab From 7873f6f38c620d83f8d9f4ca0b6ec051a16cf326 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:09:07 +0100 Subject: [PATCH 08/24] [cleanup] accept FIX_197_CREND_INTERFACE --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal.c | 4 - lib_dec/ivas_dec.c | 8 - lib_dec/ivas_init_dec.c | 20 - lib_dec/ivas_ism_dec.c | 13 - lib_dec/ivas_mct_dec.c | 28 - lib_dec/ivas_objectRenderer_internal.c | 4 - lib_dec/ivas_stat_dec.h | 5 - lib_rend/ivas_crend.c | 1341 ------------------------ lib_rend/ivas_objectRenderer.c | 24 - lib_rend/ivas_prot_rend.h | 32 - lib_rend/lib_rend.c | 178 ---- 12 files changed, 1658 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 27cd0adef4..c7b6ebec04 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_197_CREND_INTERFACE #define FIX_329_ENABLE_TD_RENDERER_REVERB_MC /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */ #define FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 9fcb85ac0c..a0cd77d987 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -866,7 +866,6 @@ void ivas_binaural_add_LFE( if ( render_lfe ) { -#ifdef FIX_197_CREND_INTERFACE #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -878,9 +877,6 @@ void ivas_binaural_add_LFE( } #else gain = ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) ? st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe : GAIN_LFE; -#endif -#else - gain = st_ivas->hHrtf != NULL ? st_ivas->hHrtf->gain_lfe : GAIN_LFE; #endif for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index ca4666ae76..38486a340b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -222,14 +222,10 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else - ivas_crend_process( st_ivas, output ); -#endif ivas_binaural_add_LFE( st_ivas, output_frame, output ); } #ifdef DEBUGGING @@ -433,14 +429,10 @@ ivas_error ivas_dec( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else - ivas_crend_process( st_ivas, output ); -#endif ivas_binaural_add_LFE( st_ivas, output_frame, output ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e6c5f28a21..83cd4f471b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1228,7 +1228,6 @@ ivas_error ivas_init_decoder( return error; } #else -#ifdef FIX_197_CREND_INTERFACE #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) #else @@ -1237,9 +1236,6 @@ ivas_error ivas_init_decoder( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) -#endif -#else - if ( ( st_ivas->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) #endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); @@ -1263,7 +1259,6 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation ) { if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) @@ -1279,12 +1274,6 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; -#else - if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" ); - } -#endif } if ( st_ivas->ivas_format == ISM_FORMAT && @@ -1590,14 +1579,9 @@ void ivas_initialize_handles_dec( st_ivas->hIsmRendererData = NULL; st_ivas->hBinRendererTd = NULL; st_ivas->hMonoDmxRenderer = NULL; -#ifdef FIX_197_CREND_INTERFACE st_ivas->hCrendWrapper = NULL; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND st_ivas->hReverb = NULL; -#endif -#else - st_ivas->hCrend = NULL; - st_ivas->hHrtf = NULL; #endif st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; @@ -1756,11 +1740,7 @@ void ivas_destroy_dec( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Crend handle */ -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); -#endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0bda9f5ae0..6babce65b4 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -151,7 +151,6 @@ static ivas_error ivas_ism_bitrate_switching( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Open Crend Binaural renderer */ -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, @@ -164,9 +163,6 @@ static ivas_error ivas_ism_bitrate_switching( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; -#else - ivas_crend_open( st_ivas ); -#endif } } @@ -227,16 +223,7 @@ static ivas_error ivas_ism_bitrate_switching( } /* close the crend binaural renderer */ -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); - - if ( st_ivas->hHrtf != NULL ) - { - st_ivas->hHrtf = NULL; - } -#endif } } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 332455974c..9107453f35 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1070,17 +1070,9 @@ static ivas_error ivas_mc_dec_reconfig( ivas_binRenderer_close( &st_ivas->hBinRenderer ); } -#ifdef FIX_197_CREND_INTERFACE if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) ) -#else - if ( st_ivas->hCrend != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) ) -#endif { -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); -#endif } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1136,7 +1128,6 @@ static ivas_error ivas_mc_dec_reconfig( return error; } -#ifdef FIX_197_CREND_INTERFACE if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) { #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC @@ -1156,17 +1147,7 @@ static ivas_error ivas_mc_dec_reconfig( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } } -#else - if ( st_ivas->hCrend == NULL && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) - { - if ( ( st_ivas->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } - } -#endif } -#ifdef FIX_197_CREND_INTERFACE else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), @@ -1180,15 +1161,6 @@ static ivas_error ivas_mc_dec_reconfig( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; } -#else - else if ( st_ivas->hCrend == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" ); - } - } -#endif } /* mono/stereo */ else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8780b4ea98..d42578017f 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -76,11 +76,7 @@ ivas_error ivas_td_binaural_renderer( st_ivas->hReverb, #else st_ivas->hRenderConfig, st_ivas->ini_frame, -#ifdef FIX_197_CREND_INTERFACE st_ivas->hCrendWrapper, -#else - st_ivas->hCrend, -#endif #endif st_ivas->transport_config, #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4157438f80..70a3805cfc 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1238,14 +1238,9 @@ typedef struct Decoder_Struct EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE hCrendWrapper; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb; /* Reverb handle */ -#endif -#else - CREND_HANDLE hCrend; /* Convolution mixer renderer structure */ - HRTFS_HANDLE hHrtf; /* HRTFs handle */ #endif HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index caf9a562d5..4da404e721 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -148,1222 +148,11 @@ static ivas_error ivas_hrtf_close( } -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_init_from_rom() - * - * Allocate and initialize crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_rom( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i, j, tmp; - int32_t output_Fs; - AUDIO_CONFIG intern_config; - HRTFS_HANDLE hHrtf; - -#ifdef FIX_197_CREND_INTERFACE - hHrtf = st_ivas->hCrendWrapper->hHrtfCrend; -#else - hHrtf = st_ivas->hHrtf; -#endif - - output_Fs = st_ivas->hDecoderConfig->output_Fs; - - intern_config = st_ivas->intern_config; - - if ( intern_config == AUDIO_CONFIG_BINAURAL || intern_config == AUDIO_CONFIG_BINAURAL_ROOM ) - { - return IVAS_ERR_INTERNAL_FATAL; - } - - if ( hHrtf == NULL ) - { - if ( ivas_hrtf_open( &hHrtf ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for HRTF handle" ); - } - } - - hHrtf->max_num_ir = audioCfg2channels( intern_config ); - - if ( hHrtf->max_num_ir <= 0 ) - { - return IVAS_ERR_INTERNAL_FATAL; - } - - /* Do all error checks up front so that the nested if later is easier */ - if ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported renderer type" ); - } - - if ( intern_config != AUDIO_CONFIG_5_1 && intern_config != AUDIO_CONFIG_5_1_2 && intern_config != AUDIO_CONFIG_5_1_4 && - intern_config != AUDIO_CONFIG_7_1 && intern_config != AUDIO_CONFIG_7_1_4 && - intern_config != AUDIO_CONFIG_FOA && intern_config != AUDIO_CONFIG_HOA2 && intern_config != AUDIO_CONFIG_HOA3 ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Encountered unsupported transport config in Crend" ); - } - - if ( ( ( st_ivas->hRenderConfig != NULL ) && !st_ivas->hRenderConfig->roomAcoustics.use_brir ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV ) ) - { - if ( intern_config == AUDIO_CONFIG_5_1 || intern_config == AUDIO_CONFIG_5_1_2 || intern_config == AUDIO_CONFIG_5_1_4 || - intern_config == AUDIO_CONFIG_7_1 || intern_config == AUDIO_CONFIG_7_1_4 ) - { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; - - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( intern_config == AUDIO_CONFIG_5_1 ) - { - tmp = channelIndex_CICP6[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1 ) - { - tmp = channelIndex_CICP12[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_2 ) - { - tmp = channelIndex_CICP14[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_4 ) - { - tmp = channelIndex_CICP16[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1_4 ) - { - tmp = channelIndex_CICP19[i]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); - } - - if ( output_Fs == 48000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_48kHz[tmp][j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_32kHz[tmp][j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_16kHz[tmp][j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j]; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( ( ( st_ivas->hRenderConfig != NULL ) && st_ivas->hRenderConfig->roomAcoustics.use_brir ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( intern_config == AUDIO_CONFIG_5_1 || intern_config == AUDIO_CONFIG_5_1_2 || intern_config == AUDIO_CONFIG_5_1_4 || - intern_config == AUDIO_CONFIG_7_1 || intern_config == AUDIO_CONFIG_7_1_4 ) - { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; - - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( intern_config == AUDIO_CONFIG_5_1 ) - { - tmp = channelIndex_CICP6[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1 ) - { - tmp = channelIndex_CICP12[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_2 ) - { - tmp = channelIndex_CICP14[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_4 ) - { - tmp = channelIndex_CICP16[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1_4 ) - { - tmp = channelIndex_CICP19[i]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); - } - - if ( output_Fs == 48000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_48kHz[tmp][j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_32kHz[tmp][j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_16kHz[tmp][j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported intern_config type in Crend" ); - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" ); - } - -#ifdef FIX_197_CREND_INTERFACE - st_ivas->hCrendWrapper->hHrtfCrend = hHrtf; -#else - st_ivas->hHrtf = hHrtf; -#endif - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_init_from_hrtf_handle() - * - * Allocate and initialize Crend HRTF handle from external file - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_hrtf_handle( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_HANDLE hrtf ) -{ - int16_t i, j, as_lfe_filter; - const int16_t *hchannelIndex = NULL; - AUDIO_CONFIG transport_config; - - if ( st_ivas == NULL ) - { - return IVAS_ERR_INTERNAL; - } - - if ( hrtf == NULL ) - { - return IVAS_ERR_INVALID_HRTF; - } - - if ( st_ivas->hHrtf != NULL ) - { - ivas_hrtf_close( &st_ivas->hHrtf ); - } - - if ( ivas_hrtf_open( &( st_ivas->hHrtf ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INTERNAL; - } - - if ( st_ivas->hHrtf != NULL ) - { - st_ivas->hHrtf->latency_s = hrtf->latency_s; - // st_ivas->hHrtf->max_num_ir->max_ir_len = hrtf->max_ir_len; - st_ivas->hHrtf->max_num_iterations = hrtf->max_num_iterations; - st_ivas->hHrtf->gain_lfe = hrtf->gain_lfe; - // st_ivas->hHrtf->crend_hr_gain_foa_to_bin = hrtf->crend_hr_gain_foa_to_bin; - st_ivas->hHrtf->max_num_ir = 0; - st_ivas->hIntSetup.nchan_out_woLFE = 0; - st_ivas->hIntSetup.num_lfe = 0; - st_ivas->hIntSetup.nchan_out_woLFE = 0; - - transport_config = st_ivas->intern_config == AUDIO_CONFIG_INVALID ? st_ivas->transport_config : st_ivas->intern_config; - - switch ( transport_config ) - { - case AUDIO_CONFIG_5_1: - st_ivas->hHrtf->max_num_ir = 5; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP6; - break; - case AUDIO_CONFIG_7_1: - st_ivas->hHrtf->max_num_ir = 7; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP12; - break; - case AUDIO_CONFIG_5_1_2: - st_ivas->hHrtf->max_num_ir = 7; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP14; - break; - case AUDIO_CONFIG_5_1_4: - st_ivas->hHrtf->max_num_ir = 9; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP16; - break; - case AUDIO_CONFIG_7_1_4: - st_ivas->hHrtf->max_num_ir = 11; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP19; - break; - case AUDIO_CONFIG_FOA: - st_ivas->hIntSetup.ambisonics_order = 1; - st_ivas->hHrtf->max_num_ir = 4; - break; - case AUDIO_CONFIG_HOA2: - st_ivas->hIntSetup.ambisonics_order = 2; - st_ivas->hHrtf->max_num_ir = 9; - break; - case AUDIO_CONFIG_HOA3: - st_ivas->hIntSetup.ambisonics_order = 3; - st_ivas->hHrtf->max_num_ir = 16; - break; - default: - break; - } - - as_lfe_filter = 0; - if ( ( st_ivas->hHrtf->max_num_ir != hrtf->max_num_ir ) && ( st_ivas->hHrtf->max_num_ir + 1 == hrtf->max_num_ir ) ) - { - as_lfe_filter = 1; - hchannelIndex = NULL; - } - - if ( st_ivas->hHrtf->max_num_ir == 0 ) - { - return IVAS_ERR_INTERNAL; - } - - for ( i = 0; i < st_ivas->hHrtf->max_num_ir; i++ ) - { - int16_t tmp = i; - if ( hchannelIndex != NULL ) - { - tmp = hchannelIndex[i]; - } - if ( as_lfe_filter ) - { - if ( tmp > 2 ) - { - tmp++; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - st_ivas->hHrtf->pOut_to_bin_re[i][j] = hrtf->pOut_to_bin_re[tmp][j]; - st_ivas->hHrtf->pOut_to_bin_im[i][j] = hrtf->pOut_to_bin_im[tmp][j]; - st_ivas->hHrtf->num_iterations[i][j] = hrtf->num_iterations[tmp][j]; - st_ivas->hHrtf->pIndex_frequency_max[i][j] = hrtf->pIndex_frequency_max[tmp][j]; - } - st_ivas->hHrtf->inv_diffuse_weight[i] = hrtf->inv_diffuse_weight[tmp]; - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - st_ivas->hHrtf->pOut_to_bin_diffuse_re[j] = hrtf->pOut_to_bin_diffuse_re[j]; - st_ivas->hHrtf->pOut_to_bin_diffuse_im[j] = hrtf->pOut_to_bin_diffuse_im[j]; - st_ivas->hHrtf->num_iterations_diffuse[j] = hrtf->num_iterations_diffuse[j]; - st_ivas->hHrtf->pIndex_frequency_max_diffuse[j] = hrtf->pIndex_frequency_max_diffuse[j]; - } - st_ivas->hHrtf->index_frequency_max_diffuse = hrtf->index_frequency_max_diffuse; - } - return IVAS_ERR_OK; -} - -/*------------------------------------------------------------------------- - * ivas_crend_init_from_setofhrtf() - * - * Allocate and initialize crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_setofhrtf( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - ivas_error error; - AUDIO_CONFIG transport_config; - - transport_config = st_ivas->intern_config == AUDIO_CONFIG_INVALID ? st_ivas->transport_config : st_ivas->intern_config; - switch ( transport_config ) - { - case AUDIO_CONFIG_5_1: - case AUDIO_CONFIG_5_1_2: - case AUDIO_CONFIG_5_1_4: - case AUDIO_CONFIG_7_1: - case AUDIO_CONFIG_7_1_4: - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_brir_combined ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_hrir_combined ) ) != IVAS_ERR_OK ) - { - return error; - } - } - break; - case AUDIO_CONFIG_FOA: - case AUDIO_CONFIG_HOA2: - case AUDIO_CONFIG_HOA3: - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_hrir_hoa3 ) ) != IVAS_ERR_OK ) - { - return error; - } - break; - default: - return IVAS_ERR_INTERNAL; - } - - return IVAS_ERR_OK; -} - -#endif - -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_open() - * - * Allocate and initialize Crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i, subframe_length; - int16_t max_total_ir_len; - HRTFS_HANDLE hHrtf; - CREND_HANDLE hCrend; - ivas_error error; - - error = IVAS_ERR_OK; - subframe_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; - - if ( ( st_ivas->hHrtf == NULL ) && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( st_ivas->hSetOfHRTF != NULL ) - { - if ( ( error = ivas_crend_init_from_setofhrtf( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = ivas_crend_init_from_rom( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - - if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" ); - } - - hCrend->lfe_delay_line = NULL; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hCrend->freq_buffer_re[i] = NULL; - hCrend->freq_buffer_im[i] = NULL; - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - hCrend->prev_out_buffer[i] = NULL; - } - - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - hCrend->hReverb = NULL; - hCrend->delay_line_rw_index = 0; - hCrend->diffuse_delay_line_rw_index = 0; - hCrend->hTrack = NULL; - hCrend->m_fYaw = 0; - hCrend->m_fPitch = 0; - hCrend->m_fRoll = 0; - - hHrtf = st_ivas->hHrtf; - - if ( ( hHrtf != NULL ) && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - max_total_ir_len = hHrtf->max_num_iterations * subframe_length; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_re[i], 0, max_total_ir_len ); - - if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_im[i], 0, max_total_ir_len ); - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->prev_out_buffer[i], 0, subframe_length ); - } - - max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length; - - if ( max_total_ir_len > 0 ) - { - if ( ( hCrend->freq_buffer_re_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_re_diffuse, 0, max_total_ir_len ); - - if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_im_diffuse, 0, max_total_ir_len ); - } - else - { - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - } - - max_total_ir_len = (int16_t) ( hHrtf->latency_s * st_ivas->hDecoderConfig->output_Fs + 0.5f ) + subframe_length; - if ( max_total_ir_len > 0 ) - { - if ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->lfe_delay_line, 0, max_total_ir_len ); - } - else - { - hCrend->lfe_delay_line = NULL; - } - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - if ( ( hCrend->hTrack = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); - } - - ivas_orient_trk_Init( hCrend->hTrack ); - } - else - { - hCrend->hTrack = NULL; - } - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation ) - { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( ( ( st_ivas->hRenderConfig != NULL ) && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) - { - if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), st_ivas->intern_config, hHrtf, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - hCrend->hReverb = NULL; - } - - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtf->latency_s * 1000000000.f ); - } - - st_ivas->hCrend = hCrend; - - return error; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*------------------------------------------------------------------------- - * ivas_crend_close() - * - * Deallocate Crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_close( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i; - - if ( st_ivas->hHrtf != NULL ) - { - ivas_hrtf_close( &st_ivas->hHrtf ); - } - - if ( st_ivas->hCrend != NULL ) - { - if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - if ( st_ivas->hCrend->freq_buffer_re[i] != NULL ) - { - free( st_ivas->hCrend->freq_buffer_re[i] ); - st_ivas->hCrend->freq_buffer_re[i] = NULL; - } - if ( st_ivas->hCrend->freq_buffer_im[i] != NULL ) - { - free( st_ivas->hCrend->freq_buffer_im[i] ); - st_ivas->hCrend->freq_buffer_im[i] = NULL; - } - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( st_ivas->hCrend->prev_out_buffer[i] != NULL ) - { - free( st_ivas->hCrend->prev_out_buffer[i] ); - st_ivas->hCrend->prev_out_buffer[i] = NULL; - } - } - - if ( st_ivas->hCrend->lfe_delay_line != NULL ) - { - free( st_ivas->hCrend->lfe_delay_line ); - st_ivas->hCrend->lfe_delay_line = NULL; - } - - if ( st_ivas->hCrend->freq_buffer_re_diffuse != NULL ) - { - free( st_ivas->hCrend->freq_buffer_re_diffuse ); - st_ivas->hCrend->freq_buffer_re_diffuse = NULL; - } - - if ( st_ivas->hCrend->freq_buffer_im_diffuse != NULL ) - { - free( st_ivas->hCrend->freq_buffer_im_diffuse ); - st_ivas->hCrend->freq_buffer_im_diffuse = NULL; - } - - if ( st_ivas->hCrend->hTrack != NULL ) - { - free( st_ivas->hCrend->hTrack ); - st_ivas->hCrend->hTrack = NULL; - } - } - - ivas_reverb_close( &st_ivas->hCrend->hReverb ); - - free( st_ivas->hCrend ); - st_ivas->hCrend = NULL; - } - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*-----------------------------------------------------------------------------------------* - * Function ivas_crend_convolver() - * - * Convolver block - *-----------------------------------------------------------------------------------------*/ - -static ivas_error ivas_crend_convolver( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float pcm_in[][L_FRAME48k], - float pcm_out[][L_FRAME48k], - const int16_t i_ts ) -{ - float *pIn; - float *pFreq_buf_re; - float *pFreq_buf_im; - float *pFreq_filt_re; - float *pFreq_filt_im; - int16_t i, j, k, m, nchan_out, subframe_length, nchan_intern, idx_in; - float pOut[L_FRAME48k * 2]; - float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; - int16_t offset, offset_in, offset_diffuse; - int32_t output_Fs; - - nchan_intern = audioCfg2channels( st_ivas->intern_config ); - nchan_out = st_ivas->hDecoderConfig->nchan_out; - output_Fs = st_ivas->hDecoderConfig->output_Fs; - subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; - - offset = st_ivas->hCrend->delay_line_rw_index * subframe_length; /* subframe_length * ( st_ivas->hHrtf->max_num_iterations - 1 ); */ - offset_diffuse = st_ivas->hCrend->diffuse_delay_line_rw_index * subframe_length; /* subframe_length *( st_ivas->hHrtf->num_iterations_diffuse[0] - 1 ); */ - - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - set_zero( &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse], subframe_length ); - set_zero( &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse], subframe_length ); - } - - i = 0; - for ( idx_in = 0; idx_in < nchan_intern; idx_in++ ) - { - pIn = &pcm_in[idx_in][i_ts * subframe_length]; - if ( st_ivas->hIntSetup.index_lfe[0] != idx_in ) - { - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse]; - pFreq_filt_re = &st_ivas->hCrend->freq_buffer_re[i][offset]; - pFreq_filt_im = &st_ivas->hCrend->freq_buffer_im[i][offset]; - - for ( k = 0; k < st_ivas->hHrtf->index_frequency_max_diffuse; k++ ) - { - pFreq_buf_re[k] += pFreq_filt_re[k] * st_ivas->hHrtf->inv_diffuse_weight[i]; - pFreq_buf_im[k] += pFreq_filt_im[k] * st_ivas->hHrtf->inv_diffuse_weight[i]; - } - } - - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re[i][offset]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im[i][offset]; - - ivas_mdft( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); - i++; - } - } - - for ( j = 0; j < nchan_out; j++ ) - { - set_zero( tmp_out_re, subframe_length ); - set_zero( tmp_out_im, subframe_length ); - - i = 0; - for ( idx_in = 0; idx_in < nchan_intern; idx_in++ ) - { - if ( idx_in != st_ivas->hIntSetup.index_lfe[0] ) - { - offset = 0; - for ( m = 0; m < st_ivas->hHrtf->num_iterations[i][j]; m++ ) - { - offset_in = ( st_ivas->hCrend->delay_line_rw_index + st_ivas->hHrtf->max_num_iterations - st_ivas->hHrtf->num_iterations[i][j] + m + 1 ); - offset_in = offset_in % ( st_ivas->hHrtf->max_num_iterations ); - offset_in = offset_in * subframe_length; - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re[i][offset_in]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im[i][offset_in]; - pFreq_filt_re = &st_ivas->hHrtf->pOut_to_bin_re[i][j][offset]; - pFreq_filt_im = &st_ivas->hHrtf->pOut_to_bin_im[i][j][offset]; - - for ( k = 0; k < st_ivas->hHrtf->pIndex_frequency_max[i][j][m]; k++ ) - { - tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k]; - tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k]; - } - offset = offset + k; - } - i++; - } - } - - offset = 0; - for ( m = 0; m < st_ivas->hHrtf->num_iterations_diffuse[j]; m++ ) - { - offset_diffuse = ( st_ivas->hCrend->diffuse_delay_line_rw_index + m + 1 ); - offset_diffuse = offset_diffuse % st_ivas->hHrtf->num_iterations_diffuse[0]; - offset_diffuse = offset_diffuse * subframe_length; - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse]; - pFreq_filt_re = &st_ivas->hHrtf->pOut_to_bin_diffuse_re[j][offset]; - pFreq_filt_im = &st_ivas->hHrtf->pOut_to_bin_diffuse_im[j][offset]; - - for ( k = 0; k < st_ivas->hHrtf->pIndex_frequency_max_diffuse[j][m]; k++ ) - { - tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k]; - tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k]; - } - offset = offset + k; - } - - ivas_imdft( tmp_out_re, tmp_out_im, pOut, subframe_length ); - - pFreq_buf_re = &pcm_out[j][i_ts * subframe_length]; - for ( k = 0; k < subframe_length; k++ ) - { - pFreq_buf_re[k] = pOut[k] + st_ivas->hCrend->prev_out_buffer[j][k]; - st_ivas->hCrend->prev_out_buffer[j][k] = pOut[k + subframe_length]; - } - } - - st_ivas->hCrend->delay_line_rw_index++; - st_ivas->hCrend->delay_line_rw_index = st_ivas->hCrend->delay_line_rw_index % ( st_ivas->hHrtf->max_num_iterations ); - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - st_ivas->hCrend->diffuse_delay_line_rw_index++; - st_ivas->hCrend->diffuse_delay_line_rw_index = st_ivas->hCrend->diffuse_delay_line_rw_index % ( st_ivas->hHrtf->num_iterations_diffuse[0] ); - } - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*-----------------------------------------------------------------------------------------* - * Function ivas_crend_process() - * - * Process call for IVAS Crend renderer - *-----------------------------------------------------------------------------------------*/ - -ivas_error ivas_crend_process( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output[][L_FRAME48k] /* i/o: input/output audio channels */ -) -{ - int16_t i, nchan_out, output_frame; - int16_t subframe_len, subframe_idx; - float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; - AUDIO_CONFIG intern_config; - ivas_error error; - - push_wmops( "ivas_crend_process" ); - - intern_config = st_ivas->intern_config; - nchan_out = st_ivas->hDecoderConfig->nchan_out; - output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; - - for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) - { - if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ) - { - /* Orientation tracking */ - if ( st_ivas->hCrend->hTrack != NULL ) - { - if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_AVG ) - { - ivas_orient_trk_SetTrackingType( st_ivas->hCrend->hTrack, OTR_TRACKING_AVG_ORIENT ); - } - else - { - ivas_orient_trk_SetTrackingType( st_ivas->hCrend->hTrack, OTR_TRACKING_REF_ORIENT ); - } - /* get current subframe quaternion and convert to euler angles */ - Quat2Euler( st_ivas->hHeadTrackData->Quaternions[subframe_idx], &( st_ivas->hCrend->m_fYaw ), &( st_ivas->hCrend->m_fPitch ), &( st_ivas->hCrend->m_fRoll ) ); - ivas_orient_trk_SetAbsoluteOrientation( st_ivas->hCrend->hTrack, st_ivas->hCrend->m_fYaw, st_ivas->hCrend->m_fPitch, st_ivas->hCrend->m_fRoll ); - ivas_orient_trk_Process( st_ivas->hCrend->hTrack ); - ivas_orient_trk_GetTrackedOrientation( st_ivas->hCrend->hTrack, &( st_ivas->hCrend->m_fYaw ), &( st_ivas->hCrend->m_fPitch ), &( st_ivas->hCrend->m_fRoll ) ); - } - - /* Rotation in SHD for: - MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL - SBA SPAR -> BINAURAL or BINAURAL_ROOM - */ - if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - rotateFrame_shd( st_ivas->hHeadTrackData, output, subframe_len, st_ivas->hIntSetup, subframe_idx ); - } - /* Rotation in SD for MC -> BINAURAL_ROOM */ - else if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - rotateFrame_sd( st_ivas->hHeadTrackData, output, subframe_len, st_ivas->hIntSetup, st_ivas->hEFAPdata, subframe_idx ); - } - } - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - if ( ( intern_config == AUDIO_CONFIG_FOA ) || ( intern_config == AUDIO_CONFIG_HOA2 ) || ( intern_config == AUDIO_CONFIG_HOA3 ) || - ( intern_config == AUDIO_CONFIG_5_1 ) || ( intern_config == AUDIO_CONFIG_7_1 ) || - ( intern_config == AUDIO_CONFIG_5_1_2 ) || ( intern_config == AUDIO_CONFIG_5_1_4 ) || ( intern_config == AUDIO_CONFIG_7_1_4 ) ) - { - ivas_crend_convolver( st_ivas, output, pcm_tmp, subframe_idx ); - if ( st_ivas->hCrend->hReverb != NULL ) - { - if ( ( error = ivas_reverb_process( st_ivas->hCrend->hReverb, intern_config, 1, output, pcm_tmp, subframe_idx ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } - } - else - { - return IVAS_ERR_INTERNAL_FATAL; - } - } - /* move to output */ - for ( i = 0; i < nchan_out; i++ ) - { - mvr2r( pcm_tmp[i], output[i], output_frame ); - } - pop_wmops(); - return IVAS_ERR_OK; -} -#endif /*------------------------------------------------------------------------- @@ -1416,17 +205,10 @@ static ivas_error ivas_rend_initCrend( /* set BRIR flag */ use_brir = false; -#ifdef FIX_197_CREND_INTERFACE if ( ( ( hRendCfg != NULL ) && hRendCfg->roomAcoustics.use_brir ) || ( ( hRendCfg == NULL ) && ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) ) ) { use_brir = true; } -#else - if ( ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir ) || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) - { - use_brir = true; - } -#endif if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) @@ -1893,7 +675,6 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } -#ifdef FIX_197_CREND_INTERFACE #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() @@ -1951,7 +732,6 @@ ivas_error ivas_rend_initCrendWrapper( return IVAS_ERR_OK; } #endif -#endif /*------------------------------------------------------------------------- * ivas_rend_openCrend() * @@ -1959,17 +739,11 @@ ivas_error ivas_rend_initCrendWrapper( *------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE *pCrend, -#else - CREND_WRAPPER *pCrend, -#endif const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, -#ifdef FIX_197_CREND_INTERFACE int16_t Opt_Headrotation, -#endif HRTFS_CREND_HANDLE hSetOfHRTF, const int32_t output_Fs ) { @@ -1981,7 +755,6 @@ ivas_error ivas_rend_openCrend( ivas_error error; error = IVAS_ERR_OK; -#ifdef FIX_197_CREND_INTERFACE #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) { @@ -2004,12 +777,10 @@ ivas_error ivas_rend_openCrend( ( *pCrend )->hCrend = NULL; ( *pCrend )->hHrtfCrend = NULL; } -#endif #endif subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; -#ifdef FIX_197_CREND_INTERFACE if ( ( *pCrend )->hHrtfCrend == NULL ) { if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) @@ -2017,15 +788,6 @@ ivas_error ivas_rend_openCrend( return error; } } -#else - if ( pCrend->hHrtfCrend == NULL ) - { - if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif #ifndef FIX_329_ENABLE_TD_RENDERER_REVERB_MC @@ -2059,11 +821,7 @@ ivas_error ivas_rend_openCrend( #endif -#ifdef FIX_197_CREND_INTERFACE hHrtf = ( *pCrend )->hHrtfCrend; -#else - hHrtf = pCrend->hHrtfCrend; -#endif if ( hHrtf != NULL ) { @@ -2128,11 +886,7 @@ ivas_error ivas_rend_openCrend( { hCrend->lfe_delay_line = NULL; } -#ifdef FIX_197_CREND_INTERFACE if ( Opt_Headrotation ) -#else - if ( false ) /* TODO tmu : check renderer headrotation flag */ -#endif { if ( ( hCrend->hTrack = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { @@ -2150,11 +904,7 @@ ivas_error ivas_rend_openCrend( { if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hHrtfCrend, -#else - pCrend->hHrtfCrend, -#endif hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { @@ -2166,18 +916,10 @@ ivas_error ivas_rend_openCrend( hCrend->hReverb = NULL; } -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->binaural_latency_ns = (int32_t) ( ( *pCrend )->hHrtfCrend->latency_s * 1000000000.f ); -#else - pCrend->binaural_latency_ns = (int32_t) ( pCrend->hHrtfCrend->latency_s * 1000000000.f ); -#endif } -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hCrend = hCrend; -#else - pCrend->hCrend = hCrend; -#endif return IVAS_ERR_OK; } @@ -2188,17 +930,11 @@ ivas_error ivas_rend_openCrend( * Deallocate Crend renderer handle *------------------------------------------------------------------------*/ -#ifdef FIX_197_CREND_INTERFACE void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ) -#else -ivas_error ivas_rend_closeCrend( - CREND_WRAPPER *pCrend ) -#endif { int16_t i; -#ifdef FIX_197_CREND_INTERFACE if ( pCrend == NULL ) { return; @@ -2271,69 +1007,6 @@ ivas_error ivas_rend_closeCrend( *pCrend = NULL; } return; -#else - if ( pCrend->hHrtfCrend != NULL ) - { - ivas_hrtf_close( &pCrend->hHrtfCrend ); - } - - if ( pCrend->hCrend != NULL ) - { - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - if ( pCrend->hCrend->freq_buffer_re[i] != NULL ) - { - free( pCrend->hCrend->freq_buffer_re[i] ); - pCrend->hCrend->freq_buffer_re[i] = NULL; - } - if ( pCrend->hCrend->freq_buffer_im[i] != NULL ) - { - free( pCrend->hCrend->freq_buffer_im[i] ); - pCrend->hCrend->freq_buffer_im[i] = NULL; - } - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( pCrend->hCrend->prev_out_buffer[i] != NULL ) - { - free( pCrend->hCrend->prev_out_buffer[i] ); - pCrend->hCrend->prev_out_buffer[i] = NULL; - } - } - - if ( pCrend->hCrend->lfe_delay_line != NULL ) - { - free( pCrend->hCrend->lfe_delay_line ); - pCrend->hCrend->lfe_delay_line = NULL; - } - - if ( pCrend->hCrend->freq_buffer_re_diffuse != NULL ) - { - free( pCrend->hCrend->freq_buffer_re_diffuse ); - pCrend->hCrend->freq_buffer_re_diffuse = NULL; - } - - if ( pCrend->hCrend->freq_buffer_im_diffuse != NULL ) - { - free( pCrend->hCrend->freq_buffer_im_diffuse ); - pCrend->hCrend->freq_buffer_im_diffuse = NULL; - } - - if ( pCrend->hCrend->hTrack != NULL ) - { - free( pCrend->hCrend->hTrack ); - pCrend->hCrend->hTrack = NULL; - } - - ivas_reverb_close( &pCrend->hCrend->hReverb ); - - free( pCrend->hCrend ); - pCrend->hCrend = NULL; - } - return IVAS_ERR_OK; -#endif } /*-----------------------------------------------------------------------------------------* @@ -2508,20 +1181,14 @@ ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, -#ifdef FIX_197_CREND_INTERFACE DECODER_CONFIG_HANDLE hDecoderConfig, HEAD_TRACK_DATA_HANDLE hHeadTrackData, IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, -#endif float output[][L_FRAME48k], /* i/o: input/output audio channels */ const int32_t output_Fs ) { -#ifdef FIX_197_CREND_INTERFACE int16_t i, subframe_idx, output_frame, subframe_len; -#else - int16_t i, subframe_idx, output_frame; -#endif int16_t nchan_out; float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; AUDIO_CONFIG in_config; @@ -2535,11 +1202,7 @@ ivas_error ivas_rend_crendProcess( inRendConfig = getRendAudioConfigFromIvasAudioConfig( inConfig ); outRendConfig = getRendAudioConfigFromIvasAudioConfig( outConfig ); -#ifdef FIX_197_CREND_INTERFACE in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); -#else - in_config = rendAudioConfigToIvasAudioConfig( inRendConfig ); -#endif inConfigType = getAudioConfigType( inRendConfig ); @@ -2549,12 +1212,9 @@ ivas_error ivas_rend_crendProcess( } output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); -#ifdef FIX_197_CREND_INTERFACE subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; -#endif for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { -#ifdef FIX_197_CREND_INTERFACE if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { /* Orientation tracking */ @@ -2595,7 +1255,6 @@ ivas_error ivas_rend_crendProcess( rotateFrame_sd( hHeadTrackData, output, subframe_len, *hIntSetup, hEFAPdata, subframe_idx ); } } -#endif if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index a8be0b5ba3..dfa504c07f 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -232,11 +232,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( #else RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */ const int16_t ini_frame, /* i : Initialization frame counter */ -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */ -#else - CREND_HANDLE hCrend, /* i : Crend handle */ -#endif #endif AUDIO_CONFIG transport_config, /* i : Transport configuration */ #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND @@ -266,11 +262,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( if ( hRenderConfig->roomAcoustics.late_reverb_on && ( ini_frame == 0 ) ) { ivas_reverb_open( -#ifdef FIX_197_CREND_INTERFACE &hCrendWrapper->hCrend->hReverb, -#else - &hCrend->hReverb, -#endif transport_config, NULL, hRenderConfig, @@ -294,14 +286,10 @@ ivas_error ivas_td_binaural_renderer_unwrap( #endif { if ( ( error = ivas_reverb_process( -#ifdef FIX_197_CREND_INTERFACE #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hReverb, #else hCrendWrapper->hCrend->hReverb, -#endif -#else - hCrend->hReverb, #endif transport_config, 0, output, reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) { @@ -310,11 +298,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND ivas_reverb_process( -#ifdef FIX_197_CREND_INTERFACE hCrendWrapper->hCrend->hReverb, -#else - hCrend->hReverb, -#endif transport_config, 0, output, @@ -592,11 +576,7 @@ ivas_error ivas_td_binaural_open_ext( nchan_transport = customLsInput->num_spk; } -#ifdef FIX_197_CREND_INTERFACE transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -#else - transport_config = rendAudioConfigToIvasAudioConfig( inConfig ); -#endif ivas_format = ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? MC_FORMAT : ISM_FORMAT; hTransSetup.ls_azimuth = customLsInput->ls_azimuth; hTransSetup.ls_elevation = customLsInput->ls_elevation; @@ -679,11 +659,7 @@ ivas_error ivas_td_binaural_renderer_ext( } #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND -#ifdef FIX_197_CREND_INTERFACE transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -#else - transport_config = rendAudioConfigToIvasAudioConfig( inConfig ); -#endif output_Fs = output_frame * 50; #endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 9e92e45d57..12a3f27736 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -54,11 +54,7 @@ ivas_error getAudioConfigNumChannels( int16_t *numChannels ); -#ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( -#else -AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( -#endif IVAS_REND_AudioConfig rendConfig ); IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( @@ -221,11 +217,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( #else RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */ const int16_t ini_frame, /* i : Initialization frame counter */ -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */ -#else - CREND_HANDLE hCrend, /* i : Crend handle */ -#endif #endif AUDIO_CONFIG transport_config, /* i : Transport configuration */ #ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND @@ -484,28 +476,17 @@ void TDREND_firfilt( *----------------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE *pCrend, -#else - CREND_WRAPPER *pCrend, -#endif const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, -#ifdef FIX_197_CREND_INTERFACE int16_t Opt_Headrotation, -#endif HRTFS_CREND_HANDLE hSetOfHRTF, const int32_t output_Fs ); -#ifdef FIX_197_CREND_INTERFACE void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); -#else -ivas_error ivas_rend_closeCrend( - CREND_WRAPPER *pCrend ); -#endif #ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC ivas_error ivas_rend_initCrendWrapper( @@ -516,27 +497,14 @@ ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, -#ifdef FIX_197_CREND_INTERFACE DECODER_CONFIG_HANDLE hDecoderConfig, HEAD_TRACK_DATA_HANDLE hHeadTrackData, IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, -#endif float output[][L_FRAME48k], /* i/o: input/output audio channels */ const int32_t output_Fs ); -#ifndef FIX_197_CREND_INTERFACE - -ivas_error ivas_crend_init_from_setofhrtf( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_crend_init_from_hrtf_handle( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_HANDLE hrtf); - -#endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 7a1c4f4f30..ffa09574c8 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -115,13 +115,9 @@ typedef struct IVAS_REND_AudioObjectPosition currentPos; IVAS_REND_AudioObjectPosition previousPos; TDREND_WRAPPER tdRendWrapper; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif -#else - CREND_WRAPPER crendWrapper; #endif rotation_matrix rot_mat_prev; } input_ism; @@ -147,13 +143,9 @@ typedef struct LSSETUP_CUSTOM_STRUCT customLsInput; EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif -#else - CREND_WRAPPER crendWrapper; #endif rotation_gains rot_gains_prev; lfe_routing lfeRouting; @@ -163,11 +155,7 @@ typedef struct { input_base base; pan_matrix hoaDecMtx; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; -#else - CREND_WRAPPER crendWrapper; -#endif rotation_gains rot_gains_prev; } input_sba; @@ -329,11 +317,7 @@ static int32_t limitRendererOutput( * *-------------------------------------------------------------------*/ -#ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( -#else -AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( -#endif IVAS_REND_AudioConfig rendConfig ) { switch ( rendConfig ) @@ -1091,13 +1075,9 @@ static ivas_error setRendInputActiveIsm( inputIsm->currentPos = defaultObjectPosition(); inputIsm->previousPos = defaultObjectPosition(); -#ifdef FIX_197_CREND_INTERFACE inputIsm->crendWrapper = NULL; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputIsm->reverb = NULL; -#endif -#else - inputIsm->crendWrapper = defaultCrendWrapper(); #endif inputIsm->tdRendWrapper = defaultTdRendWrapper(); initRotMatrix( inputIsm->rot_mat_prev ); @@ -1129,15 +1109,9 @@ static ivas_error setRendInputActiveIsm( { #endif if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, AUDIO_CONFIG_7_1_4, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -1160,11 +1134,7 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ -#ifdef FIX_197_CREND_INTERFACE if ( inputIsm->crendWrapper != NULL ) -#else - if ( inputIsm->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputIsm->crendWrapper ); } @@ -1249,13 +1219,8 @@ static ivas_error initMcPanGainsWithConversionMapping( AUDIO_CONFIG ivasConfigIn, ivasConfigOut; int16_t i; -#ifdef FIX_197_CREND_INTERFACE ivasConfigIn = getIvasAudioConfigFromRendAudioConfig( inputMc->base.inConfig ); ivasConfigOut = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - ivasConfigIn = rendAudioConfigToIvasAudioConfig( inputMc->base.inConfig ); - ivasConfigOut = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif /* Find conversion mapping for current I/O config pair. * Stay with default panning matrix if conversion_matrix is NULL */ @@ -1818,11 +1783,7 @@ static ivas_error initMcBinauralRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } -#ifdef FIX_197_CREND_INTERFACE if ( inputMc->crendWrapper != NULL ) -#else - if ( inputMc->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputMc->crendWrapper ); } @@ -1877,16 +1838,9 @@ static ivas_error initMcBinauralRendering( { if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, -#ifdef FIX_197_CREND_INTERFACE ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : rendAudioConfigToIvasAudioConfig( inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, outSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -1989,13 +1943,9 @@ static ivas_error setRendInputActiveMc( setZeroPanMatrix( inputMc->panGains ); inputMc->customLsInput = defaultCustomLs(); inputMc->tdRendWrapper = defaultTdRendWrapper(); -#ifdef FIX_197_CREND_INTERFACE inputMc->crendWrapper = NULL; #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputMc->reverb = NULL; -#endif -#else - inputMc->crendWrapper = defaultCrendWrapper(); #endif initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); @@ -2031,11 +1981,7 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } -#ifdef FIX_197_CREND_INTERFACE if ( inputMc->crendWrapper != NULL ) -#else - if ( inputMc->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputMc->crendWrapper ); } @@ -2083,11 +2029,7 @@ static ivas_error initSbaPanGainsForMcOut( case IVAS_REND_AUDIO_CONFIG_MONO: hOutSetup.ls_azimuth = ls_azimuth_CICP1; hOutSetup.ls_elevation = ls_elevation_CICP1; -#ifdef FIX_197_CREND_INTERFACE ivas_output_init( &hOutSetup, getIvasAudioConfigFromRendAudioConfig( outConfig ) ); -#else - ivas_output_init( &hOutSetup, rendAudioConfigToIvasAudioConfig( outConfig ) ); -#endif break; case IVAS_REND_AUDIO_CONFIG_STEREO: case IVAS_REND_AUDIO_CONFIG_5_1: @@ -2095,11 +2037,7 @@ static ivas_error initSbaPanGainsForMcOut( case IVAS_REND_AUDIO_CONFIG_5_1_2: case IVAS_REND_AUDIO_CONFIG_5_1_4: case IVAS_REND_AUDIO_CONFIG_7_1_4: -#ifdef FIX_197_CREND_INTERFACE ivas_output_init( &hOutSetup, getIvasAudioConfigFromRendAudioConfig( outConfig ) ); -#else - ivas_output_init( &hOutSetup, rendAudioConfigToIvasAudioConfig( outConfig ) ); -#endif break; case IVAS_REND_AUDIO_CONFIG_LS_CUSTOM: ivas_ls_custom_setup( &hOutSetup, outSetupCustom ); @@ -2180,17 +2118,10 @@ static ivas_error updateSbaPanGains( { case IVAS_REND_AUDIO_CONFIG_BINAURAL: error = ivas_rend_openCrend( &inputSba->crendWrapper, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ); break; @@ -2202,15 +2133,9 @@ static ivas_error updateSbaPanGains( error = ivas_rend_openCrend( &inputSba->crendWrapper, AUDIO_CONFIG_7_1_4, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ); break; @@ -2254,11 +2179,7 @@ static ivas_error setRendInputActiveSba( initRendInputBase( &inputSba->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputSba->hoaDecMtx ); -#ifdef FIX_197_CREND_INTERFACE inputSba->crendWrapper = NULL; -#else - inputSba->crendWrapper = defaultCrendWrapper(); -#endif initRotGains( inputSba->rot_gains_prev ); if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) @@ -2279,11 +2200,7 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ -#ifdef FIX_197_CREND_INTERFACE if ( inputSba->crendWrapper != NULL ) -#else - if ( inputSba->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputSba->crendWrapper ); } @@ -2303,11 +2220,7 @@ static ivas_error initMasaDummyDecForMcOut( DecoderDummy *decDummy; decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; decDummy->hDecoderConfig->ivas_total_brate = IVAS_512k; /* Todo Nokia: This is preventing initialization of 2TC as 1TC, should be fixed properly in ivas_dirac_dec_config() */ @@ -2392,11 +2305,7 @@ static ivas_error initMasaDummyDecForSbaOut( decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; decDummy->hDecoderConfig->ivas_total_brate = IVAS_512k; /* Todo Nokia: This is preventing initialization of 2TC as 1TC, should be fixed properly in ivas_dirac_dec_config() */ @@ -2463,11 +2372,7 @@ static ivas_error initMasaDummyDecForBinauralOut( decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; output_config = decDummy->hDecoderConfig->output_config; @@ -2581,12 +2486,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hBinRenderer = NULL; decDummy->hEFAPdata = NULL; -#ifdef FIX_197_CREND_INTERFACE decDummy->hCrendWrapper = NULL; -#else - decDummy->hHrtf = NULL; - decDummy->hCrend = NULL; -#endif decDummy->hHrtfTD = NULL; decDummy->hSpar = NULL; decDummy->hoa_dec_mtx = NULL; @@ -2594,11 +2494,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hMasa = NULL; decDummy->hDiracDecBin = NULL; decDummy->hQMetaData = NULL; -#ifdef FIX_197_CREND_INTERFACE decDummy->hDecoderConfig->output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - decDummy->hDecoderConfig->output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->nchan_transport = numTransChannels; if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) @@ -2831,11 +2727,7 @@ ivas_error IVAS_REND_Open( for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { initRendInputBase( &hIvasRend->inputsIsm[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsIsm[i].crendWrapper = NULL; -#else - hIvasRend->inputsIsm[i].crendWrapper.hCrend = NULL; -#endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsIsm[i].reverb = NULL; #endif @@ -2846,11 +2738,7 @@ ivas_error IVAS_REND_Open( { initRendInputBase( &hIvasRend->inputsMc[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsMc[i].efapInWrapper.hEfap = NULL; -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsMc[i].crendWrapper = NULL; -#else - hIvasRend->inputsMc[i].crendWrapper.hCrend = NULL; -#endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsMc[i].reverb = NULL; #endif @@ -2860,11 +2748,7 @@ ivas_error IVAS_REND_Open( for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { initRendInputBase( &hIvasRend->inputsSba[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsSba[i].crendWrapper = NULL; -#else - hIvasRend->inputsSba[i].crendWrapper.hCrend = NULL; -#endif } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) @@ -3645,13 +3529,8 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = max( ( hIvasRend->inputsIsm[i].crendWrapper != NULL ) ? hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); -#else - latency_ns = max( hIvasRend->inputsIsm[i].crendWrapper.binaural_latency_ns, - hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3660,13 +3539,8 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = max( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ? hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); -#else - latency_ns = max( hIvasRend->inputsMc[i].crendWrapper.binaural_latency_ns, - hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3675,11 +3549,7 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; -#else - latency_ns = hIvasRend->inputsSba[i].crendWrapper.binaural_latency_ns; -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3876,7 +3746,6 @@ ivas_error IVAS_REND_InitConfig( hIvasRend->rendererConfigEnabled = 0; } -#ifdef FIX_197_CREND_INTERFACE if ( rendererConfigEnabled ) { if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) @@ -3893,17 +3762,6 @@ ivas_error IVAS_REND_InitConfig( { hIvasRend->hRendererConfig = NULL; } -#else - if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INTERNAL_FATAL; - } -#endif return IVAS_ERR_OK; } @@ -4536,15 +4394,9 @@ static ivas_error renderIsmToBinauralRoom( if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE ismInput->crendWrapper, -#else - &ismInput->crendWrapper, -#endif AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, -#ifdef FIX_197_CREND_INTERFACE NULL, NULL, NULL, NULL, -#endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, #else @@ -4870,14 +4722,8 @@ static ivas_error renderMcToBinaural( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -4977,14 +4823,8 @@ static ivas_error renderMcToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif #ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, #else @@ -5067,13 +4907,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - AUDIO_CONFIG_7_1_4, - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -5303,13 +5137,7 @@ static ivas_error renderSbaToBinaural( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE sbaInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &sbaInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( sbaInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -5379,14 +5207,8 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &sbaInput->crendWrapper, - AUDIO_CONFIG_7_1_4, - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 4794fcd6ec5e048a6aefa69a7b943c35a3749a4d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:09:59 +0100 Subject: [PATCH 09/24] [cleanup] accept FIX_329_ENABLE_TD_RENDERER_REVERB_MC --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal.c | 4 --- lib_dec/ivas_init_dec.c | 8 ----- lib_dec/ivas_mct_dec.c | 6 ---- lib_rend/ivas_crend.c | 50 ----------------------------- lib_rend/ivas_prot_rend.h | 2 -- 6 files changed, 71 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c7b6ebec04..efb224e691 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_329_ENABLE_TD_RENDERER_REVERB_MC /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */ #define FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */ #define FIX_347_DTX_CRASH /* FhG: Fix crash that can happen with DTX */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a0cd77d987..e27fc42db5 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -866,7 +866,6 @@ void ivas_binaural_add_LFE( if ( render_lfe ) { -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { gain = GAIN_LFE; @@ -875,9 +874,6 @@ void ivas_binaural_add_LFE( { gain = ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) ? st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe : GAIN_LFE; } -#else - gain = ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) ? st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe : GAIN_LFE; -#endif for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { v_multc( output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain, output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 83cd4f471b..b2aecc4d2e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1228,15 +1228,7 @@ ivas_error ivas_init_decoder( return error; } #else -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) -#else - if ( ( st_ivas->hCrendWrapper = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 9107453f35..af3749d980 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1130,18 +1130,12 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) { -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) -#else - if ( ( st_ivas->hCrendWrapper = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC st_ivas->hCrendWrapper->hCrend = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; -#endif if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 4da404e721..9ea32ba1e3 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -675,7 +675,6 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() * @@ -731,7 +730,6 @@ ivas_error ivas_rend_initCrendWrapper( return IVAS_ERR_OK; } -#endif /*------------------------------------------------------------------------- * ivas_rend_openCrend() * @@ -755,29 +753,11 @@ ivas_error ivas_rend_openCrend( ivas_error error; error = IVAS_ERR_OK; -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) { return error; } hCrend = ( *pCrend )->hCrend; -#else - if ( pCrend == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - - if ( *pCrend == NULL ) - { - if ( ( *pCrend = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - ( *pCrend )->binaural_latency_ns = 0; - ( *pCrend )->hCrend = NULL; - ( *pCrend )->hHrtfCrend = NULL; - } -#endif subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; @@ -789,36 +769,6 @@ ivas_error ivas_rend_openCrend( } } -#ifndef FIX_329_ENABLE_TD_RENDERER_REVERB_MC - - if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" ); - } - - hCrend->lfe_delay_line = NULL; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hCrend->freq_buffer_re[i] = NULL; - hCrend->freq_buffer_im[i] = NULL; - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - hCrend->prev_out_buffer[i] = NULL; - } - - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - hCrend->hReverb = NULL; - hCrend->delay_line_rw_index = 0; - hCrend->diffuse_delay_line_rw_index = 0; - hCrend->hTrack = NULL; - hCrend->m_fYaw = 0; - hCrend->m_fPitch = 0; - hCrend->m_fRoll = 0; -#endif hHrtf = ( *pCrend )->hHrtfCrend; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 12a3f27736..f90d781c33 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -488,10 +488,8 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend ); -#endif ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, -- GitLab From 4f7bb9eb7195381c2fa3299487d1fd5a99354710 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:10:54 +0100 Subject: [PATCH 10/24] [cleanup] accept FIX_330_ENABLE_TD_RENDERER_REVERB_REND --- lib_com/options.h | 1 - lib_dec/ivas_init_dec.c | 11 ---- lib_dec/ivas_objectRenderer_internal.c | 8 --- lib_dec/ivas_stat_dec.h | 2 - lib_rend/ivas_objectRenderer.c | 79 -------------------------- lib_rend/ivas_prot_rend.h | 11 ---- lib_rend/ivas_reverb.c | 2 - lib_rend/lib_rend.c | 77 ------------------------- 8 files changed, 191 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index efb224e691..479b2a829b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,6 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */ #define FIX_347_DTX_CRASH /* FhG: Fix crash that can happen with DTX */ #define DISABLE_RES_CHANNELS_MCT /* decode only W and residual for Y when outputting to stereo */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b2aecc4d2e..e66e5915d8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1222,17 +1222,10 @@ ivas_error ivas_init_decoder( if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } -#endif } } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -1572,9 +1565,7 @@ void ivas_initialize_handles_dec( st_ivas->hBinRendererTd = NULL; st_ivas->hMonoDmxRenderer = NULL; st_ivas->hCrendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND st_ivas->hReverb = NULL; -#endif st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; @@ -1733,10 +1724,8 @@ void ivas_destroy_dec( /* Crend handle */ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); -#endif /* LS config converter handle */ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index d42578017f..77e3586784 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -72,16 +72,8 @@ ivas_error ivas_td_binaural_renderer( ) { return ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND st_ivas->hReverb, -#else - st_ivas->hRenderConfig, st_ivas->ini_frame, - st_ivas->hCrendWrapper, -#endif st_ivas->transport_config, -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - st_ivas->hDecoderConfig->output_Fs, -#endif st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame ); } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 70a3805cfc..1cef5cb3c0 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1239,9 +1239,7 @@ typedef struct Decoder_Struct VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ CREND_WRAPPER_HANDLE hCrendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb; /* Reverb handle */ -#endif HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index dfa504c07f..9ae3014938 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -227,17 +227,8 @@ void ivas_td_binaural_close( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb, /* i : reverb handle */ -#else - RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */ - const int16_t ini_frame, /* i : Initialization frame counter */ - CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */ -#endif AUDIO_CONFIG transport_config, /* i : Transport configuration */ -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - const int32_t output_Fs, /* i : Output sampling rate */ -#endif BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ const int16_t nchan_transport, /* i : Transport channels (ISms) */ const int16_t lfe_idx, /* i : LFE channel index */ @@ -255,21 +246,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( ivas_error error; subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - if ( hRenderConfig != NULL ) - { - - if ( hRenderConfig->roomAcoustics.late_reverb_on && ( ini_frame == 0 ) ) - { - ivas_reverb_open( - &hCrendWrapper->hCrend->hReverb, - transport_config, - NULL, - hRenderConfig, - output_Fs ); - } - } -#endif /* Update object position(s) */ TDREND_Update_object_positions( hBinRendererTd, nchan_transport, lfe_idx, ivas_format, hIsmMetaData, output ); @@ -279,32 +255,15 @@ ivas_error ivas_td_binaural_renderer_unwrap( /* Update the listener's location/orientation */ TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) ) -#else - if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) ) -#endif { if ( ( error = ivas_reverb_process( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hReverb, -#else - hCrendWrapper->hCrend->hReverb, -#endif transport_config, 0, output, reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) { return error; } -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - ivas_reverb_process( - hCrendWrapper->hCrend->hReverb, - transport_config, - 0, - output, - reverb_signal, - subframe_idx ); -#endif } /* Render subframe */ @@ -315,24 +274,12 @@ ivas_error ivas_td_binaural_renderer_unwrap( } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) ) { /* add reverb to rendered signals */ v_add( reverb_signal[0], output[0], output[0], output_frame ); v_add( reverb_signal[1], output[1], output[1], output_frame ); } -#else - if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ - { - if ( hRenderConfig->roomAcoustics.late_reverb_on ) - { - /* add reverb to rendered signals */ - v_add( reverb_signal[0], output[0], output[0], output_frame ); - v_add( reverb_signal[1], output[1], output[1], output_frame ); - } - } -#endif return IVAS_ERR_OK; } @@ -598,9 +545,7 @@ ivas_error ivas_td_binaural_renderer_ext( const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND const REVERB_HANDLE reverb, /* i : reverb handle */ -#endif const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) @@ -609,17 +554,10 @@ ivas_error ivas_td_binaural_renderer_ext( ISM_METADATA_HANDLE hIsmMetaData[1]; int16_t lfe_idx; int16_t num_src; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - /* TODO tmu : pass down renderer config struct */ - // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; -#endif IVAS_FORMAT ivas_format; IVAS_REND_AudioConfigType inConfigType; AUDIO_CONFIG transport_config; ivas_error error; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - int32_t output_Fs; -#endif push_wmops( "ivas_td_binaural_renderer_ext" ); @@ -630,9 +568,7 @@ ivas_error ivas_td_binaural_renderer_ext( if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { ivas_format = MC_FORMAT; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -#endif if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { if ( ( error = getAudioConfigNumChannels( inConfig, &num_src ) ) != IVAS_ERR_OK ) @@ -650,32 +586,17 @@ ivas_error ivas_td_binaural_renderer_ext( { ivas_format = ISM_FORMAT; num_src = 1; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND transport_config = AUDIO_CONFIG_ISM1; -#endif hIsmMetaData[0] = &hIsmMetaDataFrame; hIsmMetaData[0]->azimuth = currentPos->azimuth; hIsmMetaData[0]->elevation = currentPos->elevation; } -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); - output_Fs = output_frame * 50; -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( error = ivas_td_binaural_renderer_unwrap( reverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, output, output_frame ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( ( error = error = ivas_td_binaural_renderer_unwrap( NULL, 1, NULL, transport_config, output_Fs, pTDRend->hBinRendererTd, num_src, lfe_idx, - ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, - output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif pop_wmops(); diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index f90d781c33..ea3db32259 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -212,17 +212,8 @@ void ivas_HRTF_CRend_binary_close( *----------------------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb, /* i : reverb handle */ -#else - RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */ - const int16_t ini_frame, /* i : Initialization frame counter */ - CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */ -#endif AUDIO_CONFIG transport_config, /* i : Transport configuration */ -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - const int32_t output_Fs, /* i : Output sampling rate */ -#endif BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ const int16_t nchan_transport, /* i : Transport channels (ISms) */ const int16_t lfe_idx, /* i : LFE channel index */ @@ -240,9 +231,7 @@ ivas_error ivas_td_binaural_renderer_ext( const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND const REVERB_HANDLE reverb, /* i : reverb handle */ -#endif const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 3911c36601..ec5bd928d2 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1175,7 +1175,6 @@ ivas_error ivas_reverb_open( /* set up reverb acoustic data on the basis of HRTF data and renderer config */ set_reverb_acoustic_data( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING pState->pConfig.renderer_type_override = hRenderConfig->renderer_type_override; @@ -1184,7 +1183,6 @@ ivas_error ivas_reverb_open( pState->pConfig.roomAcoustics.use_brir = hRenderConfig->roomAcoustics.use_brir; pState->pConfig.roomAcoustics.late_reverb_on = hRenderConfig->roomAcoustics.late_reverb_on; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; -#endif /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ffa09574c8..eae8c6d0d0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -116,9 +116,7 @@ typedef struct IVAS_REND_AudioObjectPosition previousPos; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif rotation_matrix rot_mat_prev; } input_ism; @@ -144,9 +142,7 @@ typedef struct EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif rotation_gains rot_gains_prev; lfe_routing lfeRouting; } input_mc; @@ -1076,9 +1072,7 @@ static ivas_error setRendInputActiveIsm( inputIsm->currentPos = defaultObjectPosition(); inputIsm->previousPos = defaultObjectPosition(); inputIsm->crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputIsm->reverb = NULL; -#endif inputIsm->tdRendWrapper = defaultTdRendWrapper(); initRotMatrix( inputIsm->rot_mat_prev ); @@ -1092,7 +1086,6 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir == 0 && hRendCfg->roomAcoustics.late_reverb_on ) { if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) @@ -1107,7 +1100,6 @@ static ivas_error setRendInputActiveIsm( } else { -#endif if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), hRendCfg, @@ -1116,9 +1108,7 @@ static ivas_error setRendInputActiveIsm( { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } -#endif } return IVAS_ERR_OK; @@ -1139,12 +1129,10 @@ static void clearInputIsm( ivas_rend_closeCrend( &inputIsm->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputIsm->reverb != NULL ) { ivas_reverb_close( &inputIsm->reverb ); } -#endif if ( inputIsm->tdRendWrapper.hBinRendererTd != NULL ) { @@ -1788,12 +1776,10 @@ static ivas_error initMcBinauralRendering( ivas_rend_closeCrend( &inputMc->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputMc->reverb != NULL ) { ivas_reverb_close( &inputMc->reverb ); } -#endif if ( inputMc->efapInWrapper.hEfap != NULL ) { @@ -1825,7 +1811,6 @@ static ivas_error initMcBinauralRendering( return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir == 0 && hRendCfg->roomAcoustics.late_reverb_on ) { if ( ( error = ivas_reverb_open( &( inputMc->reverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) @@ -1833,7 +1818,6 @@ static ivas_error initMcBinauralRendering( return error; } } -#endif } { @@ -1944,9 +1928,7 @@ static ivas_error setRendInputActiveMc( inputMc->customLsInput = defaultCustomLs(); inputMc->tdRendWrapper = defaultTdRendWrapper(); inputMc->crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputMc->reverb = NULL; -#endif initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); @@ -1986,12 +1968,10 @@ static void clearInputMc( ivas_rend_closeCrend( &inputMc->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputMc->reverb != NULL ) { ivas_reverb_close( &inputMc->reverb ); } -#endif if ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { @@ -2728,9 +2708,7 @@ ivas_error IVAS_REND_Open( { initRendInputBase( &hIvasRend->inputsIsm[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsIsm[i].crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsIsm[i].reverb = NULL; -#endif hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; } @@ -2739,9 +2717,7 @@ ivas_error IVAS_REND_Open( initRendInputBase( &hIvasRend->inputsMc[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsMc[i].efapInWrapper.hEfap = NULL; hIvasRend->inputsMc[i].crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsMc[i].reverb = NULL; -#endif hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL; } @@ -4246,9 +4222,7 @@ static ivas_error renderIsmToBinaural( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND ismInput->reverb, -#endif outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { @@ -4271,11 +4245,7 @@ static ivas_error renderIsmToBinauralRoom( int16_t subframe_idx, subframe_len; int16_t tmp; rotation_matrix Rmat; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#else - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif IVAS_QUATERNION quat; ivas_error error; pan_vector currentPanGains; @@ -4289,7 +4259,6 @@ static ivas_error renderIsmToBinauralRoom( headRotData = ismInput->base.ctx.pHeadRotData; rotatedPos = defaultObjectPosition(); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ismInput->reverb != NULL && ismInput->reverb->pConfig.roomAcoustics.use_brir == 0 && ismInput->reverb->pConfig.roomAcoustics.late_reverb_on == 1 && headRotData->headRotEnabled ) { copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); @@ -4300,21 +4269,16 @@ static ivas_error renderIsmToBinauralRoom( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND ismInput->reverb, -#endif outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#endif } else { -#endif if ( headRotData->headRotEnabled ) { @@ -4386,37 +4350,23 @@ static ivas_error renderIsmToBinauralRoom( renderBufferChannelLerp( ismInput->base.inputBuffer, 0, currentPanGains, previousPanGains, tmpMcBuffer ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); -#endif if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, -#else - tmpCrendBuffer, -#endif *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#else - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); -#endif free( tmpMcBuffer.data ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } -#endif pop_wmops(); return IVAS_ERR_OK; @@ -4683,9 +4633,7 @@ static ivas_error renderMcToBinaural( &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, NULL, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND mcInput->reverb, -#endif mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { @@ -4748,19 +4696,14 @@ static ivas_error renderMcToBinauralRoom( const IVAS_REND_AudioConfig outConfig, IVAS_REND_AudioBuffer outAudio ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND int8_t headRotEnabled; float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; IVAS_REND_AudioConfig inConfig; -#else - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; push_wmops( "renderMcToBinauralRoom" ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND headRotEnabled = mcInput->base.ctx.pHeadRotData->headRotEnabled; inConfig = mcInput->base.inConfig; @@ -4785,10 +4728,6 @@ static ivas_error renderMcToBinauralRoom( /* apply rotation */ if ( headRotEnabled ) -#else - /* apply rotation */ - if ( mcInput->base.ctx.pHeadRotData->headRotEnabled ) -#endif { tmpRotBuffer = mcInput->base.inputBuffer; tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); @@ -4805,42 +4744,26 @@ static ivas_error renderMcToBinauralRoom( return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( tmpRotBuffer, tmpCrendBuffer ); -#endif free( tmpRotBuffer.data ); } else { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( mcInput->base.inputBuffer, tmpCrendBuffer ); -#endif } /* call CREND */ if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, -#else - tmpCrendBuffer, -#endif *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#else - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); -#endif /* TODO tmu : needs delay compensation */ if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) -- GitLab From 2342c56db814dc8be36f2c786bb5d6a46404c18f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:11:44 +0100 Subject: [PATCH 11/24] [cleanup] accept FIX_347_DTX_CRASH --- lib_com/options.h | 1 - lib_dec/ivas_core_dec.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 479b2a829b..be8fe4ee1a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,7 +142,6 @@ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_347_DTX_CRASH /* FhG: Fix crash that can happen with DTX */ #define DISABLE_RES_CHANNELS_MCT /* decode only W and residual for Y when outputting to stereo */ #define FIX_107_5MS_SUBFRAME_RENDERING #define REMOVE_FORCE_SUBFRAME_BIN /* Issue 355: remove obsolete "-force_subframe_bin" command-line option. */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 49429e0381..929e8187e7 100755 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -240,11 +240,7 @@ ivas_error ivas_core_dec( hCPE->hStereoCng->flag_cna_fade = 0; } -#ifdef FIX_347_DTX_CRASH if ( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) -#else - if ( sba_dirac_stereo_flag && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) -#endif { save_hb_synth = hSCE->save_hb_synth; } @@ -461,11 +457,7 @@ ivas_error ivas_core_dec( /* for FD-CNG we need the delay compensation in the synth, so do this afterwards */ -#ifdef FIX_347_DTX_CRASH if ( sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) -#else - if ( sba_dirac_stereo_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) -#endif { mvr2r( synth[n], hSCE->save_synth, output_frame ); } -- GitLab From 49049c0db14974020471565c59bdc4ec8ed1cdd7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:12:29 +0100 Subject: [PATCH 12/24] [cleanup] accept DISABLE_RES_CHANNELS_MCT --- lib_com/options.h | 1 - lib_dec/ivas_mct_dec.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index be8fe4ee1a..b45f22db61 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,7 +142,6 @@ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define DISABLE_RES_CHANNELS_MCT /* decode only W and residual for Y when outputting to stereo */ #define FIX_107_5MS_SUBFRAME_RENDERING #define REMOVE_FORCE_SUBFRAME_BIN /* Issue 355: remove obsolete "-force_subframe_bin" command-line option. */ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index af3749d980..1e34ef397a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -166,7 +166,6 @@ ivas_error ivas_mct_dec( /* MCT core decoder */ ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output ); -#ifdef DISABLE_RES_CHANNELS_MCT /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ if ( st_ivas->sba_dirac_stereo_flag ) { @@ -178,7 +177,6 @@ ivas_error ivas_mct_dec( } } } -#endif /* MCT reconstruction and CoreCoder updates */ for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) -- GitLab From 8acccbbbb27060e3cb1346c3a52c959be388df9f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:13:32 +0100 Subject: [PATCH 13/24] [cleanup] accept REMOVE_FORCE_SUBFRAME_BIN, FIX_107_5MS_SUBFRAME_RENDERING --- apps/decoder.c | 33 -------------------- lib_com/options.h | 2 -- lib_dec/ivas_init_dec.c | 14 --------- lib_dec/ivas_stat_dec.h | 3 -- lib_dec/lib_dec.c | 16 ---------- lib_dec/lib_dec.h | 6 ---- lib_rend/ivas_dirac_dec_binaural_functions.c | 15 --------- lib_rend/lib_rend.c | 11 ------- 8 files changed, 100 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index af9a847aab..40f6b47b23 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -104,9 +104,6 @@ typedef struct char *renderConfigFilename; #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - bool forceSubframeBinauralization; -#endif IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ @@ -303,23 +300,7 @@ int main( * Configure the decoder *------------------------------------------------------------------------------------------*/ -#ifdef REMOVE_FORCE_SUBFRAME_BIN - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) -#else -#ifdef DEBUGGING -#ifdef FIX_351_HRTF_COMMAND - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef FIX_351_HRTF_COMMAND if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK ) -#endif -#endif -#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -710,9 +691,6 @@ static bool parseCmdlIVAS_dec( float ftmp; arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED; -#ifndef REMOVE_FORCE_SUBFRAME_BIN - arg->forceSubframeBinauralization = false; -#endif #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; #endif @@ -864,13 +842,6 @@ static bool parseCmdlIVAS_dec( i++; } } -#ifndef REMOVE_FORCE_SUBFRAME_BIN - else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */ - { - arg->forceSubframeBinauralization = true; - i++; - } -#endif #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK /*-----------------------------------------------------------------* @@ -1120,10 +1091,6 @@ static void usage_dec( void ) fprintf( stdout, "-T File : Head rotation specified by external trajectory File\n" ); fprintf( stdout, "-hrtf File : HRTF filter File used in BINAURAL output configuration\n" ); #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - fprintf( stdout, "-force_subframe_bin : Forces parametric binauralizer code to use 5 ms time resolution even when\n" ); - fprintf( stdout, " output time resolution is larger.\n" ); -#endif fprintf( stdout, "-FEC X : Insert frame erasures, X = 0-10 is the percentage\n" ); fprintf( stdout, " of erased frames, or X may be the name of binary file or \n" ); fprintf( stdout, " file with G192 headers indicating GOOD FRAME or BAD FRAME\n" ); diff --git a/lib_com/options.h b/lib_com/options.h index b45f22db61..e482b2189e 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -142,8 +142,6 @@ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_107_5MS_SUBFRAME_RENDERING -#define REMOVE_FORCE_SUBFRAME_BIN /* Issue 355: remove obsolete "-force_subframe_bin" command-line option. */ #define PARAM_ISM_DTX_CNG /* FhG: contribution 9 - DTX-CNG for ParamISM */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e66e5915d8..1c1a44ea53 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2053,20 +2053,6 @@ static ivas_error doSanityChecks_IVAS( } #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - if ( st_ivas->hDecoderConfig->forceSubframeBinauralization ) - { - /* Note about resolution of Binaural Renderers: * - * - Parametric Binaural Renderer: 20 ms by default, can be forced to subframe (5 ms) resolution * - * - FastConv Binaural Renderer: 5 ms by default * - * - TD objects Binaural Renderer: 20 ms by default */ - - if ( !( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM ) || !( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT || st_ivas->ivas_format == ISM_FORMAT ) ) - { - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong set-up: Forced subframe resolution parametric binauralization activated for non-binaural output." ); - } - } -#endif if ( ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration: Time Domain object renderer not supported in this configuration" ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1cef5cb3c0..fa61493818 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1154,9 +1154,6 @@ typedef struct decoder_config_structure /* temp. development parameters */ #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - int16_t forceSubframeBinauralization; /* Flag for forcing Parametric binauralizer to subframe mode */ -#endif int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 95f7dca8a7..d10b6d79d5 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -225,11 +225,6 @@ static void init_decoder_config( hDecoderConfig->Opt_Headrotation = 0; #ifdef FIX_351_HRTF_COMMAND hDecoderConfig->Opt_RendConfigCustom = 0; -#endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - hDecoderConfig->forceSubframeBinauralization = 0; -#endif #endif hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->no_diegetic_pan = no_diegetic_pan; @@ -399,12 +394,6 @@ ivas_error IVAS_DEC_Configure( , const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ #endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - , - const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ -#endif -#endif ) { Decoder_Struct *st_ivas; @@ -450,11 +439,6 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - hDecoderConfig->forceSubframeBinauralization = forceSubframeBinauralization; -#endif -#endif hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 36dab5c1f9..c0d74b077b 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -134,12 +134,6 @@ ivas_error IVAS_DEC_Configure( ,const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ #endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - , - const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ -#endif -#endif ); void IVAS_DEC_Close( diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 020dd27cfa..ebd7c737a2 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -139,22 +139,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hBinaural->ChCrossImOutPrev, nBins ); hBinaural->renderStereoOutputInsteadOfBinaural = 0; -#ifdef FIX_107_5MS_SUBFRAME_RENDERING hBinaural->useSubframeMode = 1; -#else - if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR ) /* Use subframe-mode with SPAR, since the metadata is not in sync on a frame level */ - { - hBinaural->useSubframeMode = 1; - } - else - { -#ifdef DEBUGGING - hBinaural->useSubframeMode = st_ivas->hDecoderConfig->forceSubframeBinauralization; -#else - hBinaural->useSubframeMode = 0; /* Default to 20 ms mode. */ -#endif - } -#endif hBinaural->useTdDecorr = 0; if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index eae8c6d0d0..63b79cf2af 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2237,9 +2237,6 @@ static ivas_error initMasaDummyDecForMcOut( { return error; } -#ifndef FIX_107_5MS_SUBFRAME_RENDERING - decDummy->hDiracDecBin->useSubframeMode = 0; /* Todo Nokia: This will disappear in later work but needs to be this now. */ -#endif } numCldfbAnalyses = decDummy->nchan_transport; @@ -2372,11 +2369,6 @@ static ivas_error initMasaDummyDecForBinauralOut( } decDummy->ivas_format = MASA_FORMAT; decDummy->transport_config = AUDIO_CONFIG_INVALID; -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - decDummy->hDecoderConfig->forceSubframeBinauralization = 0; -#endif -#endif if ( ( error = ivas_dirac_dec_open( decDummy ) ) != IVAS_ERR_OK ) { @@ -2393,9 +2385,6 @@ static ivas_error initMasaDummyDecForBinauralOut( return error; } -#ifndef FIX_107_5MS_SUBFRAME_RENDERING - decDummy->hDiracDecBin->useSubframeMode = 0; /* Todo Nokia: This will disappear in later work but needs to be this now. */ -#endif for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { -- GitLab From 7e2c9ae2534c5f482584c47853506ff6b7265cfa Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:14:24 +0100 Subject: [PATCH 14/24] [cleanup] accept PARAM_ISM_DTX_CNG --- lib_com/ivas_cnst.h | 8 ---- lib_com/ivas_prot.h | 4 -- lib_com/options.h | 1 - lib_com/prot.h | 4 -- lib_dec/acelp_core_dec.c | 14 ------ lib_dec/fd_cng_dec.c | 37 ---------------- lib_dec/init_dec.c | 2 - lib_dec/ivas_core_dec.c | 4 -- lib_dec/ivas_dec.c | 2 - lib_dec/ivas_init_dec.c | 6 --- lib_dec/ivas_ism_dec.c | 2 - lib_dec/ivas_ism_dtx_dec.c | 2 - lib_dec/ivas_ism_metadata_dec.c | 2 - lib_dec/ivas_ism_param_dec.c | 77 --------------------------------- lib_dec/ivas_sce_dec.c | 10 ----- lib_dec/ivas_stat_dec.h | 4 -- lib_dec/ivas_tcx_core_dec.c | 6 --- lib_dec/stat_dec.h | 2 - lib_enc/acelp_core_enc.c | 4 -- lib_enc/fd_cng_enc.c | 4 -- lib_enc/init_enc.c | 6 --- lib_enc/ivas_cpe_enc.c | 4 -- lib_enc/ivas_init_enc.c | 6 --- lib_enc/ivas_ism_dtx_enc.c | 2 - lib_enc/ivas_ism_enc.c | 45 ------------------- lib_enc/ivas_ism_param_enc.c | 2 - lib_enc/ivas_sce_enc.c | 4 -- lib_enc/ivas_spar_encoder.c | 4 -- lib_enc/ivas_stat_enc.h | 4 -- lib_enc/ivas_tcx_core_enc.c | 4 -- lib_enc/lib_enc.c | 11 ----- lib_enc/rst_enc.c | 4 -- 32 files changed, 291 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 04e11c4656..b382b66600 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -333,11 +333,9 @@ typedef enum #define PARAM_ISM_MAX_CHAN 16 #define PARAM_ISM_HYS_BUF_SIZE 10 -#ifdef PARAM_ISM_DTX_CNG #define PARAM_ISM_DTX_COH_SCA_BITS 4 #define PARAM_ISM_DTX_AZI_BITS 5 #define PARAM_ISM_DTX_ELE_BITS 4 -#endif typedef enum { @@ -353,18 +351,12 @@ enum IND_ISM_NUM_OBJECTS, IND_ISM_METADATA_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS, IND_ISM_VAD_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS, -#ifdef PARAM_ISM_DTX_CNG IND_ISM_SCE_ID_DTX = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS, IND_ISM_NOISY_SPEECH_FLAG, IND_ISM_DTX_COH_SCA, -#endif /* ------------- loop for objects -------------- */ -#ifdef PARAM_ISM_DTX_CNG TAG_ISM_LOOP_START = IND_ISM_DTX_COH_SCA + MAX_NUM_OBJECTS, -#else - TAG_ISM_LOOP_START = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS, - #endif IND_ISM_AZIMUTH_DIFF_FLAG = TAG_ISM_LOOP_START, IND_ISM_AZIMUTH = TAG_ISM_LOOP_START, IND_ISM_ELEVATION_DIFF_FLAG = TAG_ISM_LOOP_START, diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8982d3d4d6..9ed187ca42 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -500,11 +500,9 @@ void stereo_tcx_core_dec( const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ const int16_t nchan_out /* i : number of output channels */ -#ifdef PARAM_ISM_DTX_CNG , const IVAS_FORMAT ivas_format, /* i : IVAS format */ const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ -#endif ); void stereo_tcx_init_dec( @@ -892,7 +890,6 @@ void ivas_param_ism_params_to_masa_param_mapping( ); -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX prototypes *----------------------------------------------------------------------------------*/ @@ -940,7 +937,6 @@ void ivas_ism_coh_estim_dtx_enc( const int16_t nchan_transport, /* i : number of transport channels */ const int16_t input_frame /* i : input frame length */ ); -#endif /*----------------------------------------------------------------------------------* * DFT Stereo prototypes diff --git a/lib_com/options.h b/lib_com/options.h index e482b2189e..fa106a83c5 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -143,7 +143,6 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define PARAM_ISM_DTX_CNG /* FhG: contribution 9 - DTX-CNG for ParamISM */ #define FIX_331_SBA_HBR_HOA_FIXES /* DLB: issue 331 - fix addressing low frequency stuttering with HOA inputs at high bitrates */ #ifdef FIX_331_SBA_HBR_HOA_FIXES diff --git a/lib_com/prot.h b/lib_com/prot.h index 16d069759f..69cc4e0d32 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2229,10 +2229,8 @@ ivas_error init_encoder( const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ -#ifdef PARAM_ISM_DTX_CNG , const ISM_MODE ism_mode /* i : ISM mode */ -#endif ); void LPDmem_enc_init( @@ -8524,10 +8522,8 @@ void generate_comfort_noise_dec_hf( float **bufferReal, /* o : Real part of input bands */ float **bufferImag, /* o : Imaginary part of input bands */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef PARAM_ISM_DTX_CNG , const int16_t cng_flag /*i : CNG Flag */ -#endif ); void generate_masking_noise( diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 571311ed12..b0d30e88dd 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -512,11 +512,7 @@ ivas_error acelp_core_dec( } else { -#ifdef PARAM_ISM_DTX_CNG if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT && st->read_sid_info ) -#else - if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT ) -#endif { FdCng_decodeSID( st ); *sid_bw = 0; @@ -532,7 +528,6 @@ ivas_error acelp_core_dec( } ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } -#ifdef PARAM_ISM_DTX_CNG if ( !st->read_sid_info ) // if (!st->read_sid_info && st->cng_paramISM_flag) /* read_sid_info can only be 0 in ParamISM mode */ { @@ -544,7 +539,6 @@ ivas_error acelp_core_dec( st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest; } } -#endif generate_comfort_noise_dec( NULL, NULL, st, nchan_out ); @@ -1131,11 +1125,7 @@ ivas_error acelp_core_dec( st->lp_noise = st->hFdCngDec->lp_noise; } -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode != IVAS_CPE_TD && !st->cng_paramISM_flag ) -#else - if ( st->element_mode != IVAS_CPE_TD ) -#endif { /*Noise estimate*/ ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); @@ -1311,11 +1301,7 @@ ivas_error acelp_core_dec( /*WB/SWB-FD_CNG*/ if ( ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && ( st->cng_type == FD_CNG ) && ( st->hFdCngDec->hFdCngCom->numCoreBands < st->cldfbSyn->no_channels ) ) { -#ifdef PARAM_ISM_DTX_CNG generate_comfort_noise_dec_hf( realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom, st->cng_paramISM_flag ); -#else - generate_comfort_noise_dec_hf( realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom ); -#endif if ( st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels ) { diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 515188369c..0620b09d5f 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1091,11 +1091,7 @@ void generate_comfort_noise_dec( c2 = (float) sqrt( 1 - hFdCngCom->coherence ); seed2 = &( hFdCngCom->seed2 ); -#ifdef PARAM_ISM_DTX_CNG if ( ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) -#endif { seed2 = &( hFdCngCom->seed3 ); } @@ -1105,11 +1101,7 @@ void generate_comfort_noise_dec( if ( hFdCngCom->startBand == 0 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1134,11 +1126,7 @@ void generate_comfort_noise_dec( for ( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ ) { /* Real part in FFT bins */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1152,11 +1140,7 @@ void generate_comfort_noise_dec( ptr_r += 2; /* Imaginary part in FFT bins */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1234,11 +1218,7 @@ void generate_comfort_noise_dec( for ( i = 0; i < hFdCngCom->numSlots; i++ ) { /* Real part in CLDFB band */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1251,11 +1231,7 @@ void generate_comfort_noise_dec( bufferReal[i][j] *= (float) sqrt( ( scaleCldfb * *ptr_level ) * 0.5f ); /* Imaginary part in CLDFB band */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1355,10 +1331,8 @@ void generate_comfort_noise_dec_hf( float **bufferReal, /* o : Real part of input bands */ float **bufferImag, /* o : Imaginary part of input bands */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef PARAM_ISM_DTX_CNG , const int16_t cng_coh_flag /* i : CNG Flag for coherence handling */ -#endif ) { int16_t i, j; @@ -1367,7 +1341,6 @@ void generate_comfort_noise_dec_hf( int16_t *seed = &( hFdCngCom->seed ); float scale = CLDFB_SCALING / hFdCngCom->scalingFactor; -#ifdef PARAM_ISM_DTX_CNG int16_t *seed2 = &( hFdCngCom->seed ); float tmp1, tmp2, c1 = 0.f, c2 = 0.f; @@ -1378,7 +1351,6 @@ void generate_comfort_noise_dec_hf( c1 = (float) sqrt( hFdCngCom->coherence ); c2 = (float) sqrt( 1 - hFdCngCom->coherence ); } -#endif ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; /* @@ -1391,7 +1363,6 @@ void generate_comfort_noise_dec_hf( { for ( i = 0; i < hFdCngCom->numSlots; i++ ) { -#ifdef PARAM_ISM_DTX_CNG if ( cng_coh_flag ) { /* Real part in CLDFB band */ @@ -1415,14 +1386,6 @@ void generate_comfort_noise_dec_hf( rand_gauss( &bufferImag[i][j], seed ); bufferImag[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); } -#else - /* Real part in CLDFB band */ - rand_gauss( &bufferReal[i][j], seed ); - bufferReal[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - /* Imaginary part in CLDFB band */ - rand_gauss( &bufferImag[i][j], seed ); - bufferImag[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); -#endif } ptr_level++; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 402fdc78f5..ca3c88b8d1 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -738,10 +738,8 @@ ivas_error init_decoder( st->tdm_LRTD_flag = 0; st->cna_dirac_flag = 0; st->cng_sba_flag = 0; -#ifdef PARAM_ISM_DTX_CNG st->cng_paramISM_flag = 0; st->read_sid_info = 1; /* by default read the sid info from bitstream */ -#endif return error; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 929e8187e7..f1a897351f 100755 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -341,11 +341,7 @@ ivas_error ivas_core_dec( if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) { /* TCX decoder */ -#ifdef PARAM_ISM_DTX_CNG stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format, st_ivas == NULL ? 0 : st_ivas->ism_mode ); -#else - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out ); -#endif } if ( st->core == HQ_CORE ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 38486a340b..b51eacd1ba 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -140,7 +140,6 @@ ivas_error ivas_dec( else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Metadata decoding and configuration */ -#ifdef PARAM_ISM_DTX_CNG if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -149,7 +148,6 @@ ivas_error ivas_dec( } } else -#endif if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1c1a44ea53..70768d6e0f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -402,7 +402,6 @@ static ivas_error ivas_read_format( break; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_DISC ) { @@ -413,9 +412,6 @@ static ivas_error ivas_read_format( { ivas_ism_dec_config( st_ivas, st_ivas->nSCE ); /* for Param-ISM, we need to generate 2 TCs */ } -#else - ivas_ism_dec_config( st_ivas, 1 ); /* currently DTX supported for 1ISM only */ -#endif break; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; @@ -837,12 +833,10 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2; } -#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 6babce65b4..28a36d36d4 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -293,13 +293,11 @@ ivas_error ivas_ism_dec_config( } else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { -#ifdef PARAM_ISM_DTX_CNG if ( last_ism_mode == ISM_MODE_PARAM ) { nchan_transport_old = MAX_PARAM_ISM_WAVE; } else -#endif { st_ivas->nchan_transport = num_obj; } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index bd15569f9e..b9d00792df 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -40,7 +40,6 @@ #include "wmc_auto.h" -#ifdef PARAM_ISM_DTX_CNG /*-------------------------------------------------------------------* * ivas_ism_preprocessing() * @@ -170,4 +169,3 @@ ivas_error ivas_ism_dtx_dec( return IVAS_ERR_OK; } -#endif diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 53c1e9d2e9..b60f66bdfb 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -502,12 +502,10 @@ ivas_error ivas_ism_metadata_dec( hSCE[ch]->hCoreCoder[0]->bit_stream = hSCE[ch - 1]->hCoreCoder[0]->bit_stream + ( hSCE[ch - 1]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC ); } -#ifdef PARAM_ISM_DTX_CNG for ( ch = 0; ch < *nchan_transport; ch++ ) { hSCE[ch]->hCoreCoder[0]->cng_paramISM_flag = 0; } -#endif pop_wmops(); diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 81a4744726..43ae3cf072 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -158,9 +158,7 @@ static void ivas_ism_get_proto_matrix( static void ivas_param_ism_compute_mixing_matrix( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ -#ifdef PARAM_ISM_DTX_CNG ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ -#endif float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], @@ -188,11 +186,7 @@ static void ivas_param_ism_compute_mixing_matrix( assert( ( hDirAC->hParamIsm->num_obj == 3 ) || ( hDirAC->hParamIsm->num_obj == 4 ) ); assert( nchan_transport == 2 ); -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { num_wave = hDirAC->hParamIsm->num_obj; } @@ -214,11 +208,7 @@ static void ivas_param_ism_compute_mixing_matrix( { set_zero( cy_diag_tmp[w], nchan_out_woLFE ); -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { dir_res_ptr = direct_response[w]; } @@ -257,11 +247,7 @@ static void ivas_param_ism_compute_mixing_matrix( set_zero( cy_diag, nchan_out_woLFE ); for ( w = 0; w < num_wave; w++ ) { -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { direct_power[w] = ( 1.0f / hDirAC->hParamIsm->num_obj ) * ref_power; } @@ -619,9 +605,7 @@ ivas_error ivas_param_ism_dec_open( } } -#ifdef PARAM_ISM_DTX_CNG st_ivas->hISMDTX.dtx_flag = 0; -#endif st_ivas->hDirAC = hDirAC; @@ -817,9 +801,7 @@ void ivas_param_ism_dec( { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t subframe_idx, slot_idx, index_slot, bin_idx; -#ifdef PARAM_ISM_DTX_CNG int32_t ivas_total_brate; -#endif /* CLDFB Input Buffers */ float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -856,9 +838,7 @@ void ivas_param_ism_dec( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } -#ifdef PARAM_ISM_DTX_CNG ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; -#endif hSetup = st_ivas->hIntSetup; @@ -866,7 +846,6 @@ void ivas_param_ism_dec( /* Frame-level Processing */ /* De-quantization */ -#ifdef PARAM_ISM_DTX_CNG if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) { ivas_param_ism_dec_dequant_DOA( hDirAC ); @@ -877,10 +856,6 @@ void ivas_param_ism_dec( { st_ivas->hISMDTX.dtx_flag = 1; } -#else - ivas_param_ism_dec_dequant_DOA( hDirAC ); - ivas_param_ism_dec_dequant_powrat( hDirAC ); -#endif /* obtain the direct response using EFAP */ if ( !( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) ) @@ -943,11 +918,7 @@ void ivas_param_ism_dec( } /* Compute mixing matrix */ -#ifdef PARAM_ISM_DTX_CNG ivas_param_ism_compute_mixing_matrix( hDirAC, st_ivas->hISMDTX, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, direct_response, nchan_transport, nchan_out_woLFE, 0, CLDFB_NO_COL_MAX, mixing_matrix ); -#else - ivas_param_ism_compute_mixing_matrix( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, direct_response, nchan_transport, nchan_out_woLFE, 0, CLDFB_NO_COL_MAX, mixing_matrix ); -#endif /* subframe loop for synthesis*/ for ( subframe_idx = 0; subframe_idx < hDirAC->nb_subframes; subframe_idx++ ) @@ -1053,14 +1024,11 @@ void ivas_param_ism_params_to_masa_param_mapping( int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; -#ifdef PARAM_ISM_DTX_CNG int32_t ivas_total_brate; -#endif hDirAC = st_ivas->hDirAC; nBins = hDirAC->num_freq_bands; -#ifdef PARAM_ISM_DTX_CNG ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) @@ -1073,14 +1041,9 @@ void ivas_param_ism_params_to_masa_param_mapping( { st_ivas->hISMDTX.dtx_flag = 1; } -#else - ivas_param_ism_dec_dequant_DOA( hDirAC ); - ivas_param_ism_dec_dequant_powrat( hDirAC ); -#endif if ( hDirAC->hParamIsm->num_obj > 1 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; @@ -1142,44 +1105,6 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } -#else - hDirAC->numSimultaneousDirections = 2; - for ( band_idx = 0; band_idx < hDirAC->hParamIsm->nbands; band_idx++ ) - { - brange[0] = hDirAC->hParamIsm->band_grouping[band_idx]; - brange[1] = hDirAC->hParamIsm->band_grouping[band_idx + 1]; - - azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[hDirAC->hParamIsm->obj_indices[band_idx][0][0]] ); - elevation[0] = (int16_t) roundf( hDirAC->elevation_values[hDirAC->hParamIsm->obj_indices[band_idx][0][0]] ); - power_ratio[0] = hDirAC->power_ratios[band_idx][0][0]; - - azimuth[1] = (int16_t) roundf( hDirAC->azimuth_values[hDirAC->hParamIsm->obj_indices[band_idx][0][1]] ); - elevation[1] = (int16_t) roundf( hDirAC->elevation_values[hDirAC->hParamIsm->obj_indices[band_idx][0][1]] ); - power_ratio[1] = hDirAC->power_ratios[band_idx][0][1]; - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) - { - hDirAC->azimuth[sf_idx][bin_idx] = azimuth[0]; - hDirAC->elevation[sf_idx][bin_idx] = elevation[0]; - hDirAC->energy_ratio1[sf_idx][bin_idx] = power_ratio[0]; - hDirAC->azimuth2[sf_idx][bin_idx] = azimuth[1]; - hDirAC->elevation2[sf_idx][bin_idx] = elevation[1]; - hDirAC->energy_ratio2[sf_idx][bin_idx] = power_ratio[1]; - } - } - } - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) - { - hDirAC->spreadCoherence[sf_idx][bin_idx] = 0.0f; - hDirAC->spreadCoherence2[sf_idx][bin_idx] = 0.0f; - hDirAC->surroundingCoherence[sf_idx][bin_idx] = 0.0; - } - } -#endif } else { @@ -1203,7 +1128,6 @@ void ivas_param_ism_params_to_masa_param_mapping( } -#ifdef PARAM_ISM_DTX_CNG static void ivas_param_ism_dec_dequantize_DOA_dtx( int16_t azi_bits, int16_t ele_bits, @@ -1334,4 +1258,3 @@ void ivas_param_ism_metadata_dtx_dec( return; } -#endif diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ac948a59c4..228a6e7b3a 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -77,12 +77,10 @@ ivas_error ivas_sce_dec( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st->cng_type = FD_CNG; /* TODO: move to init if possible */ } -#endif /*------------------------------------------------------------------* * Read audio bandwidth info @@ -100,15 +98,11 @@ ivas_error ivas_sce_dec( } else if ( !st_ivas->bfi && ( last_ivas_total_brate <= SID_2k40 || last_ivas_total_brate == IVAS_SID_5k2 ) ) { -#ifdef PARAM_ISM_DTX_CNG /* check if this is indeed needed? */ if ( st_ivas->ivas_format != ISM_FORMAT ) { st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; } -#else - st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; -#endif } /* read the bandwidth */ @@ -229,11 +223,7 @@ ivas_error ivas_sce_dec( * Decoder *----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_core_dec( NULL, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index fa61493818..5243763844 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -382,7 +382,6 @@ typedef struct stereo_icbwe_dec_data_structure } STEREO_ICBWE_DEC_DATA, *STEREO_ICBWE_DEC_HANDLE; -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX structure *----------------------------------------------------------------------------------*/ @@ -393,7 +392,6 @@ typedef struct int16_t sce_id_dtx; } ISM_DTX_DATA_DEC; -#endif /*----------------------------------------------------------------------------------* * DirAC decoder structure @@ -1203,9 +1201,7 @@ typedef struct Decoder_Struct /* multichannel modules */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */ -#ifdef PARAM_ISM_DTX_CNG ISM_DTX_DATA_DEC hISMDTX; /* ISM DTX structure */ -#endif ISM_RENDERER_HANDLE hIsmRendererData; /* ISM renderer handle */ DIRAC_DEC_HANDLE hDirAC; /* DirAC handle */ SPAR_DEC_HANDLE hSpar; /* SPAR handle */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 378ddec9aa..b8d96233db 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -161,11 +161,9 @@ void stereo_tcx_core_dec( const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ const int16_t nchan_out /* i : number of output channels */ -#ifdef PARAM_ISM_DTX_CNG , const IVAS_FORMAT ivas_format, /* i : IVAS format */ const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ -#endif ) { int16_t i, k; @@ -729,7 +727,6 @@ void stereo_tcx_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { -#ifdef PARAM_ISM_DTX_CNG if ( ivas_format == ISM_FORMAT && ism_mode == ISM_MODE_PARAM ) { float buffer[L_FRAME16k]; @@ -740,9 +737,6 @@ void stereo_tcx_core_dec( { ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); } -#else - ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); -#endif } /* Generate additional comfort noise to mask potential coding artefacts */ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 0950b529f6..9ba901352c 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1345,10 +1345,8 @@ typedef struct Decoder_State /* MCT Channel mode indication: LFE, ignore channel? */ MCT_CHAN_MODE mct_chan_mode; -#ifdef PARAM_ISM_DTX_CNG int16_t cng_paramISM_flag; /* CNG in Param-ISM flag */ int16_t read_sid_info; /* For ParamISM, use the transmitted noise */ -#endif } Decoder_State, *DEC_CORE_HANDLE; diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 272d36fb9c..48cdb5c536 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -314,17 +314,13 @@ ivas_error acelp_core_enc( if ( st->core_brate == SID_2k40 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif tmpF = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, exc, st->L_frame ); i = (int16_t) ( ( tmpF + 2.0f ) * STEP_SID ); i = min( max( i, 0 ), 127 ); st->hTdCngEnc->old_enr_index = i; -#ifdef PARAM_ISM_DTX_CNG } -#endif } } diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 5789f0dfd9..e43b65d56a 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -708,18 +708,14 @@ void generate_comfort_noise_enc( /* Perform STFT synthesis */ SynthesisSTFT( fftBuffer, timeDomainOutput, hFdCngCom->olapBufferSynth, hFdCngCom->olapWinSyn, tcx_transition, hFdCngCom, -1, -1 ); -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif /* update CNG excitation energy for LP_CNG */ /* calculate the residual signal energy */ enr = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, hFdCngCom->exc_cng, hFdCngCom->frameSize ); st->hTdCngEnc->lp_ener = (float) ( 0.8f * st->hTdCngEnc->lp_ener + 0.2f * pow( 2.0f, enr ) ); -#ifdef PARAM_ISM_DTX_CNG } -#endif /* Overlap-add when previous frame is active */ if ( st->last_core_brate > SID_2k40 && st->codec_mode == MODE2 ) diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 683356c6c0..7019beca8e 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -59,10 +59,8 @@ ivas_error init_encoder( const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ -#ifdef PARAM_ISM_DTX_CNG , const ISM_MODE ism_mode /* i : ISM mode */ -#endif ) { int16_t i; @@ -466,11 +464,7 @@ ivas_error init_encoder( * LP-CNG *-----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( ( ( idchan == 0 && st->Opt_DTX_ON && st->element_mode != IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && !( ism_mode == ISM_MODE_PARAM ) ) -#else - if ( ( ( idchan == 0 && st->Opt_DTX_ON && st->element_mode != IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) ) -#endif { if ( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 323d99ae3a..f9b787ac56 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -832,11 +832,7 @@ ivas_error create_cpe_enc( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( st, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( st, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index c729511e70..2fadc22637 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -276,10 +276,8 @@ void ivas_initialize_handles_enc( st_ivas->hIsmMetaData[i] = NULL; } -#ifdef PARAM_ISM_DTX_CNG /* ISM DTX handle */ st_ivas->hISMDTX = NULL; -#endif /* Q Metadata handle */ st_ivas->hQMetaData = NULL; @@ -437,7 +435,6 @@ ivas_error ivas_init_encoder( } } -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->hEncoderConfig->Opt_DTX_ON && st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -445,7 +442,6 @@ ivas_error ivas_init_encoder( return error; } } -#endif } else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) { @@ -933,14 +929,12 @@ void ivas_destroy_enc( } } -#ifdef PARAM_ISM_DTX_CNG /* ISM DTX Handle */ if ( st_ivas->hISMDTX != NULL ) { free( st_ivas->hISMDTX ); st_ivas->hISMDTX = NULL; } -#endif /* Q Metadata handle */ ivas_qmetadata_close( &( st_ivas->hQMetaData ) ); diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 2fea85e44a..fe358f6c90 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -41,7 +41,6 @@ #endif #include "wmc_auto.h" -#ifdef PARAM_ISM_DTX_CNG /*-------------------------------------------------------------------* * ivas_ism_dtx_open() @@ -333,4 +332,3 @@ void ivas_ism_coh_estim_dtx_enc( return; } -#endif diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 7cfe962bc7..14b52bd0ee 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -86,9 +86,7 @@ ivas_error ivas_ism_enc( float lf_E[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ int16_t localVAD_HE_SAD[1]; /* local HE VAD */ int16_t i, nBits; -#ifdef PARAM_ISM_DTX_CNG int16_t dtx_flag, sid_flag; -#endif ivas_error error; push_wmops( "ivas_ism_enc" ); @@ -99,10 +97,8 @@ ivas_error ivas_ism_enc( error = IVAS_ERR_OK; -#ifdef PARAM_ISM_DTX_CNG dtx_flag = 0; sid_flag = 0; -#endif /*------------------------------------------------------------------* * Preprocesing @@ -171,7 +167,6 @@ ivas_error ivas_ism_enc( vad_flag[sce_id] = st->vad_flag; } -#ifdef PARAM_ISM_DTX_CNG /*------------------------------------------------------------------* * DTX analysis *-----------------------------------------------------------------*/ @@ -195,14 +190,12 @@ ivas_error ivas_ism_enc( dbgwrite( &( st_ivas->hISMDTX->dtx_flag ), sizeof( int16_t ), 1, 1, "./res/ParamISM_DTX_CNG_flag_enc.dat" ); #endif } -#endif /*------------------------------------------------------------------* * Analysis of objects, configuration and decision about bitrates per channel * Metadata quantization and encoding *-----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_param_ism_compute_noisy_speech_flag( st_ivas ); @@ -216,40 +209,8 @@ ivas_error ivas_ism_enc( } } else -#endif if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { -#ifndef PARAM_ISM_DTX_CNG - /* Move the Noisy speech buffer */ - for ( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ ) - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i + 1]; - } - - /* For the current frame, make a decision based on some core-coder flags */ - if ( st_ivas->hSCE[0]->hCoreCoder[0]->flag_noisy_speech_snr && st_ivas->hSCE[1]->hCoreCoder[0]->flag_noisy_speech_snr ) - { - if ( st_ivas->hSCE[0]->hCoreCoder[0]->vad_flag || st_ivas->hSCE[1]->hCoreCoder[0]->vad_flag ) - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; - } - else - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 1; - } - } - else - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; - } - - /* Do a decision based on hysterisis */ - st_ivas->hDirAC->hParamIsm->flag_noisy_speech = 1; - for ( i = 0; i < PARAM_ISM_HYS_BUF_SIZE; i++ ) - { - st_ivas->hDirAC->hParamIsm->flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech && st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i]; - } -#endif ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); } else /* ISM_MODE_DISC */ @@ -267,9 +228,7 @@ ivas_error ivas_ism_enc( { ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode != ISM_MODE_PARAM ) -#endif { /* write unused bits */ nBits = ( IVAS_SID_5k2 - SID_2k40 ) / 50 - SID_FORMAT_NBITS; @@ -321,9 +280,7 @@ ivas_error ivas_ism_enc( * Encoder *----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( !dtx_flag || ( dtx_flag && sce_id == st_ivas->hISMDTX->sce_id_dtx ) ) -#endif { if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], ener[sce_id], A[sce_id], Aw[sce_id], epsP[sce_id], lsp_new[sce_id], lsp_mid[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer[sce_id], imagBuffer[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum[sce_id], vad_flag_dtx[sce_id], enerBuffer[sce_id], fft_buff[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) { @@ -342,7 +299,6 @@ ivas_error ivas_ism_enc( st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; } -#ifdef PARAM_ISM_DTX_CNG if ( dtx_flag ) { for ( sce_id = 0; sce_id < st_ivas->nchan_transport; sce_id++ ) @@ -354,7 +310,6 @@ ivas_error ivas_ism_enc( } } } -#endif pop_wmops(); diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 2397e68eaf..fb69537bc2 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -399,7 +399,6 @@ void ivas_param_ism_enc( } -#ifdef PARAM_ISM_DTX_CNG static void ivas_param_ism_enc_quantize_DOA_dtx( float azimuth, float elevation, @@ -572,4 +571,3 @@ void ivas_param_ism_compute_noisy_speech_flag( return; } -#endif diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 48bea12e53..c8577a85ba 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -332,11 +332,7 @@ ivas_error create_sce_enc( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( st, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( st, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e5ed9ff9ff..d773a9ed61 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -203,11 +203,7 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index e450990254..8949dac71a 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -550,7 +550,6 @@ typedef struct ivas_stereo_classifier_data_structure } STEREO_CLASSIF_DATA, *STEREO_CLASSIF_HANDLE; -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX structure *----------------------------------------------------------------------------------*/ @@ -566,7 +565,6 @@ typedef struct float coh[MAX_NUM_OBJECTS]; } ISM_DTX_DATA, *ISM_DTX_HANDLE; -#endif /*----------------------------------------------------------------------------------* * Front-VAD structure @@ -1071,9 +1069,7 @@ typedef struct /* multichannel modules */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */ -#ifdef PARAM_ISM_DTX_CNG ISM_DTX_HANDLE hISMDTX; /* ISM DTX handle */ -#endif DIRAC_ENC_HANDLE hDirAC; /* DirAC data handle */ SPAR_ENC_HANDLE hSpar; /* SPAR encoder handle */ MASA_ENCODER_HANDLE hMasa; /* MASA encoder data and configuration */ diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 3971c6740e..40a97cc33e 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -457,11 +457,7 @@ void stereo_tcx_core_enc( mvr2r( lsp_q, st->lsp_old, M ); } -#ifdef PARAM_ISM_DTX_CNG if ( st->Opt_DTX_ON && !st->tcxonly && st->hTdCngEnc != NULL ) -#else - if ( st->Opt_DTX_ON && !st->tcxonly ) -#endif { /* update CNG parameters in active frames */ if ( st->bwidth == NB && st->enableTcxLpc && st->core != ACELP_CORE ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 7ed8d4f2ec..373a6f7950 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -873,7 +873,6 @@ static ivas_error configureEncoder( return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz input sampling rate is not supported in IVAS." ); } -#ifdef PARAM_ISM_DTX_CNG if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && ( ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp == 2 ) || // ToDo: see Issue 113 ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp > 2 && hEncoderConfig->ivas_total_brate != IVAS_24k4 && hEncoderConfig->ivas_total_brate != IVAS_32k ) || // ParamISM @@ -881,14 +880,6 @@ static ivas_error configureEncoder( ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD ) ) -#else - if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && - ( ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp > 1 ) || // ToDo: see Issue 113 - ( hEncoderConfig->ivas_format == MASA_FORMAT && hEncoderConfig->ivas_total_brate > IVAS_128k ) || // ToDo: remove the bitrate limitation - ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done - hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD - ) ) -#endif { return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); } @@ -919,12 +910,10 @@ static ivas_error configureEncoder( return error; } -#ifdef PARAM_ISM_DTX_CNG if ( hEncoderConfig->Opt_DTX_ON && ( hEncoderConfig->ivas_format == ISM_FORMAT ) && !( st_ivas->ism_mode == ISM_MODE_DISC && hEncoderConfig->nchan_inp == 1 ) && !( st_ivas->ism_mode == ISM_MODE_PARAM && ( hEncoderConfig->nchan_inp == 3 || hEncoderConfig->nchan_inp == 4 ) ) ) { return IVAS_ERROR( IVAS_ERR_UNKNOWN, "DTX is not supported in this IVAS format and element mode." ); } -#endif if ( hEncoderConfig->ivas_format == MONO_FORMAT ) { diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c index 2f19c41665..3a20418759 100644 --- a/lib_enc/rst_enc.c +++ b/lib_enc/rst_enc.c @@ -84,15 +84,11 @@ void CNG_reset_enc( set_f( voice_factors, 1.0, NB_SUBFR16k ); -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif /* Reset active frame counter */ st->hTdCngEnc->act_cnt2 = 0; -#ifdef PARAM_ISM_DTX_CNG } -#endif /* deactivate bass post-filter */ st->bpf_off = 1; -- GitLab From ba7f2f7983ce5ba0a13b46a53a50adb4e391643d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:16:46 +0100 Subject: [PATCH 15/24] [cleanup] accept FIX_331_SBA_HBR_HOA_FIXES, COV_SMOOTH_TUNING, SBA_HPF_TUNING_ENC, SMOOTH_WITH_TRANS_DET --- lib_com/ivas_cov_smooth.c | 33 --------------------------------- lib_com/ivas_prot.h | 16 ---------------- lib_com/ivas_transient_det.c | 29 ----------------------------- lib_com/options.h | 6 ------ lib_dec/ivas_spar_decoder.c | 19 ------------------- lib_enc/ivas_enc.c | 2 -- lib_enc/ivas_enc_cov_handler.c | 8 -------- lib_enc/ivas_init_enc.c | 4 ---- lib_enc/ivas_sba_enc.c | 4 ---- lib_enc/ivas_spar_encoder.c | 8 -------- 10 files changed, 129 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 57f74fb70e..48ca292e8e 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -39,9 +39,7 @@ #include "wmc_auto.h" #include "prot.h" -#ifdef SMOOTH_WITH_TRANS_DET #define BAND_SMOOTH_REST_START_IDX ( 2 ) -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -53,18 +51,14 @@ static void ivas_set_up_cov_smoothing( ivas_filterbank_t *pFb, const float max_update_rate, const int16_t min_pool_size -#ifdef COV_SMOOTH_TUNING , const int16_t nchan_inp /* i : number of input channels */ -#endif ) { int16_t j, k; -#ifdef COV_SMOOTH_TUNING if ( nchan_inp <= FOA_CHANNELS ) { -#endif for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { float update_factor; @@ -83,7 +77,6 @@ static void ivas_set_up_cov_smoothing( } } -#ifdef COV_SMOOTH_TUNING } else { @@ -107,7 +100,6 @@ static void ivas_set_up_cov_smoothing( } } } -#endif hCovState->prior_bank_idx = -1; return; @@ -153,10 +145,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( } ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size -#ifdef COV_SMOOTH_TUNING , nchan_inp -#endif ); *hCovState_out = hCovState; @@ -218,25 +208,18 @@ static void ivas_compute_smooth_cov( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ) { int16_t i, j, k; int16_t prev_idx = hCovState->prior_bank_idx; float factor = 0; -#ifdef SMOOTH_WITH_TRANS_DET int16_t sm_b; int16_t non_sm_b_idx; sm_b = BAND_SMOOTH_REST_START_IDX; -#endif assert( end_band <= pFb->filterbank_num_bands ); -#ifdef SMOOTH_WITH_TRANS_DET if ( prev_idx == -1 || transient_det[1] == 1 ) { for ( i = 0; i < num_ch; i++ ) @@ -277,18 +260,6 @@ static void ivas_compute_smooth_cov( } } } -#else - if ( prev_idx == -1 || transient_det == 1 ) - { - for ( i = 0; i < num_ch; i++ ) - { - for ( k = start_band; k < end_band; k++ ) - { - pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); - } - } - } -#endif else if ( prev_idx == 0 ) { for ( i = 0; i < num_ch; i++ ) @@ -329,11 +300,7 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ) { int16_t i, j; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9ed187ca42..c5b7cef5db 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4140,11 +4140,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t nchan_inp, const int16_t dtx_vad, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ); ivas_error ivas_spar_covar_smooth_enc_open( @@ -4166,11 +4162,7 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ); /* Transient detector module */ @@ -4183,20 +4175,12 @@ void ivas_transient_det_close( ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ ); -#ifdef SMOOTH_WITH_TRANS_DET void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ int16_t transient_det[2] /* o : transient det outputs */ ); -#else -int16_t ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len /* i : frame length in samples */ -); -#endif void ivas_td_decorr_get_ducking_gains( ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index e2f2dfb766..1e8f53c7ca 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -211,43 +211,17 @@ void ivas_transient_det_close( * * Transient detection process call *-----------------------------------------------------------------------------------------*/ -#ifdef SMOOTH_WITH_TRANS_DET void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ int16_t transient_det[2] /* o: transient det outputs */ ) -#else -int16_t ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len /* i : frame length in samples */ -) -#endif { -#ifdef SMOOTH_WITH_TRANS_DET float in_duck_gain[L_FRAME48k]; int16_t num_sf, sf, sf_samp, idx; -#else - int16_t trans; -#endif float mem = hTranDet->in_duck_gain; -#ifndef SMOOTH_WITH_TRANS_DET - ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, IVAS_TDET_ONLY ); - - if ( mem - hTranDet->in_duck_gain > IVAS_TDET_PARM_TRANS_THR ) - { - trans = 1; - } - else - { - trans = 0; - } - - return trans; -#else ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, in_duck_gain, NULL, frame_len, IVAS_TDET_ONLY ); transient_det[0] = 0; @@ -270,7 +244,6 @@ int16_t ivas_transient_det_process( } return; -#endif } @@ -344,9 +317,7 @@ void ivas_td_decorr_get_ducking_gains( for ( i = 0; i < frame_len; i++ ) { in_duck_gain = ivas_calc_duck_gain( in_duck_gain, in_duck_coeff, e_slow[i], e_fast[i], duck_mult_fac ); -#ifdef SMOOTH_WITH_TRANS_DET pIn_duck_gains[i] = in_duck_gain; -#endif } hTranDet->in_duck_gain = in_duck_gain; } diff --git a/lib_com/options.h b/lib_com/options.h index fa106a83c5..4db9738caa 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,13 +144,7 @@ -#define FIX_331_SBA_HBR_HOA_FIXES /* DLB: issue 331 - fix addressing low frequency stuttering with HOA inputs at high bitrates */ -#ifdef FIX_331_SBA_HBR_HOA_FIXES -#define COV_SMOOTH_TUNING -#define SBA_HPF_TUNING_ENC /*#define SBA_HPF_TUNING_DEC*/ -#define SMOOTH_WITH_TRANS_DET -#endif #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ #define FIX_351_HRTF_COMMAND /* VA: Issue 354 - improve "-hrtf" command-line option */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index dbab951140..6bf8b57f4c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -806,28 +806,18 @@ void ivas_spar_get_parameters( weight = ivas_spar_get_cldfb_slot_gain( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms ); -#ifdef COV_SMOOTH_TUNING split_band = SPAR_DIRAC_SPLIT_START_BAND; -#else - split_band = hSpar->hMdDec->spar_md.num_bands; -#endif for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) { -#ifndef COV_SMOOTH_TUNING - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) - { -#endif if ( split_band < IVAS_MAX_NUM_BANDS /* 20ms cross-fade for Transport channels in all frequency bands */ && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ ) { -#ifdef COV_SMOOTH_TUNING for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { -#endif if ( hSpar->i_subframe > 3 ) { par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + @@ -837,26 +827,17 @@ void ivas_spar_get_parameters( { par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; } -#ifdef COV_SMOOTH_TUNING } -#endif } else { -#ifdef COV_SMOOTH_TUNING for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { -#endif /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; -#ifdef COV_SMOOTH_TUNING } -#endif } -#ifndef COV_SMOOTH_TUNING - } -#endif } } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 0500a8e775..aff410fcab 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -132,13 +132,11 @@ ivas_error ivas_enc( /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) { -#ifdef SBA_HPF_TUNING_ENC if ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) { hp20( data_f[HOA_keep_ind[i]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } else -#endif if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index b70c05e962..1b366b86e8 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -150,11 +150,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ) { int16_t i, j; @@ -218,11 +214,7 @@ void ivas_enc_cov_handler_process( } else { -#ifdef SMOOTH_WITH_TRANS_DET if ( ( transient_det[0] == 0 ) && ( transient_det[1] == 0 ) ) -#else - if ( transient_det == 0 ) -#endif { ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, num_ch, transient_det ); hCovEnc->prior_dtx_present = 1; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 2fadc22637..766caa1519 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -184,11 +184,7 @@ int16_t getNumChanAnalysis( n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ) { -#ifdef SBA_HPF_TUNING_ENC n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); -#else - n = DIRAC_MAX_ANA_CHANS; -#endif } else if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_PARAMMC || st_ivas->mc_mode == MC_MODE_MCMASA ) ) { diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index d9cd39f7c0..11d9c3540f 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -120,9 +120,7 @@ ivas_error ivas_sba_enc_reconfigure( DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; SPAR_ENC_HANDLE hSpar; SBA_MODE sba_mode_old; -#ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; -#endif int16_t spar_reconfig_flag; spar_reconfig_flag = 0; @@ -134,7 +132,6 @@ ivas_error ivas_sba_enc_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); -#ifdef SBA_HPF_TUNING_ENC analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); if ( analysis_order_old != st_ivas->sba_analysis_order ) @@ -202,7 +199,6 @@ ivas_error ivas_sba_enc_reconfigure( old_mem_hp20_in = NULL; } } -#endif if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index d773a9ed61..5b81d91ea2 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -391,11 +391,7 @@ static ivas_error ivas_spar_enc_process( float pcm_tmp[IVAS_SPAR_MAX_CH][L_FRAME48k * 2]; float *p_pcm_tmp[IVAS_SPAR_MAX_CH]; int16_t i, j, b, i_ts, input_frame, dtx_vad; -#ifdef SMOOTH_WITH_TRANS_DET int16_t transient_det[2]; -#else - int16_t transient_det; -#endif int32_t ivas_total_brate, input_Fs; float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -438,15 +434,11 @@ static ivas_error ivas_spar_enc_process( * Transient detector *-----------------------------------------------------------------------------------------*/ -#ifdef SMOOTH_WITH_TRANS_DET ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame, transient_det ); if ( sba_order == 1 ) { transient_det[1] = transient_det[0]; } -#else - transient_det = ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame ); -#endif /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); -- GitLab From 61e8811388678bb1edcd183dbda152fb12864c4e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:17:36 +0100 Subject: [PATCH 16/24] [cleanup] accept FIX_351_HRTF_COMMAND --- apps/decoder.c | 8 -------- lib_com/options.h | 1 - lib_dec/ivas_stat_dec.h | 2 -- lib_dec/lib_dec.c | 8 -------- lib_dec/lib_dec.h | 2 -- 5 files changed, 21 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 40f6b47b23..fbb8922261 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -219,7 +219,6 @@ int main( if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { @@ -227,13 +226,10 @@ int main( fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK ) { -#ifdef FIX_351_HRTF_COMMAND arg.hrtfReaderEnabled = false; -#endif fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; } @@ -245,14 +241,12 @@ int main( if ( arg.enableHeadRotation ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = HeadRotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) { @@ -280,14 +274,12 @@ int main( if ( arg.renderConfigEnabled ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/options.h b/lib_com/options.h index 4db9738caa..b579595759 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ /*#define SBA_HPF_TUNING_DEC*/ #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ -#define FIX_351_HRTF_COMMAND /* VA: Issue 354 - improve "-hrtf" command-line option */ #define FIX_94_VERIFY_WAV_NUM_CHANNELS /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */ #define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5243763844..c4c37754fa 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1143,9 +1143,7 @@ typedef struct decoder_config_structure int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ -#ifdef FIX_351_HRTF_COMMAND int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ -#endif int16_t orientation_tracking; /* indicates orientation tracking type */ float no_diegetic_pan; int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d10b6d79d5..2fba6491d4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -223,9 +223,7 @@ static void init_decoder_config( hDecoderConfig->Opt_LsCustom = 0; hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; -#ifdef FIX_351_HRTF_COMMAND hDecoderConfig->Opt_RendConfigCustom = 0; -#endif hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->no_diegetic_pan = no_diegetic_pan; @@ -390,10 +388,8 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ -#ifdef FIX_351_HRTF_COMMAND , const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ -#endif ) { Decoder_Struct *st_ivas; @@ -442,9 +438,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled; -#ifdef FIX_351_HRTF_COMMAND hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled; -#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -1924,7 +1918,6 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); -#ifdef FIX_351_HRTF_COMMAND if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { fprintf( stdout, "HRIR/BRIR file: ON\n" ); @@ -1934,7 +1927,6 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Renderer config. file: ON\n" ); } -#endif if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index c0d74b077b..e9aba91f9e 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -130,9 +130,7 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ -#ifdef FIX_351_HRTF_COMMAND ,const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ -#endif ); -- GitLab From 465ceeaa78b307f025d117ac42fb7e2074ae4311 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:18:32 +0100 Subject: [PATCH 17/24] [cleanup] accept FIX_94_VERIFY_WAV_NUM_CHANNELS --- apps/encoder.c | 19 ----------------- apps/renderer.c | 28 ------------------------- lib_com/ivas_error.h | 2 -- lib_com/options.h | 1 - lib_enc/lib_enc.c | 2 -- lib_enc/lib_enc.h | 2 -- lib_util/audio_file_reader.c | 40 ------------------------------------ lib_util/audio_file_reader.h | 10 --------- 8 files changed, 104 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 5fb6100034..274c4099ab 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -213,23 +213,6 @@ int main( goto cleanup; } -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - /*------------------------------------------------------------------------------------------* - * Open input audio file - *------------------------------------------------------------------------------------------*/ - int32_t inFileSampleRate = 0; - if ( AudioFileReader_open( &audioReader, arg.inputWavFilename, &inFileSampleRate ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename ); - goto cleanup; - } - if ( inFileSampleRate != 0 && /* inFileSampleRate will remain zero if input file is raw PCM */ - inFileSampleRate != arg.inputFs ) - { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename ); - goto cleanup; - } -#endif /*------------------------------------------------------------------------------------------* * Open output bitstream file @@ -452,7 +435,6 @@ int main( goto cleanup; } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*------------------------------------------------------------------------------------------* * Open input audio file *------------------------------------------------------------------------------------------*/ @@ -511,7 +493,6 @@ int main( fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#endif /*------------------------------------------------------------------------------------------* * Open input metadata files diff --git a/apps/renderer.c b/apps/renderer.c index e7088a4316..1c9601b590 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -565,7 +565,6 @@ int main( setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders ); } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) { fprintf( stderr, "Error opening file: %s\n", audioFilePath ); @@ -609,28 +608,6 @@ int main( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } -#else - int32_t inFileSampleRate = 0; - if ( AudioFileReader_open( &audioReader, audioFilePath, &inFileSampleRate ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Error opening file: %s\n", audioFilePath ); - exit( -1 ); - } - if ( args.sampleRate == 0 && inFileSampleRate == 0 ) - { - fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); - exit( -1 ); - } - if ( args.sampleRate != 0 && inFileSampleRate != 0 && args.sampleRate != inFileSampleRate ) - { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); - exit( -1 ); - } - if ( args.sampleRate == 0 ) - { - args.sampleRate = inFileSampleRate; - } -#endif const int16_t frameSize_smpls = (int16_t) ( 20 * args.sampleRate / 1000 ); IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 }; @@ -798,12 +775,7 @@ int main( const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) -#else - if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */ - && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) ) -#endif { fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); exit( -1 ); diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index b384e8dee5..a0fe708361 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -123,10 +123,8 @@ typedef enum IVAS_ERR_BITSTREAM_WRITER_INVALID_FORMAT, IVAS_ERR_BITSTREAM_READER_INVALID_DATA, IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS IVAS_ERR_NO_FILE_OPEN, IVAS_ERR_SAMPLING_RATE_UNKNOWN, -#endif /*----------------------------------------* * renderer (lib_rend only) * diff --git a/lib_com/options.h b/lib_com/options.h index b579595759..4ce0b05847 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ /*#define SBA_HPF_TUNING_DEC*/ #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ -#define FIX_94_VERIFY_WAV_NUM_CHANNELS /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */ #define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ #define FIX_350_MASA_DELAY_COMP /* Nokia: Issue 350: MASA audio/meta delay compensation */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 373a6f7950..6beb889d00 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -983,7 +983,6 @@ static int16_t getInputBufferSize( return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*---------------------------------------------------------------------* * IVAS_ENC_GetNumInChannels() * @@ -1008,7 +1007,6 @@ ivas_error IVAS_ENC_GetNumInChannels( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 7430822642..9c16e69c75 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -298,13 +298,11 @@ ivas_error IVAS_ENC_GetDelay( int16_t *delay /* o : encoder delay */ ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*! r: encoder error code */ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ); -#endif /*! r: encoder error code */ ivas_error IVAS_ENC_GetInputBufferSize( diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index c7feefd7b7..f124c11169 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -40,9 +40,7 @@ struct AudioFileReader { FILE *rawFile; WAVEFILEIN *wavFile; -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS uint32_t samplingRate; -#endif int16_t numChannels; }; @@ -58,25 +56,12 @@ static int8_t AudioFileReader_open_raw( static int8_t AudioFileReader_open_wav( AudioFileReader *self, const char *fileName -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - int32_t *sampleRate -#endif ) { -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS uint32_t samplesInFile; -#else - uint32_t sampleRate_, samplesInFile; -#endif int16_t bps; -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS self->wavFile = OpenWav( fileName, &self->samplingRate, &self->numChannels, &samplesInFile, &bps ); -#else - self->wavFile = OpenWav( fileName, &sampleRate_, &self->numChannels, &samplesInFile, &bps ); - *sampleRate = sampleRate_; -#endif if ( !self->wavFile ) { @@ -92,10 +77,6 @@ static int8_t AudioFileReader_open_wav( ivas_error AudioFileReader_open( AudioFileReader **audioReader, /* o : AudioFileReader handle */ const char *fileName /* i : path to wav/raw pcm file */ -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - int32_t *sampleRate /* o : sample rate of wav file, unused with pcm */ -#endif ) { AudioFileReader *self; @@ -118,18 +99,12 @@ ivas_error AudioFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } self = calloc( sizeof( AudioFileReader ), 1 ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS self->samplingRate = 0; -#endif self->numChannels = 0; if ( fileNameLen > wavSuffixLen && strncmp( fileName + fileNameLen - wavSuffixLen, wavSuffix, wavSuffixLen ) == 0 ) { retCode = AudioFileReader_open_wav( self, fileName -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - sampleRate -#endif ); } else @@ -206,7 +181,6 @@ ivas_error AudioFileReader_read( return error; } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS ivas_error AudioFileReader_getSamplingRate( AudioFileReader *self, int32_t *samplingRate ) @@ -257,17 +231,3 @@ ivas_error AudioFileReader_getNumChannels( return IVAS_ERR_OK; } -#else -/*! r: number of channels of the opened file */ -int16_t AudioFileReader_getNumChannels( - AudioFileReader *self /* i/o: AudioFileReader handle */ -) -{ - if ( self != NULL ) - { - return self->numChannels; - } - - return 0; -} -#endif diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h index a944c85dc1..0fd4da5ac7 100644 --- a/lib_util/audio_file_reader.h +++ b/lib_util/audio_file_reader.h @@ -43,9 +43,6 @@ typedef struct AudioFileReader AudioFileReader; ivas_error AudioFileReader_open( AudioFileReader **audioReader, /* o : AudioFileReader handle */ const char *fileName /* i : path to wav/raw pcm file */ -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - ,int32_t *sampleRate /* o : sample rate of wav file, unused with pcm */ -#endif ); ivas_error AudioFileReader_read( @@ -55,7 +52,6 @@ ivas_error AudioFileReader_read( int16_t *numSamplesRead /* i : number of samples actualy read */ ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*! r: ivas error - in particular, IVAS_ERR_SAMPLING_RATE_UNKNOWN if the opened file has no sampling rate metadata */ ivas_error AudioFileReader_getSamplingRate( AudioFileReader *self, /* i/o: AudioFileReader handle */ @@ -67,12 +63,6 @@ ivas_error AudioFileReader_getNumChannels( AudioFileReader *self, /* i/o: AudioFileReader handle */ int16_t * numChannels /* o : number fo channels in opened audio file */ ); -#else -/*! r: number of channels of the opened file */ -int16_t AudioFileReader_getNumChannels( - AudioFileReader *self /* i/o: AudioFileReader handle */ -); -#endif void AudioFileReader_close( AudioFileReader **selfPtr /* i/o: pointer to AudioFileReader handle */ -- GitLab From ad24c98c512a37f057fd180401b616d69a4a787a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:19:21 +0100 Subject: [PATCH 18/24] [cleanup] accept ISM_HIGHEST_BITRATE --- apps/encoder.c | 5 ----- lib_com/options.h | 1 - lib_enc/lib_enc.c | 7 ------- 3 files changed, 13 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 274c4099ab..1e0fb3e524 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1621,7 +1621,6 @@ static void usage_enc( void ) fprintf( stdout, " *VBR mode (average bitrate),\n" ); fprintf( stdout, " for AMR-WB IO modes R = (6600, 8850, 12650, 14250, 15850, 18250,\n" ); fprintf( stdout, " 19850, 23050, 23850) \n" ); -#ifdef ISM_HIGHEST_BITRATE fprintf( stdout, " for IVAS stereo R = (13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); fprintf( stdout, " 96000, 128000, 160000, 192000, 256000) \n" ); fprintf( stdout, " for IVAS ISM R = 13200 for 1 ISM, 16400 for 1 ISM and 2 ISM, \n" ); @@ -1629,10 +1628,6 @@ static void usage_enc( void ) fprintf( stdout, " for 2 ISM, 3 ISM and 4 ISM also 160000, 192000, 256000) \n" ); fprintf( stdout, " for 3 ISM and 4 ISM also 384000 \n" ); fprintf( stdout, " for 4 ISM also 512000 \n" ); -#else - fprintf( stdout, " for IVAS stereo & ISm R =(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); - fprintf( stdout, " 96000, 128000, 160000, 192000, 256000) \n" ); -#endif fprintf( stdout, " for IVAS SBA, MASA, MC R=(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); fprintf( stdout, " 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" ); fprintf( stdout, " Alternatively, R can be a bitrate switching file which consists of R values\n" ); diff --git a/lib_com/options.h b/lib_com/options.h index 4ce0b05847..1b39ef7591 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,6 @@ /*#define SBA_HPF_TUNING_DEC*/ #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ -#define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ #define FIX_350_MASA_DELAY_COMP /* Nokia: Issue 350: MASA audio/meta delay compensation */ #define FIX_372_LIB_REND_VALIDATE_IO /* FhG: Issue 372: IVAS_rend segfaults with unsupported I/O configs - add validation checks of I/O config */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 6beb889d00..ff63f604b6 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1972,7 +1972,6 @@ static ivas_error sanitizeBandwidth( static ivas_error sanitizeBitrateISM( const ENCODER_CONFIG_HANDLE hEncoderConfig ) { -#ifdef ISM_HIGHEST_BITRATE if ( hEncoderConfig->ivas_total_brate > IVAS_128k && hEncoderConfig->nchan_inp == 1 ) { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for 1 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); @@ -1987,12 +1986,6 @@ static ivas_error sanitizeBitrateISM( { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for 3 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); } -#else - if ( hEncoderConfig->ivas_total_brate > IVAS_256k ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for ISm specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } -#endif if ( hEncoderConfig->ivas_total_brate < IVAS_16k4 && hEncoderConfig->nchan_inp == 2 ) { -- GitLab From 61e8704704a5c3f7a4a5a49f1b15d0e271a1d5c4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:20:02 +0100 Subject: [PATCH 19/24] [cleanup] accept FIX_372_LIB_REND_VALIDATE_IO --- lib_com/ivas_error.h | 4 ---- lib_com/options.h | 1 - lib_rend/lib_rend.c | 10 ---------- 3 files changed, 15 deletions(-) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index a0fe708361..9438ad44a1 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -86,9 +86,7 @@ typedef enum IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT, IVAS_ERR_ISM_INVALID_METADATA_VALUE, IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE, -#ifdef FIX_372_LIB_REND_VALIDATE_IO IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, -#endif #ifdef DEBUGGING IVAS_ERR_INVALID_FORCE_MODE, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION @@ -169,10 +167,8 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong number of channels"; case IVAS_ERR_INVALID_BUFFER_SIZE: return "Invalid buffer size"; -#ifdef FIX_372_LIB_REND_VALIDATE_IO case IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED: return "Unsupported input/output config pair"; -#endif case IVAS_ERR_FAILED_FILE_OPEN: return "File open error"; case IVAS_ERR_FAILED_FILE_WRITE: diff --git a/lib_com/options.h b/lib_com/options.h index 1b39ef7591..950a2f28eb 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,6 @@ #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ #define FIX_350_MASA_DELAY_COMP /* Nokia: Issue 350: MASA audio/meta delay compensation */ -#define FIX_372_LIB_REND_VALIDATE_IO /* FhG: Issue 372: IVAS_rend segfaults with unsupported I/O configs - add validation checks of I/O config */ #define FIX_376_SBA_ROTATE /*DLB: Fix for issue 376*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 63b79cf2af..8ad381584b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1030,7 +1030,6 @@ static CREND_WRAPPER defaultCrendWrapper( return w; } -#ifdef FIX_372_LIB_REND_VALIDATE_IO static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_AudioConfig outConfig ) { /* Rendering mono or stereo to binaural is not supported */ @@ -1043,7 +1042,6 @@ static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_A /* If not returned so far, config pair is supported */ return true; } -#endif static ivas_error setRendInputActiveIsm( void *input, @@ -1060,12 +1058,10 @@ static ivas_error setRendInputActiveIsm( rendCtx = inputIsm->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputIsm->base, inConfig, id, rendCtx ); @@ -1916,12 +1912,10 @@ static ivas_error setRendInputActiveMc( rendCtx = inputMc->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputMc->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputMc->panGains ); @@ -2150,12 +2144,10 @@ static ivas_error setRendInputActiveSba( rendCtx = inputSba->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputSba->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputSba->hoaDecMtx ); @@ -2519,12 +2511,10 @@ static ivas_error setRendInputActiveMasa( outConfig = *rendCtx.pOutConfig; (void) hRendCfg; /* Suppress warning */ -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputMasa->base, inConfig, id, rendCtx ); -- GitLab From 34104faccd47f26e0f51813764db5d278b524e7c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 16 Mar 2023 21:27:33 +0100 Subject: [PATCH 20/24] [cleanup] formatting --- lib_com/ivas_cov_smooth.c | 16 ++++-------- lib_dec/ivas_dec.c | 3 +-- lib_dec/ivas_ism_param_dec.c | 2 +- lib_dec/ivas_spar_decoder.c | 42 +++++++++++++++--------------- lib_dec/ivas_stat_dec.h | 4 +-- lib_enc/ivas_core_pre_proc_front.c | 2 +- lib_enc/ivas_enc.c | 3 +-- lib_enc/ivas_enc_cov_handler.c | 3 +-- lib_enc/ivas_ism_enc.c | 3 +-- lib_enc/ivas_spar_encoder.c | 2 +- lib_rend/ivas_crend.c | 8 ------ lib_rend/ivas_objectRenderer.c | 11 ++++---- lib_util/audio_file_reader.c | 6 ++--- 13 files changed, 42 insertions(+), 63 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 48ca292e8e..35ce6b8546 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -50,8 +50,7 @@ static void ivas_set_up_cov_smoothing( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, const float max_update_rate, - const int16_t min_pool_size - , + const int16_t min_pool_size, const int16_t nchan_inp /* i : number of input channels */ ) { @@ -76,7 +75,6 @@ static void ivas_set_up_cov_smoothing( hCovState->pSmoothing_factor[j] = max_update_rate; } } - } else { @@ -144,10 +142,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( } } - ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size - , - nchan_inp - ); + ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, + nchan_inp ); *hCovState_out = hCovState; @@ -208,8 +204,7 @@ static void ivas_compute_smooth_cov( const int16_t start_band, const int16_t end_band, const int16_t num_ch, - const int16_t transient_det[2] -) + const int16_t transient_det[2] ) { int16_t i, j, k; int16_t prev_idx = hCovState->prior_bank_idx; @@ -300,8 +295,7 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, - const int16_t transient_det[2] -) + const int16_t transient_det[2] ) { int16_t i, j; int16_t num_bands = end_band - start_band; diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index b51eacd1ba..45f31e9f84 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -147,8 +147,7 @@ ivas_error ivas_dec( return error; } } - else - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 43ae3cf072..f34aa023f6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -157,7 +157,7 @@ static void ivas_ism_get_proto_matrix( static void ivas_param_ism_compute_mixing_matrix( - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 6bf8b57f4c..53c60c3d34 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -811,33 +811,33 @@ void ivas_spar_get_parameters( { for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) { - if ( split_band < IVAS_MAX_NUM_BANDS - /* 20ms cross-fade for Transport channels in all frequency bands */ - && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ - ) + if ( split_band < IVAS_MAX_NUM_BANDS + /* 20ms cross-fade for Transport channels in all frequency bands */ + && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ + ) + { + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + if ( hSpar->i_subframe > 3 ) { - if ( hSpar->i_subframe > 3 ) - { - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + - weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; - } - else - { - par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; - } + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + + weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; } - } - else - { - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + else { - /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ - int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; + par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; } } + } + else + { + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { + /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ + int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; + } + } } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c4c37754fa..51d825c0fb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1143,8 +1143,8 @@ typedef struct decoder_config_structure int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ - int16_t orientation_tracking; /* indicates orientation tracking type */ + int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + int16_t orientation_tracking; /* indicates orientation tracking type */ float no_diegetic_pan; int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 971d47c0f9..6e2f6b6db2 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -107,7 +107,7 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index aff410fcab..1e4ba82207 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -136,8 +136,7 @@ ivas_error ivas_enc( { hp20( data_f[HOA_keep_ind[i]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } - else - if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ + else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 1b366b86e8..23d0bdd0e5 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -150,8 +150,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, - const int16_t transient_det[2] -) + const int16_t transient_det[2] ) { int16_t i, j; int16_t dtx_cov_flag; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 14b52bd0ee..497f47e386 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -208,8 +208,7 @@ ivas_error ivas_ism_enc( ivas_param_ism_metadata_dtx_enc( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, st_ivas->hIsmMetaData, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm ); } } - else - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5b81d91ea2..7b2155d767 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -107,7 +107,7 @@ ivas_error ivas_spar_enc_open( ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_inp, nchan_transport, active_w_mixing, input_Fs ); fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; -/* FB mixer handle */ + /* FB mixer handle */ if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 9ea32ba1e3..74f26ad907 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -148,13 +148,6 @@ static ivas_error ivas_hrtf_close( } - - - - - - - /*------------------------------------------------------------------------- * initCrend_from_rom() * @@ -770,7 +763,6 @@ ivas_error ivas_rend_openCrend( } - hHrtf = ( *pCrend )->hHrtfCrend; if ( hHrtf != NULL ) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 9ae3014938..9041a016b1 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -227,8 +227,8 @@ void ivas_td_binaural_close( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( - REVERB_HANDLE hReverb, /* i : reverb handle */ - AUDIO_CONFIG transport_config, /* i : Transport configuration */ + REVERB_HANDLE hReverb, /* i : reverb handle */ + AUDIO_CONFIG transport_config, /* i : Transport configuration */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ const int16_t nchan_transport, /* i : Transport channels (ISms) */ const int16_t lfe_idx, /* i : LFE channel index */ @@ -263,7 +263,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( { return error; } - } /* Render subframe */ @@ -545,9 +544,9 @@ ivas_error ivas_td_binaural_renderer_ext( const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ - const REVERB_HANDLE reverb, /* i : reverb handle */ - const int16_t output_frame, /* i : output frame length */ - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ + const REVERB_HANDLE reverb, /* i : reverb handle */ + const int16_t output_frame, /* i : output frame length */ + float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) { ISM_METADATA_FRAME hIsmMetaDataFrame; diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index f124c11169..4f6bd0c34d 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -55,8 +55,7 @@ static int8_t AudioFileReader_open_raw( static int8_t AudioFileReader_open_wav( AudioFileReader *self, - const char *fileName -) + const char *fileName ) { uint32_t samplesInFile; int16_t bps; @@ -104,8 +103,7 @@ ivas_error AudioFileReader_open( if ( fileNameLen > wavSuffixLen && strncmp( fileName + fileNameLen - wavSuffixLen, wavSuffix, wavSuffixLen ) == 0 ) { - retCode = AudioFileReader_open_wav( self, fileName - ); + retCode = AudioFileReader_open_wav( self, fileName ); } else { -- GitLab From 4818c7da1e85bcb1d190a199ee6007230a9b7144 Mon Sep 17 00:00:00 2001 From: szczerba Date: Fri, 17 Mar 2023 12:12:19 +0100 Subject: [PATCH 21/24] Null position pointer handling --- lib_util/head_rotation_file_reader.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index 3dab8a5b01..98a89ef3bb 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -132,11 +132,6 @@ ivas_error HeadRotationFileReading( return IVAS_ERR_FAILED_FILE_PARSE; } - if ( read_values == 7 && pPos == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - ( headRotReader->frameCounter )++; pQuaternion->w = w; @@ -144,9 +139,12 @@ ivas_error HeadRotationFileReading( pQuaternion->y = y; pQuaternion->z = z; #ifdef TD5 - pPos->x = posx; - pPos->y = posy; - pPos->z = posz; + if ( pPos != NULL ) + { + pPos->x = posx; + pPos->y = posy; + pPos->z = posz; + } #endif return IVAS_ERR_OK; -- GitLab From e32c5f1b80cf2e922fe76b4bb955b35542bdaee0 Mon Sep 17 00:00:00 2001 From: szczerba Date: Fri, 17 Mar 2023 13:14:08 +0100 Subject: [PATCH 22/24] Fix for the botched merge --- apps/renderer.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 833ac7cd4d..46102c54b6 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -716,49 +716,49 @@ int main( if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_REND_InitConfig( hIvasRend, strlen( args.renderConfigFilePath ) != 0 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error in Renderer Config Init\n" ); exit( -1 ); } -#endif - if ( args.renderConfigFilePath[0] != '\0' ) - { - IVAS_RENDER_CONFIG_DATA renderConfig; + if ( args.renderConfigFilePath[0] != '\0' ) + { + IVAS_RENDER_CONFIG_DATA renderConfig; - /* sanity check */ + /* sanity check */ #ifdef TD5 - if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) + if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) #else if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) #endif - { + { #ifdef TD5 - fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); #else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); #endif - exit( -1 ); - } + exit( -1 ); + } - if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); - exit( -1 ); - } + if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); + exit( -1 ); + } - if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath ); - exit( -1 ); - } + if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath ); + exit( -1 ); + } - if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); - exit( -1 ); - } + if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); + exit( -1 ); } + } #ifdef FIX_I109_ORIENTATION_TRACKING if ( IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientationTracking ) ) -- GitLab From 565736146b5d71659c787edef2a77bf1d957ce82 Mon Sep 17 00:00:00 2001 From: szczerba Date: Fri, 17 Mar 2023 13:54:48 +0100 Subject: [PATCH 23/24] Fix for the botched merge --- lib_rend/ivas_objectRenderer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 2d1901288a..4a72b76384 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -455,11 +455,12 @@ void TDREND_Update_object_positions( Dir[1] = 0.0f; Dir[2] = 0.0f; +#endif /* Source directivity info */ DirAtten_p->ConeInnerAngle = 360.0f; DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterGain = 1.0f; -#endif + TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); -- GitLab From ebf161d450908dba93a242fa61172d0125b9eb9c Mon Sep 17 00:00:00 2001 From: szczerba Date: Fri, 17 Mar 2023 13:57:58 +0100 Subject: [PATCH 24/24] cleanup: formatting update (clang) --- lib_util/head_rotation_file_reader.c | 6 +++--- lib_util/head_rotation_file_reader.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index 98a89ef3bb..a7ef6b04ea 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -95,10 +95,10 @@ ivas_error HeadRotationFileReader_open( ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ #ifdef TD5 - IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ - IVAS_POSITION *pPos /* o : listener position */ + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_POSITION *pPos /* o : listener position */ #else - IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ + IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ #endif ) { diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h index 127dd3a9fc..2a995f15f6 100644 --- a/lib_util/head_rotation_file_reader.h +++ b/lib_util/head_rotation_file_reader.h @@ -61,10 +61,10 @@ ivas_error HeadRotationFileReader_open( ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ #ifdef TD5 - IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ - IVAS_POSITION *pPos /* o : listener position */ + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_POSITION *pPos /* o : listener position */ #else - IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ + IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ #endif ); #else -- GitLab