From 5f86b3eb324abf10e31476b69443886a89488507 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Oct 2025 15:00:40 +0200 Subject: [PATCH] accept FIX_CREND_SIMPLIFY_CODE, FIX_989_TD_REND_ROM, HRTF_LOAD_API, FIX_HRTF_LOAD_AP --- apps/decoder.c | 189 +-- apps/renderer.c | 56 - lib_com/common_api_types.h | 25 - lib_com/ivas_cnst.h | 2 - lib_com/ivas_error.h | 4 - lib_com/ivas_prot.h | 44 - lib_com/options.h | 12 +- lib_dec/ivas_binRenderer_internal.c | 724 +--------- lib_dec/ivas_init_dec.c | 101 +- lib_dec/ivas_ism_dec.c | 73 - lib_dec/ivas_masa_dec.c | 30 +- lib_dec/ivas_mct_dec.c | 52 - lib_dec/ivas_objectRenderer_internal.c | 2 - lib_dec/ivas_omasa_dec.c | 10 - lib_dec/ivas_output_config.c | 3 +- lib_dec/ivas_sba_dec.c | 28 - lib_dec/ivas_stat_dec.h | 4 - lib_dec/lib_dec.c | 259 +--- lib_dec/lib_dec.h | 12 - lib_isar/lib_isar_post_rend.c | 4 - lib_rend/ivas_crend.c | 352 +---- lib_rend/ivas_dirac_dec_binaural_functions.c | 3 - lib_rend/ivas_hrtf.c | 54 +- lib_rend/ivas_objectRenderer_mix.c | 119 +- lib_rend/ivas_prot_rend.h | 35 +- lib_rend/ivas_render_config.c | 4 - lib_rend/ivas_rom_TdBinauralRenderer.h | 4 - lib_rend/ivas_stat_rend.h | 131 +- lib_rend/lib_rend.c | 72 +- lib_util/hrtf_file_reader.c | 1290 +----------------- lib_util/hrtf_file_reader.h | 59 +- lib_util/render_config_reader.c | 16 - 32 files changed, 93 insertions(+), 3680 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 686c6ae0a..0bf171fb5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -156,7 +156,6 @@ typedef struct } DecArguments; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct { hrtfFileReader *hrtfReader; @@ -174,7 +173,7 @@ typedef struct IVAS_AUDIO_CONFIG hrtf_set_audio_cfg; } IVAS_DEC_HRTF_BINARY_WRAPPER; -#endif + /*------------------------------------------------------------------------------------------* * Local functions prototypes @@ -182,14 +181,9 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); -#ifdef FIX_CREND_SIMPLIFY_CODE static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); -#else -static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); -#endif #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); @@ -224,13 +218,7 @@ int main( RenderConfigReader *renderConfigReader = NULL; int16_t *pcmBuf = NULL; IVAS_RENDER_FRAMESIZE asked_frame_size; -#ifdef FIX_CREND_SIMPLIFY_CODE IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary; -#else - IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; -#endif #ifdef DEBUGGING int32_t noClipping; int32_t cnt_frames_limited; @@ -247,10 +235,8 @@ int main( reset_mem( USE_BYTES ); #endif -#ifdef FIX_CREND_SIMPLIFY_CODE hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ -#endif splitRendBits.bits_buf = splitRendBitsBuf; @@ -731,115 +717,11 @@ int main( if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_CREND_SIMPLIFY_CODE hHrtfBinary.hrtfReader = hrtfReader; hHrtfBinary.hrtfFileName = arg.hrtfFileName; hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; -#else - if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - -#ifdef FIX_989_TD_REND_ROM - if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) -#endif - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_td_hrtf( hHrtfTD ); - } - } - - - if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_SetOfHRTF( hSetOfHRTF ); - } - } - - IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; - if ( ( error = IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfFastConvHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_fastconv_hrtf( hHrtfFastConv ); - } - } - - IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; - if ( ( error = IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_parambin_hrtf( hHrtfParambin ); - } - } - - - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_hrtf_statistics( hHrtfStatistics ); - } - } -#endif } /*------------------------------------------------------------------------------------------* @@ -854,32 +736,23 @@ int main( } pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); -#ifdef FIX_CREND_SIMPLIFY_CODE if ( pcmBuf == NULL ) { fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); goto cleanup; } -#endif + /*-----------------------------------------------------------------* * Decoding *-----------------------------------------------------------------*/ if ( arg.voipMode ) { -#ifdef FIX_CREND_SIMPLIFY_CODE error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); -#else - error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); -#endif } else { -#ifdef FIX_CREND_SIMPLIFY_CODE error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); -#else - error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); -#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -895,11 +768,7 @@ int main( } else { -#ifdef FIX_CREND_SIMPLIFY_CODE fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); -#else - fprintf( stdout, "Decoding finished prematurely\n\n" ); -#endif goto cleanup; } @@ -936,23 +805,8 @@ cleanup: #endif if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_CREND_SIMPLIFY_CODE destroy_td_hrtf( hHrtfBinary.hHrtfTD ); destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); -#else - IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ); - if ( hHrtfTD != NULL ) - { - destroy_td_hrtf( hHrtfTD ); - } - IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ); - if ( hSetOfHRTF != NULL ) - { - destroy_SetOfHRTF( hSetOfHRTF ); - } - IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); - destroy_hrtf_statistics( hHrtfStatistics ); -#endif } IVAS_DEC_Close( &hIvasDec ); @@ -2212,9 +2066,7 @@ static ivas_error initOnFirstGoodFrame( static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, -#ifdef FIX_CREND_SIMPLIFY_CODE IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, -#endif RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, @@ -2575,7 +2427,6 @@ static ivas_error decodeG192( goto cleanup; } -#ifdef FIX_CREND_SIMPLIFY_CODE /* Read main parameters from the bitstream to set-up the decoder */ hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer; hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec; @@ -2596,16 +2447,13 @@ static ivas_error decodeG192( goto cleanup; } } -#endif -#ifdef FIX_HRTF_LOAD_API /* decode transport channels, do TSM and feed to renderer */ if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } -#endif #ifdef OBJ_EDITING_API /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) @@ -3116,9 +2964,7 @@ static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, -#ifdef FIX_CREND_SIMPLIFY_CODE IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, -#endif RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, @@ -3168,13 +3014,11 @@ static ivas_error decodeVoIP( IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; -#ifdef FIX_CREND_SIMPLIFY_CODE bool bitstreamReadDone = false; #ifdef OBJ_EDITING_API bool parameterAvailableForEditing = false; #endif uint16_t nSamplesRendered; -#endif vec_pos_update = 0; if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) @@ -3292,9 +3136,7 @@ static ivas_error decodeVoIP( while ( 1 ) { -#ifdef FIX_CREND_SIMPLIFY_CODE nSamplesRendered = 0; -#endif /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) @@ -3458,29 +3300,19 @@ static ivas_error decodeVoIP( /* decode and get samples */ -#ifdef FIX_HRTF_LOAD while ( nSamplesRendered < nOutSamples ) { -#endif #ifdef SUPPORT_JBM_TRACEFILE -#ifdef FIX_CREND_SIMPLIFY_CODE #ifdef OBJ_EDITING_API if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, systemTime_ms ) ) != IVAS_ERR_OK ) #endif #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef FIX_CREND_SIMPLIFY_CODE #ifdef OBJ_EDITING_API - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif -#else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK ) #endif #endif { @@ -3488,7 +3320,6 @@ static ivas_error decodeVoIP( goto cleanup; } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( bitstreamReadDone == true ) { /* Read main parameters from the bitstream to set-up the decoder */ @@ -3512,16 +3343,14 @@ static ivas_error decodeVoIP( } } } -#endif + #ifdef OBJ_EDITING_API if ( parameterAvailableForEditing == true ) { /* do the object editing here */ } #endif -#ifdef FIX_HRTF_LOAD } /* while ( nSamplesRendered < nOutSamples ) */ -#endif /* write JBM Offset file entry */ if ( jbmOffsetWriter != NULL ) @@ -3829,7 +3658,7 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( #endif -#ifdef FIX_CREND_SIMPLIFY_CODE + /*---------------------------------------------------------------------* * load_hrtf_from_file() * @@ -3894,11 +3723,7 @@ static ivas_error load_hrtf_from_file( return error; } -#ifdef FIX_989_TD_REND_ROM if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_HRTF_binary( *hHrtfBinary->hHrtfTD, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -4006,5 +3831,5 @@ static ivas_error load_hrtf_from_file( return IVAS_ERR_OK; } -#endif + #undef WMC_TOOL_SKIP diff --git a/apps/renderer.c b/apps/renderer.c index 72a294807..0c5183cd9 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -639,11 +639,7 @@ static int16_t get_cldfb_in_flag( int16_t cldfb_in_flag; cldfb_in_flag = 0; -#ifdef FIX_HRTF_LOAD if ( renderConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( renderConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { #ifdef DEBUGGING cldfb_in_flag = 1; @@ -692,11 +688,7 @@ int main( SplitRendBFIFileReader *splitRendBFIReader = NULL; Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; -#ifdef FIX_CREND_SIMPLIFY_CODE IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; -#else - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; -#endif IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; @@ -982,11 +974,7 @@ int main( goto cleanup; } -#ifdef FIX_989_TD_REND_ROM if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -999,7 +987,6 @@ int main( } } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hHrtfCrend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) ); @@ -1012,15 +999,6 @@ int main( } if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hrtfFileReader, args.outConfig.audioConfig, hrtf_set_audio_cfg, args.sampleRate ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) ); - goto cleanup; - } - - if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -1029,11 +1007,7 @@ int main( } else { -#ifdef FIX_CREND_SIMPLIFY_CODE destroy_crend_hrtf( hHrtfCrend ); -#else - destroy_SetOfHRTF( hSetOfHRTF ); -#endif } } @@ -1043,11 +1017,7 @@ int main( goto cleanup; } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, args.inConfig.ambisonicsBuses->audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hrtfFileReader ) ) != IVAS_ERR_OK ) -#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -2080,20 +2050,8 @@ cleanup: RotationFileReader_close( &headRotReader ); RotationFileReader_close( &externalOrientationFileReader ); RotationFileReader_close( &referenceRotReader ); - Vector3PairFileReader_close( &referenceVectorReader ); -#ifdef FIX_CREND_SIMPLIFY_CODE destroy_td_hrtf( hHrtfTD ); -#else - if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL ) - { - destroy_SetOfHRTF( hSetOfHRTF ); - } - if ( hHrtfTD != NULL && *hHrtfTD != NULL ) - { - destroy_td_hrtf( hHrtfTD ); - } -#endif destroy_hrtf_statistics( hHrtfStatistics ); IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); @@ -2687,9 +2645,7 @@ static CmdlnArgs defaultArgs( const char *executableName ) { CmdlnArgs args; -#ifdef FIX_CREND_SIMPLIFY_CODE int16_t i; -#endif strncpy( args.executableName, executableName, RENDERER_MAX_CLI_ARG_LENGTH ); clearString( args.inputFilePath ); @@ -2706,20 +2662,12 @@ static CmdlnArgs defaultArgs( args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; args.outConfig.outSetupCustom.num_spk = 0; args.outConfig.outSetupCustom.num_lfe = 0; -#ifdef FIX_CREND_SIMPLIFY_CODE for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { args.inConfig.ambisonicsBuses[i].audioConfig = IVAS_AUDIO_CONFIG_INVALID; } -#else - args.inConfig.ambisonicsBuses->audioConfig = IVAS_AUDIO_CONFIG_INVALID; -#endif -#ifdef FIX_CREND_SIMPLIFY_CODE for ( i = 0; i < RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS; ++i ) -#else - for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) -#endif { clearString( args.inMetadataFilePaths[i] ); } @@ -2757,11 +2705,7 @@ static CmdlnArgs defaultArgs( args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; args.syncMdDelay = 0; -#ifdef FIX_CREND_SIMPLIFY_CODE for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) -#else - for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) -#endif { args.directivityPatternId[i] = 65535; } diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index e3aa7344b..ac26b97e4 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -177,19 +177,11 @@ typedef enum typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtf_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtf_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtf_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; typedef struct ivas_hrtf_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; -#else -typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; -typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; -typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; -typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; -typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; -#endif typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; @@ -221,7 +213,6 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef enum _ivas_binaural_renderer_type { IVAS_BIN_RENDERER_TYPE_NONE, @@ -232,7 +223,6 @@ typedef enum _ivas_binaural_renderer_type IVAS_BIN_RENDERER_TYPE_DEFAULT, } IVAS_BIN_RENDERER_TYPE; -#endif /*----------------------------------------------------------------------------------* * Split rendering API constants, structures, and enums @@ -271,17 +261,6 @@ typedef enum } ISAR_SPLIT_REND_CODEC; -#ifndef FIX_HRTF_LOAD -typedef enum -{ - ISAR_SPLIT_REND_RENDERER_SELECTION_CREND, - ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV, - ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN, - ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND, - ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT, - -} ISAR_SPLIT_REND_RENDERER_SELECTION; -#endif typedef struct _ISAR_SPLIT_REND_BITS_DATA { uint8_t *bits_buf; @@ -312,11 +291,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; ISAR_SPLIT_REND_CODEC codec; -#ifdef FIX_HRTF_LOAD IVAS_BIN_RENDERER_TYPE rendererSelection; -#else - ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; -#endif int16_t lc3plus_highres; } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 55c12bad8..bff4a0cd5 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1531,10 +1531,8 @@ typedef enum #define MAX_ANGULAR_STEP_INV ( 1.0f / MAX_ANGULAR_STEP ) #define MAX_INTERPOLATION_STEPS 12 -#ifdef FIX_989_TD_REND_ROM #define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) #define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) -#endif /* ----- Enums - TD Renderer ----- */ diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 18695623b..3614cd839 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -78,9 +78,7 @@ typedef enum IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, IVAS_ERR_INVALID_HRTF, -#if defined FIX_CREND_SIMPLIFY_CODE || defined FIX_989_TD_REND_ROM IVAS_ERR_INVALID_HRTF_SAMPLING_RATE, -#endif IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA, IVAS_ERR_INVALID_INPUT_FORMAT, IVAS_ERR_INVALID_INDEX, @@ -259,10 +257,8 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Acoustic environment not supported"; case IVAS_ERR_INVALID_HRTF: return "Unsupported HRTF filter set"; -#if defined FIX_CREND_SIMPLIFY_CODE || defined FIX_989_TD_REND_ROM case IVAS_ERR_INVALID_HRTF_SAMPLING_RATE: return "Wrong sampling rate in HRTF binary file"; -#endif case IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA: return "Renderer data missing in HRTF binary file"; case IVAS_ERR_INVALID_INPUT_FORMAT: diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ccf76c486..656bc60b6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -338,12 +338,6 @@ ivas_error ivas_dec_get_format( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); ivas_error create_sce_dec( @@ -675,12 +669,10 @@ void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#ifdef FIX_CREND_SIMPLIFY_CODE /*! r: secondary binaural renderer type */ RENDERER_TYPE ivas_renderer_secondary_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#endif ivas_error ivas_mc_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ @@ -689,12 +681,6 @@ ivas_error ivas_mc_enc_config( ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx /* i : LS config. index */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); /*! r: MC format mode (MCT, McMASA, ParamMC) */ @@ -1139,12 +1125,6 @@ ivas_error ivas_ism_enc_config( ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode /* i/o: last ISM mode */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); ivas_error ivas_param_ism_dec_open( @@ -3535,12 +3515,6 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); ivas_error ivas_sba_digest_tc( @@ -5001,12 +4975,6 @@ void ivas_masa_enc_reconfigure( ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); ivas_error ivas_masa_encode( @@ -5232,13 +5200,7 @@ void ivas_init_binaural_hrtf( ivas_error ivas_allocate_binaural_hrtf( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ -#ifdef FIX_CREND_SIMPLIFY_CODE const int16_t n_channels, /* i : number of input channels */ -#else - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ -#endif const int16_t allocate_init_flag /* i : Memory allocation flag */ ); @@ -5709,12 +5671,6 @@ ivas_error ivas_omasa_enc_config( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ); void ivas_omasa_set_config( diff --git a/lib_com/options.h b/lib_com/options.h index e0ea8d1af..360c548eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,22 +163,17 @@ #define FIX_1129_EXT_REND_OUTPUT_HIGH /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ -#define FIX_989_TD_REND_ROM /* Eri: Clean-up for TD renderer and completion of ROM generation tool */ -#define FIX_CREND_SIMPLIFY_CODE -#ifdef FIX_CREND_SIMPLIFY_CODE + #define CHECK_BE_USING_OLD_ROM_TABLES_ONLY -#define FIX_HRTF_LOAD /* VA: issue 1187: fix memory issue when HRTFs are loaded from a binary file */ #ifdef CHECK_BE_USING_OLD_ROM_TABLES_ONLY #define USE_NEW_CREND_ROM_TABLE #ifdef USE_NEW_CREND_ROM_TABLE #define USE_NEW_REVERB_ROM_TABLES #endif #define USE_NEW_FASTCONV_PARAMBIN_ROM_TABLES -#ifdef FIX_989_TD_REND_ROM -#define USE_NEW_TDREND_ROM_TABLES /* requires FIX_989_TD_REND_ROM */ -#endif -#endif +#define USE_NEW_TDREND_ROM_TABLES #endif + #define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0 */ #define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ @@ -218,7 +213,6 @@ // object-editing feature porting #define OBJ_EDITING_API /* object editing changes related to the API */ #ifdef OBJ_EDITING_API -#define FIX_HRTF_LOAD_API // solves API conflicts between HRTF and object-editing features #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 25e680f4d..d1dad3023 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -165,15 +165,10 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenderer->nInChannels = ( audioCfg2channels( input_config ) - isLoudspeaker ); } -#ifdef FIX_CREND_SIMPLIFY_CODE hBinRenConvModule->numTaps = hHrtf->ntaps; -#endif if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifndef FIX_CREND_SIMPLIFY_CODE - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; -#endif /* Use variable order filtering */ bandIdx = 0; for ( ; bandIdx < 5; bandIdx++ ) @@ -199,16 +194,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } else { -#ifndef FIX_CREND_SIMPLIFY_CODE - if ( hBinRenderer->ivas_format == SBA_FORMAT ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; - } - else - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - } -#endif /* Use fixed order filtering */ bandIdx = 0; for ( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) @@ -316,10 +301,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { int16_t tmp = 0; - -#ifdef FIX_CREND_SIMPLIFY_CODE tmp = chIdx; -#endif if ( isLoudspeaker ) { @@ -351,72 +333,10 @@ static ivas_error ivas_binRenderer_convModuleOpen( #endif } -#ifdef FIX_CREND_SIMPLIFY_CODE hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftReal[bandIdx][tmp]; hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftImag[bandIdx][tmp]; hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightReal[bandIdx][tmp]; hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightImag[bandIdx][tmp]; -#else - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftBRIRReal[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftBRIRImag[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightBRIRReal[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightBRIRImag[bandIdx][tmp]; - } -#ifdef DEBUGGING - else - { - /* HOA3 filter coefficients */ - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: The tables corresponding to HOA3 for BRIR are missing \n\n" ); - } -#endif - } - else - { - if ( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftHRIRImag[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag[bandIdx][tmp]; - } - else - { - if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3[bandIdx][chIdx]; - } - else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) - { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2[bandIdx][chIdx]; - } - else if ( input_config == IVAS_AUDIO_CONFIG_FOA ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA[bandIdx][chIdx]; - } - else - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } - } - } -#endif } } @@ -451,7 +371,6 @@ void ivas_init_binaural_hrtf( { int16_t i; -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal = NULL; HrtfFastConv->leftImag = NULL; HrtfFastConv->rightReal = NULL; @@ -459,42 +378,8 @@ void ivas_init_binaural_hrtf( HrtfFastConv->FASTCONV_latency_s = 0x00; HrtfFastConv->n_channels = 0; -#else - HrtfFastConv->leftHRIRReal_HOA3 = NULL; - HrtfFastConv->leftHRIRImag_HOA3 = NULL; - HrtfFastConv->rightHRIRReal_HOA3 = NULL; - HrtfFastConv->rightHRIRImag_HOA3 = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s = 0x00; - - HrtfFastConv->leftHRIRReal = NULL; - HrtfFastConv->leftHRIRImag = NULL; - HrtfFastConv->rightHRIRReal = NULL; - HrtfFastConv->rightHRIRImag = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s = 0x00; - - HrtfFastConv->leftBRIRReal = NULL; - HrtfFastConv->leftBRIRImag = NULL; - HrtfFastConv->rightBRIRReal = NULL; - HrtfFastConv->rightBRIRImag = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s = 0x00; - - HrtfFastConv->leftHRIRReal_HOA2 = NULL; - HrtfFastConv->leftHRIRImag_HOA2 = NULL; - HrtfFastConv->rightHRIRReal_HOA2 = NULL; - HrtfFastConv->rightHRIRImag_HOA2 = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s = 0x00; - - HrtfFastConv->leftHRIRReal_FOA = NULL; - HrtfFastConv->leftHRIRImag_FOA = NULL; - HrtfFastConv->rightHRIRReal_FOA = NULL; - HrtfFastConv->rightHRIRImag_FOA = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s = 0x00; - -#endif HrtfFastConv->allocate_init_flag = 0x00; -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->ntaps = 0; -#endif for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { @@ -558,18 +443,11 @@ static ivas_error ivas_alloc_pppMem( *-------------------------------------------------------------------------*/ ivas_error ivas_allocate_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const int16_t n_channels, /* i : number of input channels */ -#else - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ -#endif + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + const int16_t n_channels, /* i : number of input channels */ const int16_t allocate_init_flag /* i : Memory allocation flag */ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->n_channels = n_channels; if ( ( HrtfFastConv->leftReal != NULL ) && ( HrtfFastConv->leftImag != NULL ) && ( HrtfFastConv->rightReal != NULL ) && ( HrtfFastConv->rightImag != NULL ) ) @@ -595,143 +473,6 @@ ivas_error ivas_allocate_binaural_hrtf( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HrtfFastConv->rightImag" ); } } -#else - if ( input_config == IVAS_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) - { - if ( ( HrtfFastConv->leftHRIRReal_HOA3 != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3 != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3 != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3 != NULL ) ) - { - return IVAS_ERR_OK; - } - else - { - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); - } - } - } - - if ( input_config == IVAS_AUDIO_CONFIG_HOA2 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { - if ( ( HrtfFastConv->leftHRIRReal_HOA2 != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2 != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2 != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2 != NULL ) ) - { - return IVAS_ERR_OK; - } - else - { - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); - } - } - } - - if ( input_config == IVAS_AUDIO_CONFIG_FOA || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { - if ( ( HrtfFastConv->leftHRIRReal_FOA != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA != NULL ) ) - { - return IVAS_ERR_OK; - } - else - { - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); - } - } - } - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - if ( ( HrtfFastConv->leftHRIRReal != NULL ) && ( HrtfFastConv->leftHRIRImag != NULL ) && ( HrtfFastConv->rightHRIRReal != NULL ) && ( HrtfFastConv->rightHRIRImag != NULL ) ) - { - return IVAS_ERR_OK; - } - else - { - - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); - } - } - } - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - if ( ( HrtfFastConv->leftBRIRReal != NULL ) && ( HrtfFastConv->leftBRIRImag != NULL ) && ( HrtfFastConv->rightBRIRReal != NULL ) && ( HrtfFastConv->rightBRIRImag != NULL ) ) - { - return IVAS_ERR_OK; - } - else - { - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightBRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); - } - } - } -#endif return IVAS_ERR_OK; } @@ -751,9 +492,7 @@ static ivas_error ivas_binaural_hrtf_open( { int16_t i, j; ivas_error error; -#ifdef FIX_CREND_SIMPLIFY_CODE int16_t n_channels; -#endif if ( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) { @@ -774,53 +513,32 @@ static ivas_error ivas_binaural_hrtf_open( if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->FASTCONV_latency_s = FASTCONV_HRIR_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS; -#else - HrtfFastConv->FASTCONV_HRIR_latency_s = FASTCONV_HRIR_latency_s; -#endif } if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA2_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; -#else - HrtfFastConv->FASTCONV_HOA2_latency_s = FASTCONV_HOA2_latency_s; -#endif } if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA3_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; -#else - HrtfFastConv->FASTCONV_HOA3_latency_s = FASTCONV_HOA3_latency_s; -#endif } if ( input_config == IVAS_AUDIO_CONFIG_FOA ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->FASTCONV_latency_s = FASTCONV_FOA_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; -#else - HrtfFastConv->FASTCONV_FOA_latency_s = FASTCONV_FOA_latency_s; -#endif } if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->FASTCONV_latency_s = FASTCONV_BRIR_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_MAX; -#else - HrtfFastConv->FASTCONV_BRIR_latency_s = FASTCONV_BRIR_latency_s; -#endif } HrtfFastConv->allocate_init_flag = 1; -#ifdef FIX_CREND_SIMPLIFY_CODE n_channels = 0; if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) { @@ -843,121 +561,63 @@ static ivas_error ivas_binaural_hrtf_open( } } if ( ( error = ivas_allocate_binaural_hrtf( HrtfFastConv, n_channels, HrtfFastConv->allocate_init_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_allocate_binaural_hrtf( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ) != IVAS_ERR_OK ) -#endif { return error; } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( renderer_type == RENDERER_BINAURAL_FASTCONV && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) -#else - if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) -#endif { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal[i][j] = leftHRIRReal[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal[i][j]; HrtfFastConv->rightImag[i][j] = rightHRIRImag[i][j]; -#else - HrtfFastConv->leftHRIRReal[i][j] = leftHRIRReal[i][j]; - HrtfFastConv->leftHRIRImag[i][j] = leftHRIRImag[i][j]; - HrtfFastConv->rightHRIRReal[i][j] = rightHRIRReal[i][j]; - HrtfFastConv->rightHRIRImag[i][j] = rightHRIRImag[i][j]; -#endif } } -#ifdef FIX_CREND_SIMPLIFY_CODE else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) -#else - else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) -#endif { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal[i][j] = leftBRIRReal[i][j]; HrtfFastConv->leftImag[i][j] = leftBRIRImag[i][j]; HrtfFastConv->rightReal[i][j] = rightBRIRReal[i][j]; HrtfFastConv->rightImag[i][j] = rightBRIRImag[i][j]; -#else - HrtfFastConv->leftBRIRReal[i][j] = leftBRIRReal[i][j]; - HrtfFastConv->leftBRIRImag[i][j] = leftBRIRImag[i][j]; - HrtfFastConv->rightBRIRReal[i][j] = rightBRIRReal[i][j]; - HrtfFastConv->rightBRIRImag[i][j] = rightBRIRImag[i][j]; -#endif } } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( input_config == IVAS_AUDIO_CONFIG_HOA3 && HrtfFastConv->n_channels == HOA3_CHANNELS ) -#else - if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) -#endif { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA3[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA3[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA3[i][j]; HrtfFastConv->rightImag[i][j] = rightHRIRImag_HOA3[i][j]; -#else - HrtfFastConv->leftHRIRReal_HOA3[i][j] = leftHRIRReal_HOA3[i][j]; - HrtfFastConv->leftHRIRImag_HOA3[i][j] = leftHRIRImag_HOA3[i][j]; - HrtfFastConv->rightHRIRReal_HOA3[i][j] = rightHRIRReal_HOA3[i][j]; - HrtfFastConv->rightHRIRImag_HOA3[i][j] = rightHRIRImag_HOA3[i][j]; -#endif } } -#ifdef FIX_CREND_SIMPLIFY_CODE /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ if ( input_config == IVAS_AUDIO_CONFIG_HOA2 && HrtfFastConv->n_channels == HOA2_CHANNELS ) -#else - if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) -#endif { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA2[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA2[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA2[i][j]; HrtfFastConv->rightImag[i][j] = rightHRIRImag_HOA2[i][j]; -#else - HrtfFastConv->leftHRIRReal_HOA2[i][j] = leftHRIRReal_HOA2[i][j]; - HrtfFastConv->leftHRIRImag_HOA2[i][j] = leftHRIRImag_HOA2[i][j]; - HrtfFastConv->rightHRIRReal_HOA2[i][j] = rightHRIRReal_HOA2[i][j]; - HrtfFastConv->rightHRIRImag_HOA2[i][j] = rightHRIRImag_HOA2[i][j]; -#endif } } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( input_config == IVAS_AUDIO_CONFIG_FOA && HrtfFastConv->n_channels == FOA_CHANNELS ) -#else - if ( input_config == IVAS_AUDIO_CONFIG_FOA ) -#endif { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE HrtfFastConv->leftReal[i][j] = leftHRIRReal_FOA[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_FOA[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_FOA[i][j]; HrtfFastConv->rightImag[i][j] = rightHRIRImag_FOA[i][j]; -#else - HrtfFastConv->leftHRIRReal_FOA[i][j] = leftHRIRReal_FOA[i][j]; - HrtfFastConv->leftHRIRImag_FOA[i][j] = leftHRIRImag_FOA[i][j]; - HrtfFastConv->rightHRIRReal_FOA[i][j] = rightHRIRReal_FOA[i][j]; - HrtfFastConv->rightHRIRImag_FOA[i][j] = rightHRIRImag_FOA[i][j]; -#endif } } } @@ -1067,11 +727,7 @@ static void ivas_binaural_obtain_DMX( set_zero( outImagRightPtr, CLDFB_NO_CHANNELS_MAX ); /*Ambisonics input requires different processing*/ -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hBinRenderer->nInChannels == HOA3_CHANNELS ) -#else - if ( hBinRenderer->nInChannels == 16 ) -#endif { float *inRealPtr_W, *inImagPtr_W; float *inRealPtr_Y, *inImagPtr_Y; @@ -1167,12 +823,7 @@ ivas_error ivas_rend_openCldfbRend( hBinRenderer->conv_band = convBand; } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_output_init( hBinRenderer->hInputSetup, inConfig ); -#else - hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; - hBinRenderer->hInputSetup->output_config = inConfig; -#endif if ( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) { @@ -1204,11 +855,7 @@ ivas_error ivas_rend_openCldfbRend( return error; } -#ifdef FIX_CREND_SIMPLIFY_CODE pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); -#else - pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f ); -#endif hBinRenderer->hReverb = NULL; hBinRenderer->hEFAPdata = NULL; @@ -1297,12 +944,10 @@ ivas_error ivas_binRenderer_open( hBinRenderer->render_lfe = 1; } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( st_ivas->hHrtfFastConv == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in FastConv renderer" ); } -#endif /* Load HRTF tables */ if ( ( error = ivas_binaural_hrtf_open( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ) != IVAS_ERR_OK ) @@ -1331,11 +976,7 @@ ivas_error ivas_binRenderer_open( } hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; -#ifdef FIX_CREND_SIMPLIFY_CODE st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); -#else - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s * 1000000000.f ); -#endif } else { @@ -1345,41 +986,7 @@ ivas_error ivas_binRenderer_open( return error; } -#ifdef FIX_CREND_SIMPLIFY_CODE st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); -#else - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - if ( hBinRenderer->ivas_format == MC_FORMAT ) - { - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s * 1000000000.f ); - } - else - { - if ( hBinRenderer->nInChannels == 16 ) - { - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f ); - } - else if ( hBinRenderer->nInChannels == 9 ) - { - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s * 1000000000.f ); - } - else if ( hBinRenderer->nInChannels == 4 ) - { - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s * 1000000000.f ); - } - else - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } - } - } - else - { - /* same value for MC or HOA both use MC BRIR*/ - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s * 1000000000.f ); - } -#endif } /* Allocate memories needed for reverb module */ @@ -1601,9 +1208,7 @@ void ivas_binaural_hrtf_close( ) { int16_t allocate_init_flag; -#ifdef FIX_CREND_SIMPLIFY_CODE int16_t n_channels; -#endif if ( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) { @@ -1611,41 +1216,13 @@ void ivas_binaural_hrtf_close( } allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; -#ifdef FIX_CREND_SIMPLIFY_CODE n_channels = ( *hHrtfFastConv )->n_channels; ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftReal, n_channels, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftImag, n_channels, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightReal, n_channels, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightImag, n_channels, allocate_init_flag ); -#else - - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRReal, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRReal, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRImag, HRTF_LS_CHANNELS, allocate_init_flag ); - - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftBRIRReal, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftBRIRImag, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightBRIRReal, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightBRIRImag, HRTF_LS_CHANNELS, allocate_init_flag ); - - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRReal_HOA3, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag_HOA3, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRReal_HOA3, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRImag_HOA3, HOA3_CHANNELS, allocate_init_flag ); - - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRReal_HOA2, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag_HOA2, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRReal_HOA2, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRImag_HOA2, HOA2_CHANNELS, allocate_init_flag ); - - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRReal_FOA, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag_FOA, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRReal_FOA, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRImag_FOA, FOA_CHANNELS, allocate_init_flag ); -#endif return; } @@ -1699,295 +1276,6 @@ void ivas_binaural_add_LFE( return; } -#ifndef FIX_HRTF_LOAD_API -#ifdef FIX_CREND_SIMPLIFY_CODE -#ifdef DEBUGGING -/*-------------------------------------------------------------------------* - * ivas_binaural_cldfb() - * - * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis - *-------------------------------------------------------------------------*/ - -void ivas_binaural_cldfb( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -) -{ - float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch; - - /* Implement a 5 msec loops */ - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); - - for ( subframeIdx = 0; subframeIdx < ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ); subframeIdx++ ) - { - for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) - { - index_slot = subframeIdx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - - /* Implement CLDFB analysis */ - idx_in = 0; - idx_lfe = 0; - - for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) - { - if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[idx_lfe] == ch ) ) - { - if ( idx_lfe < ( st_ivas->hIntSetup.num_lfe - 1 ) ) - { - idx_lfe++; - } - } - else - { - cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); - idx_in++; - } - } - /*LFE handling for split rendering cases*/ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) - { - ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; - cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); - idx_in++; - } - - if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) - { - for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) - { - mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); - mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); - } - st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; - } - } - } - - /* Implement binaural rendering */ - ivas_binRenderer( - st_ivas->hBinRenderer, - &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, - st_ivas->hCombinedOrientationData, - JBM_CLDFB_SLOTS_IN_SUBFRAME, -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - NULL, -#endif - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - Cldfb_RealBuffer, Cldfb_ImagBuffer ); - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - int16_t pos_idx; - for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) - { - if ( st_ivas->hIntSetup.num_lfe > 0 ) - { - v_multc( Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); - v_multc( Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); - } - } - - for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) - { - for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) - { - for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) - { - if ( st_ivas->hIntSetup.num_lfe > 0 ) - { - v_add( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], - Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], - Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], - maxBand ); - - v_add( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], - Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], - Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], - maxBand ); - } - - mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); - mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); - } - } - } - } - - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); - - /* Implement CLDFB synthesis */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - - index_slot = subframeIdx * MAX_PARAM_SPATIAL_SUBFRAMES; - - for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) - { - RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx]; - ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx]; - } - - cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * maxBand] ), maxBand * MAX_PARAM_SPATIAL_SUBFRAMES, st_ivas->cldfbSynDec[ch] ); - } - } - - return; -} - - -/*-------------------------------------------------------------------------* - * ivas_binaural_cldfb_sf() - * - * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis - *-------------------------------------------------------------------------*/ - -void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int16_t slot_size, /* i : JBM slot size */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -) -{ - float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch; - int16_t slots_to_render, first_sf, last_sf; - int16_t slot_index_start, slot_index_start_cldfb; - - /* Implement a 5 msec loops */ - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); - - /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); - first_sf = st_ivas->hTcBuffer->subframes_rendered; - last_sf = first_sf; - slot_index_start = st_ivas->hTcBuffer->slots_rendered; - slot_index_start_cldfb = 0; - st_ivas->hTcBuffer->slots_rendered += slots_to_render; - - while ( slots_to_render > 0 ) - { - slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; - last_sf++; - } - for ( subframeIdx = first_sf; subframeIdx < last_sf; subframeIdx++ ) - { - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) - { - index_slot = slot_index_start + slot_idx; - - /* Implement CLDFB analysis */ - idx_in = 0; - idx_lfe = 0; - - for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) - { - if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[idx_lfe] == ch ) ) - { - if ( idx_lfe < ( st_ivas->hIntSetup.num_lfe - 1 ) ) - { - idx_lfe++; - } - } - else - { - cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); - idx_in++; - } - } - - /*LFE handling for split rendering cases*/ - if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) - { - ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; - cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); - idx_in++; - } - - if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) - { - for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) - { - mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_index_start + slot_idx], maxBand ); - mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_index_start + slot_idx], maxBand ); - } - st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; - } - } - } - - /* Implement binaural rendering */ - ivas_binRenderer( - st_ivas->hBinRenderer, - &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, - st_ivas->hCombinedOrientationData, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - NULL, -#endif - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - Cldfb_RealBuffer, - Cldfb_ImagBuffer ); - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - int16_t pos_idx; - for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) - { - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) - { - for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) - { - mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); - mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); - } - } - } - } - - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); - - /* Implement CLDFB synthesis */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) - { - RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx]; - ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx]; - } - - cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_index_start_cldfb * maxBand] ), maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], st_ivas->cldfbSynDec[ch] ); - } - slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; - slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; - } - - st_ivas->hTcBuffer->subframes_rendered = last_sf; - - return; -} -#endif -#endif -#endif /*------------------------------------------------------------------------- * ivas_binRenderer() @@ -2063,12 +1351,8 @@ void ivas_binRenderer( } /* HOA decoding to CICP19 if needed*/ -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && ( hBinRenderer->nInChannels != HOA3_CHANNELS && hBinRenderer->nInChannels != HOA2_CHANNELS && hBinRenderer->nInChannels != FOA_CHANNELS ) ) -#else - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && hBinRenderer->nInChannels != 16 ) -#endif { ivas_sba2mc_cldfb( *( hBinRenderer->hInputSetup ), RealBuffer, ImagBuffer, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } @@ -2126,11 +1410,7 @@ void ivas_binRenderer( } else { -#ifdef FIX_CREND_SIMPLIFY_CODE rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hBinRenderer->hInputSetup->ambisonics_order ); -#else - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); -#endif } ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[pos_idx], Cldfb_ImagBuffer_Binaural[pos_idx], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, pos_idx ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index eaba0ed3a..0c6511055 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -463,13 +463,7 @@ ivas_error ivas_dec_get_format( *-------------------------------------------------------------------*/ ivas_error ivas_dec_setup( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t k, idx, num_bits_read; @@ -526,11 +520,7 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -548,11 +538,7 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -618,11 +604,7 @@ ivas_error ivas_dec_setup( } else { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_masa_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -630,11 +612,7 @@ ivas_error ivas_dec_setup( } else { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_omasa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -655,11 +633,7 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_omasa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -690,11 +664,7 @@ ivas_error ivas_dec_setup( if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -739,11 +709,7 @@ ivas_error ivas_dec_setup( num_bits_read += MC_LS_SETUP_BITS; /* select MC format mode; reconfigure the MC format decoder */ -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_mc_dec_config( st_ivas, idx ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -828,11 +794,7 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; } -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -886,11 +848,7 @@ ivas_error ivas_dec_setup( last_ism_mode = st_ivas->ism_mode; } -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1020,14 +978,12 @@ static ivas_error ivas_read_format( { st_ivas->ivas_format = SBA_ISM_FORMAT; -#ifdef FIX_CREND_SIMPLIFY_CODE /* read the real Ambisonic order when the above bits are used to signal OSBA format */ if ( ivas_total_brate < IVAS_24k4 ) { st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 2 + SBA_PLANAR_BITS + SBA_ORDER_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[*num_bits_read + 1 + SBA_PLANAR_BITS + SBA_ORDER_BITS]; } -#endif } } ( *num_bits_read )++; @@ -1267,42 +1223,6 @@ ivas_error ivas_init_decoder_front( } } -#ifndef FIX_CREND_SIMPLIFY_CODE - /*-------------------------------------------------------------------* - * Allocate HRTF binary handle - *--------------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) - { - if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef FIX_CREND_SIMPLIFY_CODE - if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hHrtfCrend ) ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } - - if ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ( error = ivas_HRTF_parambin_binary_open( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif /*-------------------------------------------------------------------* * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ @@ -2246,13 +2166,9 @@ ivas_error ivas_init_decoder( return error; } } -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2745,11 +2661,7 @@ void ivas_initialize_handles_dec( st_ivas->hMonoDmxRenderer = NULL; st_ivas->hCrendWrapper = NULL; st_ivas->hReverb = NULL; -#ifdef FIX_CREND_SIMPLIFY_CODE st_ivas->hHrtfCrend = NULL; -#else - st_ivas->hSetOfHRTF = NULL; -#endif st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; st_ivas->hHrtfStatistics = NULL; @@ -2920,11 +2832,8 @@ void ivas_destroy_dec( ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); /* Crend handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#endif + /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -2969,11 +2878,7 @@ void ivas_destroy_dec( } /* CRend binaural renderer handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_HRTF_CRend_binary_close( &st_ivas->hHrtfCrend ); -#else - ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); -#endif /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 312648a33..1967691cd 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -50,12 +50,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode /* i : last ISM mode */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { ivas_error error; @@ -67,15 +61,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; int16_t nchan_out_buff, nchan_out_buff_old; -#ifndef FIX_HRTF_LOAD - AUDIO_CONFIG intern_config_old; - IVAS_OUTPUT_SETUP hIntSetupOld; - RENDERER_TYPE renderer_type_old; -#endif -#ifndef FIX_HRTF_LOAD - error = IVAS_ERR_OK; -#endif nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -111,13 +97,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } -#ifndef FIX_HRTF_LOAD - /* save old IntSetup, might be needed for JBM flushing...*/ - intern_config_old = st_ivas->intern_config; - hIntSetupOld = st_ivas->hIntSetup; - tc_granularity_new = 1; - renderer_type_old = st_ivas->renderer_type; -#endif /*-----------------------------------------------------------------* * Initialize the needed renderer struct and destroy the unnecessary renderer struct *-----------------------------------------------------------------*/ @@ -156,23 +135,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { -#ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ -#else -#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH - /* write back info for correct rendering of the flushable samples */ - int16_t nchan_transport_ref = st_ivas->nchan_transport; - st_ivas->nchan_transport = nchan_transport_old; - -#endif - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH - st_ivas->nchan_transport = nchan_transport_ref; -#endif -#endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) @@ -240,11 +203,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); /* Open Crend Binaural renderer */ -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -303,11 +262,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /* close the crend binaural renderer */ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#endif } } @@ -383,11 +338,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( } #endif -#ifdef FIX_HRTF_LOAD return IVAS_ERR_OK; -#else - return error; -#endif } @@ -401,23 +352,12 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode /* i/o: last ISM mode */ - -#ifndef FIX_HRTF_LOAD - - , - uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { int32_t ivas_total_brate; ivas_error error; int16_t nchan_transport_old; -#ifndef FIX_HRTF_LOAD - error = IVAS_ERR_OK; -#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /* Assumes that num of input objects are constant */ @@ -448,11 +388,7 @@ ivas_error ivas_ism_dec_config( /* ISM bit-rate switching */ if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -474,12 +410,7 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { - -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -505,9 +436,5 @@ ivas_error ivas_ism_dec_config( break; } -#ifdef FIX_HRTF_LOAD return IVAS_ERR_OK; -#else - return error; -#endif } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index eb742e852..9a735566a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -154,7 +154,6 @@ ivas_error ivas_masa_decode( if ( ivas_format == MASA_FORMAT ) { /* re-read the number of objects, needed in case of bad frame */ -#ifdef FIX_CREND_SIMPLIFY_CODE ch = 5 - ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3] + 2 * st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2] ); if ( ch == 5 ) @@ -162,16 +161,9 @@ ivas_error ivas_masa_decode( ch = 0; } st_ivas->nchan_ism = ch; -#else - st_ivas->nchan_ism = 5 - ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3] + 2 * st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2] ); -#endif } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ivas_format == MASA_FORMAT && st_ivas->nchan_ism > 0 ) -#else - if ( ivas_format == MASA_FORMAT && st_ivas->nchan_ism != 5 ) -#endif { /* there was OMASA in the input */ hMasa->config.input_ivas_format = MASA_ISM_FORMAT; @@ -1325,13 +1317,7 @@ static int16_t decode_lfe_to_total_energy_ratio( *-------------------------------------------------------------------*/ ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t n, tmp, num_bits; @@ -1344,9 +1330,6 @@ ivas_error ivas_masa_dec_reconfigure( int16_t pos_idx; int32_t ism_total_brate; -#ifndef FIX_HRTF_LOAD - error = IVAS_ERR_OK; -#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; @@ -1572,14 +1555,7 @@ ivas_error ivas_masa_dec_reconfigure( { if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { -#ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ -#else - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } } @@ -1620,11 +1596,7 @@ ivas_error ivas_masa_dec_reconfigure( } } -#ifdef FIX_HRTF_LOAD return IVAS_ERR_OK; -#else - return error; -#endif } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 9e1a59cff..a464a1106 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -54,11 +54,7 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -#ifdef FIX_HRTF_LOAD static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas ); -#else -static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, const PCM_RESOLUTION pcm_resolution, void *data ); -#endif /*--------------------------------------------------------------------------* @@ -668,12 +664,6 @@ void ivas_mct_dec_close( ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx /* i : LS config. index */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { AUDIO_CONFIG signaled_config; @@ -708,11 +698,7 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || last_mc_mode != st_ivas->mc_mode ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_mc_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -734,12 +720,6 @@ ivas_error ivas_mc_dec_config( static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; @@ -753,15 +733,8 @@ static ivas_error ivas_mc_dec_reconfig( int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; -#ifndef FIX_HRTF_LOAD - AUDIO_CONFIG intern_config_old; - IVAS_OUTPUT_SETUP hIntSetupOld; -#endif int16_t nchan_out_buff_old, nchan_out_buff; -#ifndef FIX_HRTF_LOAD - error = IVAS_ERR_OK; -#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; nchan_transport_old = st_ivas->nchan_transport; nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); @@ -789,12 +762,6 @@ static ivas_error ivas_mc_dec_reconfig( } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); -#ifndef FIX_HRTF_LOAD - /* save old IntSetup, might be needed for JBM flushing...*/ - intern_config_old = st_ivas->intern_config; - hIntSetupOld = st_ivas->hIntSetup; - tc_granularity_new = 1; -#endif /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; ivas_renderer_select( st_ivas ); @@ -832,14 +799,7 @@ static ivas_error ivas_mc_dec_reconfig( #endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { -#ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ -#else - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) @@ -1213,11 +1173,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != 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->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) { -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#endif } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1272,11 +1228,7 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1446,9 +1398,5 @@ static ivas_error ivas_mc_dec_reconfig( return error; } -#ifdef FIX_HRTF_LOAD return IVAS_ERR_OK; -#else - return error; -#endif } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 6ba5dc8be..26f9967c9 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -61,7 +61,6 @@ ivas_error ivas_td_binaural_open( num_src = st_ivas->nchan_ism; } -#ifdef FIX_HRTF_LOAD #ifdef NONBE_1303_REND_GRANULARITY if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary ) #else @@ -72,7 +71,6 @@ ivas_error ivas_td_binaural_open( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); } -#endif return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hRenderConfig->distAtt, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 56c2fd5c3..4f53f0634 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -187,12 +187,6 @@ void ivas_omasa_data_close( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD; @@ -236,11 +230,7 @@ ivas_error ivas_omasa_dec_config( { st_ivas->hCPE[0]->nchan_out = 1; } -#ifdef FIX_HRTF_LOAD else if ( ( error = ivas_masa_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) -#else - else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index bdb164fa4..2175ecf08 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -481,7 +481,7 @@ void ivas_renderer_select( return; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*-------------------------------------------------------------------------* * ivas_renderer_secondary_select() * @@ -511,4 +511,3 @@ RENDERER_TYPE ivas_renderer_secondary_select( return renderer_type; } -#endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 16428fd86..398032da9 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -102,12 +102,6 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef FIX_HRTF_LOAD - , - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; @@ -164,9 +158,6 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); -#ifndef FIX_HRTF_LOAD - *nSamplesFlushed = 0; -#endif granularity_new = st_ivas->hTcBuffer->n_samples_granularity; /* we may need to flush only for binaural and OSBA and TSM */ @@ -223,22 +214,7 @@ ivas_error ivas_sba_dec_reconfigure( /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { -#ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ -#else - /* write back info for correct rendering of the flushable samples */ - st_ivas->sba_analysis_order = sba_analysis_order_old_flush; - st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; - - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, pcm_resolution, data ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* restore correct values for the current frame*/ - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; -#endif } else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { @@ -672,11 +648,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } -#ifdef FIX_HRTF_LOAD return IVAS_ERR_OK; -#else - return error; -#endif } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 04d23b6d1..5181416cc 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1098,11 +1098,7 @@ typedef struct Decoder_Struct MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend handle */ REVERB_HANDLE hReverb; /* Reverb handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE HRTFS_CREND_HANDLE hHrtfCrend; /* HRTF tables for CRend binaural renderer */ -#else - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ -#endif HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dcdcfa95d..35ea145e1 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -96,20 +96,14 @@ struct IVAS_DEC int16_t prev_ft_speech; /* RXDTX handler: previous frametype flag for G.192 format AMRWB SID_FIRST detection */ int16_t CNG; /* RXDTX handler: CNG=1, nonCNG=0 */ -#ifdef FIX_HRTF_LOAD uint16_t nSamplesFlushed; -#ifdef FIX_HRTF_LOAD_API int16_t *flushbuffer; -#else - int16_t flushbuffer[20 * 960 / 4]; // temp. hack -#endif IVAS_DEC_PCM_TYPE pcmType; #ifdef OBJ_EDITING_API bool hasEditableParameters; bool enableParameterEditing; #endif bool hasBeenPreparedRendering; -#endif }; @@ -125,11 +119,7 @@ static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSampl static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); -#ifdef FIX_HRTF_LOAD static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels ); -#else -static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, const IVAS_DEC_PCM_TYPE pcmType, void *data ); -#endif static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); @@ -191,23 +181,18 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; hIvasDec->updateOrientation = false; -#ifdef FIX_HRTF_LOAD #ifdef OBJ_EDITING_API hIvasDec->flushbuffer = NULL; #else - // hIvasDec->flushbuffer = NULL; + // hIvasDec->flushbuffer = NULL; #endif hIvasDec->pcmType = IVAS_DEC_PCM_INVALID; -#ifndef FIX_HRTF_LOAD_API - hIvasDec->pcmType = IVAS_DEC_PCM_INT16; // temp. hack -#endif hIvasDec->nSamplesFlushed = 0; #ifdef OBJ_EDITING_API hIvasDec->hasEditableParameters = false; hIvasDec->enableParameterEditing = false; #endif hIvasDec->hasBeenPreparedRendering = false; -#endif hIvasDec->mode = mode; @@ -928,136 +913,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; -#ifndef FIX_HRTF_LOAD_API -#ifdef OBJ_EDITING_API - int16_t isSplitRend = 0; // VE: TODO - ISAR_SPLIT_REND_BITS_DATA *splitRendBits = NULL; // VE: TODO - - /* decode TCs, do TSM and feed to renderer */ - /* setup */ - if ( hIvasDec->hasBeenFedFirstGoodFrame ) - { - uint16_t l_ts, nTimeScalerOutSamples; - uint8_t nTransportChannels; - int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; - - if ( isSplitRend ) - { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) - { - return error; - } - } - -#ifdef FIX_HRTF_LOAD - if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } - - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) - { - if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - /* IVAS TC decoder */ - if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* JBM */ - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - assert( nTimeScalerOutSamples <= APA_BUF ); - nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; - hIvasDec->timeScalingDone = 1; - } - else - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - } - - /* Feed decoded transport channels samples to the renderer */ - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - } - hIvasDec->hasBeenPreparedRendering = false; - - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) - { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - int16_t obj; - ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) - { - hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; - hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; - hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; - hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; - hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; - hIsmMetaData[obj]->edited_gain = 1.0f; - } - - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; - } - } - } - } - - if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) - { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) - { - hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; - } - } - } -#endif -#endif - return IVAS_ERR_OK; } -#ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * renderer_type_to_mode() * @@ -1255,7 +1114,6 @@ ivas_error IVAS_DEC_ReadFormat( } } #else -#ifdef FIX_HRTF_LOAD #ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && @@ -1289,7 +1147,6 @@ ivas_error IVAS_DEC_ReadFormat( } } } -#endif #endif } @@ -1303,7 +1160,7 @@ ivas_error IVAS_DEC_ReadFormat( return IVAS_ERR_OK; } -#ifdef FIX_HRTF_LOAD_API + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesDecoder( ) * @@ -1332,18 +1189,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /* If TSM is generally enabled, we have to wait for the first good frame. Otherwise, we directly decode the first frame in any case. */ -#ifdef FIX_HRTF_LOAD if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) -#else - if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) -#endif { uint16_t l_ts, nTimeScalerOutSamples; -#ifdef FIX_HRTF_LOAD uint8_t nTransportChannels; -#else - uint8_t nTransportChannels, nOutChannels; -#endif int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; if ( isSplitRend ) @@ -1354,11 +1203,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } } -#ifdef FIX_HRTF_LOAD if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1459,8 +1304,6 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_OK; } -#endif -#endif #ifdef OBJ_EDITING_API @@ -1758,11 +1601,7 @@ ivas_error IVAS_DEC_GetSamples( if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { /* setup */ -#ifdef FIX_HRTF_LOAD if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2130,35 +1969,19 @@ static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ uint8_t *nTransportChannels /* o : number of decoded transport PCM channels */ -#ifndef FIX_HRTF_LOAD - , - uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ -#endif ) { ivas_error error; -#ifndef FIX_HRTF_LOAD - *nSamplesRendered = 0; -#endif if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; -#ifndef FIX_HRTF_LOAD - *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; -#endif } else { *nTransportChannels = 1; -#ifndef FIX_HRTF_LOAD - *nOutChannels = 1; -#endif } } else @@ -2177,11 +2000,7 @@ static ivas_error IVAS_DEC_Setup( if ( st_ivas->bfi == 0 ) { -#ifdef FIX_HRTF_LOAD if ( ( error = ivas_dec_setup( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2189,9 +2008,6 @@ static ivas_error IVAS_DEC_Setup( *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; -#ifndef FIX_HRTF_LOAD - *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; -#endif /*-----------------------------------------------------------------* * ISAR: @@ -2324,7 +2140,6 @@ static ivas_error IVAS_DEC_GetRenderedSamples( st_ivas = hIvasDec->st_ivas; -#ifdef FIX_HRTF_LOAD /* temp code to make HRTF changes working in the old API structure */ uint16_t nSamplesRendered_loop; uint8_t nOutChannels; @@ -2363,10 +2178,6 @@ static ivas_error IVAS_DEC_GetRenderedSamples( error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering - *nSamplesRendered, &nSamplesRendered_loop, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ) ); *nSamplesRendered += nSamplesRendered_loop; -#else - /* run the main IVAS decoding routine */ - error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); -#endif return error; } @@ -2915,7 +2726,6 @@ ivas_error IVAS_DEC_FeedCustomLsData( return IVAS_ERR_OK; } -#ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfTDrendHandle( ) * @@ -2923,15 +2733,6 @@ ivas_error IVAS_DEC_FeedCustomLsData( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfTDrendHandle( -#else -/*---------------------------------------------------------------------* - * IVAS_DEC_GetHrtfHandle( ) - * - * - *---------------------------------------------------------------------*/ - -ivas_error IVAS_DEC_GetHrtfHandle( -#endif IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ ) @@ -2958,20 +2759,13 @@ ivas_error IVAS_DEC_GetHrtfCRendHandle( IVAS_DEC_HRTF_CREND_HANDLE **hHrtfCrend /* o : Crend HRTF handle */ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfCrend == NULL ) -#else - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL ) -#endif { return IVAS_ERR_WRONG_PARAMS; } -#ifdef FIX_CREND_SIMPLIFY_CODE *hHrtfCrend = &hIvasDec->st_ivas->hHrtfCrend; -#else - *hHrtfCrend = &hIvasDec->st_ivas->hSetOfHRTF; -#endif + return IVAS_ERR_OK; } @@ -3041,7 +2835,7 @@ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*---------------------------------------------------------------------* * IVAS_DEC_HRTF_binary_open( ) * @@ -3165,7 +2959,8 @@ ivas_error IVAS_DEC_HRTF_binary_close( return IVAS_ERR_OK; } -#endif + + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * @@ -3705,10 +3500,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter, #endif -#ifdef FIX_CREND_SIMPLIFY_CODE bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ -#endif #ifdef OBJ_EDITING_API bool *parametersAvailableForEditing, #endif @@ -3723,9 +3516,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( uint16_t extBufferedSamples; int16_t result; ivas_error error; -#ifndef FIX_CREND_SIMPLIFY_CODE - int16_t nSamplesRendered; -#endif uint8_t nOutChannels; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->hVoIP == NULL ) @@ -3737,9 +3527,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; -#ifndef FIX_CREND_SIMPLIFY_CODE - nSamplesRendered = 0; -#endif #ifdef OBJ_EDITING_API *parametersAvailableForEditing = false; #endif @@ -3758,11 +3545,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ -#ifdef FIX_CREND_SIMPLIFY_CODE while ( *nSamplesRendered < nSamplesPerChannel ) -#else - while ( nSamplesRendered < nSamplesPerChannel ) -#endif { if ( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -3832,9 +3615,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } -#ifdef FIX_CREND_SIMPLIFY_CODE *bitstreamReadDone = true; -#endif } else if ( hIvasDec->hasDecodedFirstGoodFrame ) { @@ -3873,14 +3654,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); } -#ifdef FIX_HRTF_LOAD if ( hIvasDec->hasBeenFedFirstGoodFrame && *bitstreamReadDone == true ) { /* new bitstream was feeded, return for reconfiguration */ return IVAS_ERR_OK; } -#endif if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; @@ -3903,13 +3682,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); -#ifdef FIX_CREND_SIMPLIFY_CODE set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); *nSamplesRendered += nSamplesToZero; -#else - set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); - nSamplesRendered += nSamplesToZero; -#endif hIvasDec->nSamplesRendered += nSamplesToZero; hIvasDec->nSamplesAvailableNext -= nSamplesToZero; update_voip_rendered20ms( hIvasDec, nSamplesToZero ); @@ -3919,7 +3693,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( int16_t nSamplesToRender, nSamplesRendered_loop; bool tmp; -#ifdef FIX_HRTF_LOAD_API if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { if ( hIvasDec->nSamplesAvailableNext == 0 || hIvasDec->nSamplesAvailableNext == hIvasDec->nSamplesFrame ) @@ -3936,13 +3709,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( *bitstreamReadDone = false; } } -#endif -#ifdef FIX_CREND_SIMPLIFY_CODE nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; -#else - nSamplesToRender = nSamplesPerChannel - nSamplesRendered; -#endif #ifdef OBJ_EDITING_API /* check if we still need to prepare the renderer */ @@ -3957,25 +3725,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif /* render IVAS frames directly to the output buffer */ -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) -#endif { return error; } -#ifndef FIX_HRTF_LOAD_API -#ifdef FIX_HRTF_LOAD - *bitstreamReadDone = false; // temp hack until JBM API is reworked -#endif -#endif -#ifdef FIX_CREND_SIMPLIFY_CODE *nSamplesRendered += nSamplesRendered_loop; -#else - nSamplesRendered += nSamplesRendered_loop; -#endif update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } @@ -4026,9 +3781,7 @@ ivas_error IVAS_DEC_Flush( ivas_error error; uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; -#ifdef FIX_HRTF_LOAD nSamplesFlushedLocal = 0; // temp. hack -#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index ef9f03995..b11f08323 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -151,7 +151,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( int16_t bfi /* i : bad frame indicator flag */ ); -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error IVAS_DEC_ReadFormat( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ @@ -159,14 +158,11 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_AUDIO_CONFIG *hrtf_set_audio_cfg /* o : HRTF set audio config. */ ); -#ifdef FIX_HRTF_LOAD_API ivas_error IVAS_DEC_GetSamplesDecoder( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t isSplitRend, /* i : split rendering enabled flag */ ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ); -#endif -#endif /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamples( @@ -311,10 +307,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter, #endif -#ifdef FIX_CREND_SIMPLIFY_CODE bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ -#endif #ifdef OBJ_EDITING_API bool *parametersAvailableForEditing, #endif @@ -435,11 +429,7 @@ ivas_error IVAS_DEC_FeedCustomLsData( ); /*! r: error code */ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error IVAS_DEC_GetHrtfTDrendHandle( -#else -ivas_error IVAS_DEC_GetHrtfHandle( -#endif IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ ); @@ -465,7 +455,6 @@ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ ); -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error IVAS_DEC_HRTF_binary_open( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_BIN_RENDERER_TYPE binaural_renderer /* i : binaural renderer type */ @@ -475,7 +464,6 @@ ivas_error IVAS_DEC_HRTF_binary_close( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_BIN_RENDERER_TYPE binaural_renderer_old /* i : previous binaural renderer type */ ); -#endif /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 6f2ea96d9..9bbee5d1b 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1118,11 +1118,7 @@ ivas_error ISAR_POST_REND_InitConfig( hIvasRend->splitRenderConfig.isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ hIvasRend->splitRenderConfig.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hIvasRend->splitRenderConfig.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; -#ifdef FIX_HRTF_LOAD hIvasRend->splitRenderConfig.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; -#else - hIvasRend->splitRenderConfig.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; -#endif } return IVAS_ERR_OK; diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 32ee71bd2..46f01c2cf 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -46,7 +46,6 @@ #endif #include "wmc_auto.h" -#ifdef FIX_CREND_SIMPLIFY_CODE /*------------------------------------------------------------------------- * ivas_Crend_hrtf_init() * @@ -55,16 +54,6 @@ ivas_error ivas_Crend_hrtf_init( HRTFS_CREND_DATA *hHrtf /* i/o: HRTF handle */ -#else -/*------------------------------------------------------------------------- - * ivas_hrtf_init() - * - * Initialize hHrtf handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ -#endif ) { int16_t i, j; @@ -91,11 +80,9 @@ ivas_error ivas_hrtf_init( hHrtf->pIndex_frequency_max[i][j] = NULL; hHrtf->pOut_to_bin_re[i][j] = NULL; hHrtf->pOut_to_bin_im[i][j] = NULL; -#ifdef FIX_CREND_SIMPLIFY_CODE hHrtf->pOut_to_bin_re_dyn[i][j] = NULL; hHrtf->pOut_to_bin_im_dyn[i][j] = NULL; hHrtf->pIndex_frequency_max_dyn[i][j] = NULL; -#endif } } @@ -105,11 +92,9 @@ ivas_error ivas_hrtf_init( hHrtf->pIndex_frequency_max_diffuse[j] = NULL; hHrtf->pOut_to_bin_diffuse_re[j] = NULL; hHrtf->pOut_to_bin_diffuse_im[j] = NULL; -#ifdef FIX_CREND_SIMPLIFY_CODE hHrtf->pIndex_frequency_max_diffuse_dyn[j] = NULL; hHrtf->pOut_to_bin_diffuse_re_dyn[j] = NULL; hHrtf->pOut_to_bin_diffuse_im_dyn[j] = NULL; -#endif } hHrtf->init_from_rom = 1; @@ -117,7 +102,7 @@ ivas_error ivas_hrtf_init( return IVAS_ERR_OK; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*------------------------------------------------------------------------- * ivas_hrtf_open() * @@ -139,29 +124,6 @@ static ivas_error ivas_hrtf_open( } if ( ( error = ivas_Crend_hrtf_init( hHrtf ) ) != IVAS_ERR_OK ) -#else -/*------------------------------------------------------------------------- - * ivas_hrtf_open() - * - * Open hHrtf handle - *------------------------------------------------------------------------*/ - -static ivas_error ivas_hrtf_open( - HRTFS_HANDLE *hHrtf_out /* o : HRTF handle */ -) -{ - HRTFS_HANDLE hHrtf; - ivas_error error; - - if ( *hHrtf_out == NULL ) - { - if ( ( hHrtf = (HRTFS_HANDLE) malloc( sizeof( HRTFS_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" ); - } - - if ( ( error = ivas_hrtf_init( hHrtf ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -208,26 +170,14 @@ static ivas_error ivas_rend_initCrend( CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, -#ifdef FIX_CREND_SIMPLIFY_CODE HRTFS_CREND_HANDLE hHrtfCrend, const int16_t ext_rend_flag, -#else - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif const int32_t output_Fs ) { -#ifdef FIX_CREND_SIMPLIFY_CODE int16_t i, j, tmp, tmp2; -#else - int16_t i, j, tmp; -#endif int16_t nchan_in; IVAS_REND_AudioConfigType inConfigType; -#ifdef FIX_CREND_SIMPLIFY_CODE HRTFS_CREND_HANDLE hHrtf; -#else - HRTFS_HANDLE hHrtf; -#endif ivas_error error; inConfigType = getAudioConfigType( inConfig ); @@ -246,7 +196,6 @@ static ivas_error ivas_rend_initCrend( if ( hHrtf == NULL ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hHrtfCrend != NULL && ext_rend_flag == 0 ) { /* HRTF set loaded from binary file */ @@ -267,12 +216,6 @@ static ivas_error ivas_rend_initCrend( hHrtf->init_from_rom = 0; } } -#else - if ( ivas_hrtf_open( &hHrtf ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for HRTF handle" ); - } -#endif } if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) @@ -286,20 +229,8 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_INTERNAL_FATAL; } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hHrtf->init_from_rom ) { -#else - if ( ( hSetOfHRTF == NULL ) || - ( ( hSetOfHRTF->hHRTF_hrir_combined == NULL ) && ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) && ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || - ( ( hSetOfHRTF->hHRTF_hrir_combined == NULL ) && ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) && ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL ) ) || - ( ( hSetOfHRTF->hHRTF_brir_combined == NULL ) && ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) && ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) || - ( ( hSetOfHRTF->hHRTF_hrir_foa == NULL ) && ( inConfig == IVAS_AUDIO_CONFIG_FOA ) ) || - ( ( hSetOfHRTF->hHRTF_hrir_hoa2 == NULL ) && ( inConfig == IVAS_AUDIO_CONFIG_HOA2 ) ) || - ( ( hSetOfHRTF->hHRTF_hrir_hoa3 == NULL ) && ( inConfig == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - hHrtf->init_from_rom = 1; -#endif if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { hHrtf->max_num_ir -= 1; /* subtract LFE */ @@ -780,14 +711,10 @@ static ivas_error ivas_rend_initCrend( } else { -#ifndef FIX_CREND_SIMPLIFY_CODE - hHrtf->init_from_rom = 0; -#endif if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { hHrtf->max_num_ir -= 1; /* subtract LFE */ hHrtf->gain_lfe = GAIN_LFE; -#ifdef FIX_CREND_SIMPLIFY_CODE } if ( ext_rend_flag == 1 ) @@ -889,189 +816,6 @@ static ivas_error ivas_rend_initCrend( hHrtf->pOut_to_bin_re[i][j] = hHrtfCrend->pOut_to_bin_re[tmp][j]; hHrtf->pOut_to_bin_im[i][j] = hHrtfCrend->pOut_to_bin_im[tmp][j]; } -#else - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - if ( hSetOfHRTF->hHRTF_brir_combined == NULL ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " ); - } - hHrtf->latency_s = hSetOfHRTF->hHRTF_brir_combined->latency_s; - hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_brir_combined->max_num_iterations; - hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_brir_combined->index_frequency_max_diffuse; - } - else - { - if ( hSetOfHRTF->hHRTF_hrir_combined == NULL ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " ); - } - hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_combined->latency_s; - hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_combined->max_num_iterations; - hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_combined->index_frequency_max_diffuse; - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max_diffuse[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_im[j]; - } - else - { - hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max_diffuse[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_im[j]; - } - } - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( inConfig == IVAS_AUDIO_CONFIG_5_1 ) - { - tmp = channelIndex_CICP6[i]; - } - else if ( inConfig == IVAS_AUDIO_CONFIG_7_1 ) - { - tmp = channelIndex_CICP12[i]; - } - else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_2 ) - { - tmp = channelIndex_CICP14[i]; - } - else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_4 ) - { - tmp = channelIndex_CICP16[i]; - } - else if ( inConfig == IVAS_AUDIO_CONFIG_7_1_4 ) - { - tmp = channelIndex_CICP19[i]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[j][tmp]; - hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_re[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_im[tmp][j]; - } - else - { - hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight[j][tmp]; - hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_im[tmp][j]; - } - } - } - } - else if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) - { - if ( inConfig == IVAS_AUDIO_CONFIG_HOA3 ) - { - if ( hSetOfHRTF->hHRTF_hrir_hoa3 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters" ); - } - hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_hoa3->latency_s; - hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_hoa3->max_num_iterations; - hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_hoa3->index_frequency_max_diffuse; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight[j][i]; - hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations[i][j]; - hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max[i][j]; - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_im[i][j]; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max_diffuse[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_im[j]; - } - } - else if ( inConfig == IVAS_AUDIO_CONFIG_HOA2 ) - { - if ( hSetOfHRTF->hHRTF_hrir_hoa2 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters" ); - } - hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_hoa2->latency_s; - hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_hoa2->max_num_iterations; - hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_hoa2->index_frequency_max_diffuse; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight[j][i]; - hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations[i][j]; - hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max[i][j]; - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_im[i][j]; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max_diffuse[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_im[j]; - } - } - else if ( inConfig == IVAS_AUDIO_CONFIG_FOA ) - { - if ( hSetOfHRTF->hHRTF_hrir_foa == NULL ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters" ); - } - hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_foa->latency_s; - hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_foa->max_num_iterations; - hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_foa->index_frequency_max_diffuse; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight[j][i]; - hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations[i][j]; - hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max[i][j]; - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_im[i][j]; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations_diffuse[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max_diffuse[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_im[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" ); -#endif } } } @@ -1342,12 +1086,10 @@ ivas_error ivas_rend_initCrendWrapper( ( *pCrend )->binaural_latency_ns = 0; ( *pCrend )->hHrtfCrend = NULL; -#ifdef FIX_CREND_SIMPLIFY_CODE for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { ( *pCrend )->hCrend[pos_idx] = NULL; } -#endif for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -1403,18 +1145,7 @@ ivas_error ivas_rend_openMultiBinCrend( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, const int32_t output_Fs ) { -#ifdef FIX_CREND_SIMPLIFY_CODE return ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, 0, pMultiBinPoseData->num_poses ); -#else - ivas_error error; - - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) - { - return error; - } - - return error; -#endif } @@ -1429,16 +1160,10 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, -#ifdef FIX_CREND_SIMPLIFY_CODE HRTFS_CREND_HANDLE hHrtfCrend, -#else - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, -#ifdef FIX_CREND_SIMPLIFY_CODE const int16_t ext_rend_flag, -#endif const int16_t num_poses ) { int16_t i, subframe_length; @@ -1459,11 +1184,7 @@ ivas_error ivas_rend_openCrend( if ( ( *pCrend )->hHrtfCrend == NULL ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hHrtfCrend, ext_rend_flag, output_Fs ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1554,11 +1275,7 @@ ivas_error ivas_rend_openCrend( hCrend->freq_buffer_re_diffuse[1] = NULL; hCrend->freq_buffer_im_diffuse[1] = NULL; } -#ifdef FIX_CREND_SIMPLIFY_CODE max_total_ir_len = (int32_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length; -#else - max_total_ir_len = (int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length; -#endif if ( max_total_ir_len > 0 ) { if ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) @@ -1636,12 +1353,7 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend -#ifndef FIX_CREND_SIMPLIFY_CODE - , - const int16_t num_poses -#endif -) + CREND_WRAPPER_HANDLE *pCrend ) { int16_t i; int16_t pos_idx; @@ -1651,20 +1363,13 @@ void ivas_rend_closeCrend( { return; } -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( ( *pCrend )->hHrtfCrend != NULL && ( *pCrend )->hHrtfCrend->init_from_rom ) -#else - if ( ( *pCrend )->hHrtfCrend != NULL ) -#endif { ivas_hrtf_close( &( *pCrend )->hHrtfCrend ); } -#ifdef FIX_CREND_SIMPLIFY_CODE for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) -#else - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) -#endif { hCrend = ( *pCrend )->hCrend[pos_idx]; if ( hCrend != NULL ) @@ -1805,19 +1510,11 @@ static ivas_error ivas_rend_crendConvolver( int32_t offset, offset_in, offset_diffuse; int16_t nchan_in, nchan_out; const float *pIn; -#ifdef FIX_CREND_SIMPLIFY_CODE const float *pFreq_filt_re, *pFreq_filt_im; float *pFreq_buf_re = NULL, *pFreq_buf_im = NULL; float *pFreq_buf2_re = NULL, *pFreq_buf2_im = NULL; float pOut[2 /*Re,Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; float tmp_out_re[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp_out_im[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; -#else - float *pFreq_buf_re, *pFreq_buf_im; - float *pFreq_buf2_re, *pFreq_buf2_im; - float *pFreq_filt_re, *pFreq_filt_im; - float pOut[L_FRAME48k * 2]; - float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; -#endif CREND_HANDLE hCrend; ivas_error error; @@ -1862,7 +1559,6 @@ static ivas_error ivas_rend_crendConvolver( } } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) @@ -1878,7 +1574,6 @@ static ivas_error ivas_rend_crendConvolver( pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse]; } } -#endif i = 0; for ( idx_in = 0; idx_in < nchan_in; idx_in++ ) @@ -1890,10 +1585,6 @@ static ivas_error ivas_rend_crendConvolver( { if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) { -#ifndef FIX_CREND_SIMPLIFY_CODE - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; -#endif pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; @@ -1905,12 +1596,6 @@ static ivas_error ivas_rend_crendConvolver( } else { -#ifndef FIX_CREND_SIMPLIFY_CODE - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; - pFreq_buf2_re = &hCrend->freq_buffer_re_diffuse[1][offset_diffuse]; - pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse]; -#endif pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; @@ -1924,14 +1609,7 @@ static ivas_error ivas_rend_crendConvolver( } } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_mdft( pIn, &hCrend->freq_buffer_re[i][offset], &hCrend->freq_buffer_im[i][offset], subframe_length, subframe_length ); -#else - pFreq_buf_re = &hCrend->freq_buffer_re[i][offset]; - pFreq_buf_im = &hCrend->freq_buffer_im[i][offset]; - - ivas_mdft( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); -#endif i++; } } @@ -2042,12 +1720,8 @@ ivas_error ivas_rend_crendProcessSubframe( int16_t subframe_idx, subframe_len; int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; float *tc_local[MAX_OUTPUT_CHANNELS]; -#ifdef FIX_CREND_SIMPLIFY_CODE float *p_output[BINAURAL_CHANNELS]; float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; -#else - float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; -#endif float *p_pcm_tmp[BINAURAL_CHANNELS]; IVAS_REND_AudioConfigType inConfigType; ivas_error error; @@ -2086,9 +1760,7 @@ ivas_error ivas_rend_crendProcessSubframe( for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_pcm_tmp[ch] = pcm_tmp[ch]; -#ifdef FIX_CREND_SIMPLIFY_CODE p_output[ch] = output[ch]; -#endif } if ( hTcBuffer != NULL ) @@ -2169,12 +1841,6 @@ ivas_error ivas_rend_crendProcessSubframe( { tc_local[ch] += subframe_len; } -#ifndef FIX_CREND_SIMPLIFY_CODE - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - p_pcm_tmp[ch] += subframe_len; - } -#endif if ( hTcBuffer != NULL ) { @@ -2185,7 +1851,7 @@ ivas_error ivas_rend_crendProcessSubframe( { return IVAS_ERR_INVALID_INPUT_FORMAT; } -#ifdef FIX_CREND_SIMPLIFY_CODE + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { /* move to output */ @@ -2193,19 +1859,11 @@ ivas_error ivas_rend_crendProcessSubframe( p_output[ch] += subframe_len; } -#endif + /* update combined orientation access index */ ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); } -#ifndef FIX_CREND_SIMPLIFY_CODE - /* move to output */ - for ( ch = 0; ch < nchan_out; ch++ ) - { - mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); - } - -#endif if ( hTcBuffer != NULL ) { hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 343de51bd..146f5772a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -428,9 +428,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( mvr2r( parametricReverberationEneCorrections, hrtfParambin->parametricReverberationEneCorrections, CLDFB_NO_CHANNELS_MAX ); mvr2r( parametricEarlyPartEneCorrection, hrtfParambin->parametricEarlyPartEneCorrection, CLDFB_NO_CHANNELS_MAX ); -#ifndef FIX_CREND_SIMPLIFY_CODE - hrtfParambin->allocatedFromFile = 0; -#endif *hHrtfParambin = hrtfParambin; return IVAS_ERR_OK; diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index a7be47c15..453552491 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -81,7 +81,7 @@ void ivas_HRTF_binary_close( return; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*-----------------------------------------------------------------------* * ivas_HRTF_CRend_binary_open() * @@ -149,35 +149,8 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_float( return IVAS_ERR_OK; } -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open() - * - * Allocate HRTF binary handle - *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF ) -{ - /* Allocate HR filter set for headphones configuration */ - *hSetOfHRTF = (HRTFS_CREND *) malloc( sizeof( HRTFS_CREND ) ); - if ( *hSetOfHRTF == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for set of HRTF binary!" ); - } - - ( *hSetOfHRTF )->hHRTF_hrir_combined = NULL; - ( *hSetOfHRTF )->hHRTF_hrir_hoa3 = NULL; - ( *hSetOfHRTF )->hHRTF_hrir_hoa2 = NULL; - ( *hSetOfHRTF )->hHRTF_hrir_foa = NULL; - ( *hSetOfHRTF )->hHRTF_brir_combined = NULL; - - return IVAS_ERR_OK; -} -#endif -#ifdef FIX_CREND_SIMPLIFY_CODE /*-------------------------------------------------------------------* * ivas_HRTF_CRend_binary_close() * @@ -232,28 +205,7 @@ void ivas_HRTF_CRend_binary_close( *hHrtfCrend = NULL; return; } -#else -/*-------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_close() - * - * Close HRTF CRend binary handle - *-------------------------------------------------------------------*/ - -void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF ) -{ - if ( hSetOfHRTF == NULL || *hSetOfHRTF == NULL ) - { - return; - } - - free( *hSetOfHRTF ); - *hSetOfHRTF = NULL; - - return; -} -#endif /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_open() @@ -385,11 +337,7 @@ void ivas_HRTF_statistics_close( ivas_error ivas_HRTF_statistics_init( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, -#ifdef FIX_CREND_SIMPLIFY_CODE const int32_t sampleRate ) -#else - int32_t sampleRate ) -#endif { HRTFS_STATISTICS *HrtfStatistics; diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 14851bba9..597a44b6e 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -38,26 +38,11 @@ #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_rom_rend.h" -#ifdef FIX_989_TD_REND_ROM #include -#else -#include "ivas_rom_binaural_crend_head.h" -#endif #ifdef DEBUGGING #include "debug.h" #endif -#ifndef FIX_989_TD_REND_ROM - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) -#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) - -#endif - /*------------------------------------------------------------------------- * Local functions declaration *-------------------------------------------------------------------------*/ @@ -310,9 +295,6 @@ ivas_error TDREND_MIX_AddSrc( TDREND_SRC_t *Src_p; ivas_error error; -#ifndef FIX_989_TD_REND_ROM - error = IVAS_ERR_OK; -#endif /* Get unique source index */ *SrcInd = hBinRendererTd->MaxSrcInd + 1; hBinRendererTd->MaxSrcInd++; @@ -349,11 +331,7 @@ ivas_error TDREND_MIX_AddSrc( } } -#ifdef FIX_989_TD_REND_ROM return IVAS_ERR_OK; -#else - return error; -#endif } @@ -397,9 +375,7 @@ static ivas_error DefaultBSplineModel( ModelParamsITD_t *modelITD; int16_t i, j; ivas_error error; -#ifdef FIX_989_TD_REND_ROM float azimSegSamples; -#endif HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel; model = &( HrFiltSet_p->ModelParams ); @@ -410,7 +386,6 @@ static ivas_error DefaultBSplineModel( model->modelROM = TRUE; /* int16_t parameters */ -#ifdef FIX_989_TD_REND_ROM model->UseItdModel = defaultHRIR_rom_model_configuration[0]; model->elevDim3 = defaultHRIR_rom_model_configuration[1]; model->AlphaN = defaultHRIR_rom_model_configuration[2]; @@ -418,25 +393,6 @@ static ivas_error DefaultBSplineModel( model->elevSegSamples = defaultHRIR_rom_model_configuration[4]; model->elevBsLen = defaultHRIR_rom_elevBsLen; model->elevBsStart = defaultHRIR_rom_elevBsStart; -#else - model->UseItdModel = 1; - model->SplineDegree = 4; - model->elevDim2 = 17; - model->elevDim3 = 15; - model->AlphaN = 470; - model->num_unique_azim_splines = 1; - model->elevSegSamples = 4; - model->elevBsLen[0] = 5; - model->elevBsLen[1] = 9; - model->elevBsLen[2] = 13; - model->elevBsLen[3] = 9; - model->elevBsStart[0] = 0; - model->elevBsStart[1] = 5; - model->elevBsStart[2] = 14; - model->elevBsStart[3] = 27; - - model->azimDim2 = defaultHRIR_rom_azimDim2; -#endif model->azimDim3 = defaultHRIR_rom_azimDim3; model->azim_start_idx = defaultHRIR_rom_azim_start_idx; model->azimSegSamples = defaultHRIR_rom_azimSegSamples; @@ -453,15 +409,11 @@ static ivas_error DefaultBSplineModel( } model->azimBsShape[0] = (const float *) defaultHRIR_rom_azimBsShape; -#ifdef FIX_989_TD_REND_ROM if ( ( model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ) ) == NULL ) -#else - if ( ( model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) ) ) == NULL ) -#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); } -#ifdef FIX_989_TD_REND_ROM + for ( i = 0; i < model->elevDim3; i++ ) { if ( ( model->azimKSeq[i] = (float *) malloc( ( model->azimDim3[i] + 1 ) * sizeof( float * ) ) ) == NULL ) @@ -484,32 +436,6 @@ static ivas_error DefaultBSplineModel( model->azimKSeq[i][j] = azimSegSamples * j; } } -#else - if ( ( model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); - } - if ( ( model->azimKSeq[model->elevDim3 - 1] = (float *) malloc( 2 * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); - } - model->azimKSeq[0][0] = 0.0f; - model->azimKSeq[model->elevDim3 - 1][0] = 0.0f; - model->azimKSeq[0][1] = 360.0f; - model->azimKSeq[model->elevDim3 - 1][1] = 360.0f; - - for ( i = 1; i < model->elevDim3 - 1; i++ ) - { - if ( ( model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ) ) == NULL ) /* azimDim2[i] = 91, i=2..15 */ - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); - } - for ( j = 0; j < model->azimDim2[i]; j++ ) - { - model->azimKSeq[i][j] = (float) defaultHRIR_rom_azimSegSamples[0] * j; - } - } -#endif switch ( output_Fs ) { @@ -518,11 +444,7 @@ static ivas_error DefaultBSplineModel( model->AlphaR = (const float *) defaultHRIR_rom_AlphaR48; model->EL = (const float *) defaultHRIR_rom_EL48; model->ER = (const float *) defaultHRIR_rom_ER48; -#ifdef FIX_989_TD_REND_ROM model->K = defaultHRIR_rom_model_configuration[5]; -#else - model->K = 128; -#endif if ( HrFiltSet_p->ModelParams.UseItdModel ) { modelITD->resamp_factor = 1.0f; @@ -533,11 +455,7 @@ static ivas_error DefaultBSplineModel( model->AlphaR = (const float *) defaultHRIR_rom_AlphaR32; model->EL = (const float *) defaultHRIR_rom_EL32; model->ER = (const float *) defaultHRIR_rom_ER32; -#ifdef FIX_989_TD_REND_ROM model->K = (int16_t) ceilf( RESAMPLE_FACTOR_32_48 * defaultHRIR_rom_model_configuration[5] ); -#else - model->K = 86; -#endif if ( HrFiltSet_p->ModelParams.UseItdModel ) { modelITD->resamp_factor = RESAMPLE_FACTOR_32_48; @@ -548,11 +466,7 @@ static ivas_error DefaultBSplineModel( model->AlphaR = (const float *) defaultHRIR_rom_AlphaR16; model->EL = (const float *) defaultHRIR_rom_EL16; model->ER = (const float *) defaultHRIR_rom_ER16; -#ifdef FIX_989_TD_REND_ROM model->K = (int16_t) ceilf( RESAMPLE_FACTOR_16_48 * defaultHRIR_rom_model_configuration[5] ); -#else - model->K = 43; -#endif if ( HrFiltSet_p->ModelParams.UseItdModel ) { modelITD->resamp_factor = RESAMPLE_FACTOR_16_48; @@ -562,47 +476,16 @@ static ivas_error DefaultBSplineModel( break; } -#ifdef FIX_989_TD_REND_ROM modelITD->elevDim3 = defaultHRIR_rom_ITD_model_configuration[0]; modelITD->azimDim3 = defaultHRIR_rom_ITD_model_configuration[1]; modelITD->elevSegSamples = defaultHRIR_rom_ITD_model_configuration[2]; modelITD->azimSegSamples = defaultHRIR_rom_ITD_model_configuration[3]; modelITD->elevBsLen = defaultHRIR_rom_ITD_elevBsLen; modelITD->elevBsStart = defaultHRIR_rom_ITD_elevBsStart; -#else - modelITD->N = 4; - modelITD->elevDim2 = 20; - modelITD->elevDim3 = 18; - modelITD->azimDim2 = 41; - modelITD->azimDim3 = 41; - modelITD->elevSegSamples = 3; - modelITD->elevBsLen[0] = 4; - modelITD->elevBsLen[1] = 7; - modelITD->elevBsLen[2] = 10; - modelITD->elevBsLen[3] = 7; - modelITD->elevBsStart[0] = 0; - modelITD->elevBsStart[1] = 4; - modelITD->elevBsStart[2] = 11; - modelITD->elevBsStart[3] = 21; -#endif - modelITD->elevKSeq = defaultHRIR_rom_ITD_elevKSeq; -#ifdef FIX_989_TD_REND_ROM modelITD->azimBsLen = defaultHRIR_rom_ITD_azimBsLen; modelITD->azimBsStart = defaultHRIR_rom_ITD_azimBsStart; -#else - modelITD->azimBsLen[0] = 11; - modelITD->azimBsLen[1] = 21; - modelITD->azimBsLen[2] = 31; - modelITD->azimBsLen[3] = 21; - modelITD->azimBsStart[0] = 0; - modelITD->azimBsStart[1] = 11; - modelITD->azimBsStart[2] = 32; - modelITD->azimBsStart[3] = 63; - - modelITD->azimSegSamples = 10; -#endif modelITD->azimKSeq = defaultHRIR_rom_ITD_azimKSeq; modelITD->W = (const float *) defaultHRIR_rom_ITD_W; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 1a86ba3bb..eee2360fc 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -569,7 +569,6 @@ void ivas_HRTF_parambin_binary_close( HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ ); -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error ivas_HRTF_CRend_binary_open( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); @@ -592,20 +591,6 @@ ivas_error ivas_HRTF_statistics_init( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ const int32_t sampleRate /* i : Sample rate */ ); -#else -ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ -); - -void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ -); - -ivas_error ivas_HRTF_statistics_init( - HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ - int32_t sampleRate /* i : Sample rate */ -); -#endif void ivas_HRTF_statistics_close( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ @@ -902,38 +887,20 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG inConfig, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, -#ifdef FIX_CREND_SIMPLIFY_CODE HRTFS_CREND_HANDLE hHrtfCrend, -#else - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, -#ifdef FIX_CREND_SIMPLIFY_CODE const int16_t ext_rend_flag, -#endif const int16_t num_poses ); -#ifdef FIX_CREND_SIMPLIFY_CODE + void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); -#else -void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend , - const int16_t num_poses -); -#endif -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error ivas_Crend_hrtf_init( HRTFS_CREND_DATA *hHrtf /* i/o: Crend HRTF handle */ ); -#else -ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ -); -#endif ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend, diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 3fee445ac..0cb6062fd 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -141,11 +141,7 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; -#ifdef FIX_HRTF_LOAD ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; -#else - ( *hRenderConfig )->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; -#endif ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; return IVAS_ERR_OK; diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index 064d1fa88..c2e619d4d 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -47,11 +47,7 @@ *------------------------------------------------------------------------*/ /* TD renderer default HRIR model */ extern const float defaultHRIR_rom_latency_s; -#ifdef FIX_989_TD_REND_ROM extern const int16_t defaultHRIR_rom_model_configuration[6]; -#else -extern const int16_t defaultHRIR_rom_azimDim2[15]; -#endif extern const int16_t defaultHRIR_rom_azimDim3[15]; extern const int16_t defaultHRIR_rom_azim_start_idx[15]; extern const int16_t defaultHRIR_rom_azimSegSamples[1]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 67c7fbbcb..396e4e6c6 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -494,11 +494,7 @@ typedef struct ivas_diffuse_distribution_data_structure } DIFFUSE_DISTRIBUTION_DATA, *DIFFUSE_DISTRIBUTION_HANDLE; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_parambin_struct -#else -typedef struct ivas_hrtfs_parambin_struct -#endif { float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; @@ -507,10 +503,6 @@ typedef struct ivas_hrtfs_parambin_struct float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; -#ifndef FIX_CREND_SIMPLIFY_CODE - int16_t allocatedFromFile; /* Not used and should not be here. Remove in cleanup. */ -#endif - } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; /* Parametric binaural data structure */ @@ -924,26 +916,14 @@ typedef struct { int16_t modelROM; /* Flag that indicates that the model resides in ROM (controls init/dealloc). */ int16_t UseItdModel; /* Controls whether ITD model is used. */ -#ifdef FIX_989_TD_REND_ROM - int16_t K; /* Length of filter */ -#else - int16_t SplineDegree; /* Degree of the spline functions */ - int16_t K; /* Length of filter */ - int16_t elevDim2; -#endif + int16_t K; /* Length of filter */ int16_t elevDim3; int16_t AlphaN; /* Number of rows in Alpha matrices */ int16_t num_unique_azim_splines; int16_t elevSegSamples; -#ifdef FIX_989_TD_REND_ROM const int16_t *elevBsLen; const int16_t *elevBsStart; -#else - int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - const int16_t *azimDim2; -#endif const int16_t *azimDim3; const int16_t *azim_start_idx; const int16_t *azimSegSamples; @@ -970,12 +950,8 @@ typedef struct float *ER_dyn; float *elevBsShape_dyn; float *elevKSeq_dyn; -#ifdef FIX_989_TD_REND_ROM int16_t *elevBsLen_dyn; int16_t *elevBsStart_dyn; -#else - int16_t *azimDim2_dyn; -#endif int16_t *azimDim3_dyn; int16_t *azim_start_idx_dyn; int16_t *azimSegSamples_dyn; @@ -987,43 +963,19 @@ typedef struct typedef struct { -#ifdef FIX_989_TD_REND_ROM - int16_t elevDim3; - const float *elevKSeq; /* Array, length elevDim3-2 */ - int16_t azimDim3; - const float *azimKSeq; /* Array, length azimDim3-2 */ - const float *W; /* Array, size (elevDim3*azimDim3) x K */ -#else - int16_t N; /* Polynomial degree */ - - int16_t elevDim2; int16_t elevDim3; const float *elevKSeq; /* Array, length elevDim3-2 */ - int16_t azimDim2; int16_t azimDim3; const float *azimKSeq; /* Array, length azimDim3-2 */ const float *W; /* Array, size (elevDim3*azimDim3) x K */ -#endif -#ifdef FIX_989_TD_REND_ROM const int16_t *azimBsLen; const int16_t *azimBsStart; -#else - int16_t azimBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - int16_t azimBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - -#endif const float *azimBsShape; int16_t azimSegSamples; -#ifdef FIX_989_TD_REND_ROM const int16_t *elevBsLen; const int16_t *elevBsStart; -#else - int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS]; - -#endif const float *elevBsShape; int16_t elevSegSamples; float resamp_factor; @@ -1034,12 +986,11 @@ typedef struct float *W_dyn; float *azimBsShape_dyn; float *elevBsShape_dyn; -#ifdef FIX_989_TD_REND_ROM int16_t *azimBsLen_dyn; int16_t *azimBsStart_dyn; int16_t *elevBsLen_dyn; int16_t *elevBsStart_dyn; -#endif + } ModelParamsITD_t; typedef struct @@ -1083,11 +1034,7 @@ typedef struct } TDREND_MIX_Listener_t; /* HR filter */ -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct -#else -typedef struct TDREND_HRFILT_FiltSet_struct -#endif { int32_t SampleRate; /* Sample rate of the HR filter */ int16_t NumPos; @@ -1216,33 +1163,18 @@ typedef struct /*------------------------------------------------------------------------------------------* * Crend structures *------------------------------------------------------------------------------------------*/ -#ifdef FIX_CREND_SIMPLIFY_CODE + typedef struct ivas_hrtf_crend_structure -#else -typedef struct ivas_hrtfs_structure -#endif { -#ifdef FIX_CREND_SIMPLIFY_CODE const float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; const float *pOut_to_bin_im[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; const float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS]; const float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS]; -#else - float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; - float *pOut_to_bin_im[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; - float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS]; - float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS]; -#endif float latency_s; uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; uint16_t num_iterations_diffuse[BINAURAL_CHANNELS]; -#ifdef FIX_CREND_SIMPLIFY_CODE const uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; const uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS]; -#else - uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; - uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS]; -#endif uint16_t index_frequency_max_diffuse; int16_t max_num_ir; int16_t max_num_iterations; @@ -1250,7 +1182,6 @@ typedef struct ivas_hrtfs_structure float inv_diffuse_weight[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ int16_t same_inv_diffuse_weight; float gain_lfe; -#ifdef FIX_CREND_SIMPLIFY_CODE float *pOut_to_bin_re_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; float *pOut_to_bin_im_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; float *pOut_to_bin_diffuse_re_dyn[BINAURAL_CHANNELS]; @@ -1259,9 +1190,7 @@ typedef struct ivas_hrtfs_structure uint16_t *pIndex_frequency_max_diffuse_dyn[BINAURAL_CHANNELS]; } HRTFS_DATA, *HRTFS_HANDLE, HRTFS_CREND_DATA, *HRTFS_CREND_HANDLE; // VE: all instance of HRTFS_DATAand *HRTFS_HANDLE should be renamed to HRTFS_CREND_DATA and *HRTFS_CREND_HANDLE -#else -} HRTFS_DATA, *HRTFS_HANDLE; -#endif + /* Main Crend structure */ typedef struct ivas_crend_state_t { @@ -1321,76 +1250,24 @@ typedef struct ivas_binaural_rendering_struct /*------------------------------------------------------------------------------------------* * HRTF structures - hrtfs from binary files *------------------------------------------------------------------------------------------*/ -#ifndef FIX_CREND_SIMPLIFY_CODE -typedef struct ivas_hrtfs_crend_structure -{ - HRTFS_DATA *hHRTF_hrir_combined; - HRTFS_DATA *hHRTF_hrir_hoa3; - HRTFS_DATA *hHRTF_hrir_hoa2; - HRTFS_DATA *hHRTF_hrir_foa; - HRTFS_DATA *hHRTF_brir_combined; -} HRTFS_CREND, *HRTFS_CREND_HANDLE; -#endif /* Fastconv binaural data structure */ -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_fastconv_struct -#else -typedef struct ivas_hrtfs_fastconv_struct -#endif { -#ifdef FIX_CREND_SIMPLIFY_CODE float FASTCONV_latency_s; float ***leftReal; float ***leftImag; float ***rightReal; float ***rightImag; int16_t n_channels; -#else - float FASTCONV_HOA3_latency_s; - float FASTCONV_HRIR_latency_s; - float ***leftHRIRReal_HOA3; - float ***leftHRIRImag_HOA3; - float ***rightHRIRReal_HOA3; - float ***rightHRIRImag_HOA3; - - float ***leftHRIRReal; - float ***leftHRIRImag; - float ***rightHRIRReal; - float ***rightHRIRImag; - - float ***leftBRIRReal; - float ***leftBRIRImag; - float ***rightBRIRReal; - float ***rightBRIRImag; - float FASTCONV_BRIR_latency_s; - - float ***leftHRIRReal_HOA2; - float ***leftHRIRImag_HOA2; - float ***rightHRIRReal_HOA2; - float ***rightHRIRImag_HOA2; - float FASTCONV_HOA2_latency_s; - - float ***leftHRIRReal_FOA; - float ***leftHRIRImag_FOA; - float ***rightHRIRReal_FOA; - float ***rightHRIRImag_FOA; - float FASTCONV_FOA_latency_s; -#endif int16_t allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ -#ifdef FIX_CREND_SIMPLIFY_CODE uint16_t ntaps; -#endif float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_statistics_struct -#else -typedef struct ivas_hrtfs_statistics_struct -#endif { const float *average_energy_l; const float *average_energy_r; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 07c3d6086..3d82cffa7 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1266,11 +1266,7 @@ static ivas_error initIsmMasaRendering( ivas_td_binaural_close( &inputIsm->tdRendWrapper.hBinRendererTd ); } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputIsm->crendWrapper ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper != NULL ? inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1385,11 +1381,7 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, 1, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1412,11 +1404,7 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputIsm->crendWrapper ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper != NULL ? inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -2114,11 +2102,7 @@ static ivas_error initMcBinauralRendering( /* if we need to use TD renderer and CREND was open, close it */ if ( useTDRend ) { -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputMc->crendWrapper ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif } if ( !reconfigureFlag || ( !useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL ) ) @@ -2177,13 +2161,8 @@ static ivas_error initMcBinauralRendering( else if ( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate, 1, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, - outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2223,11 +2202,7 @@ static ivas_error initMcMasaRendering( ivas_td_binaural_close( &inputMc->tdRendWrapper.hBinRendererTd ); } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputMc->crendWrapper ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2411,11 +2386,7 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputMc->crendWrapper ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2559,11 +2530,7 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { -#ifdef FIX_HRTF_LOAD if ( hRendCfg->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { #ifdef FIX_1113_EXTREND_ISAR assert( *rendCtx.pOutSampleRate == 48000 && "split binaural fast conv mode is currently supported with 48k sampling rate only" ); @@ -2590,11 +2557,7 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: #endif { -#ifdef FIX_HRTF_LOAD if ( hRendCfg->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { @@ -2603,11 +2566,7 @@ static ivas_error updateSbaPanGains( } else { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, 1, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2622,11 +2581,8 @@ static ivas_error updateSbaPanGains( { return error; } -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, 1, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2658,11 +2614,7 @@ static ivas_error initSbaMasaRendering( { ivas_error error; -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &inputSba->crendWrapper ); -#else - ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper != NULL ? inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { @@ -2741,12 +2693,8 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); -/* Free input's internal handles */ -#ifdef FIX_CREND_SIMPLIFY_CODE + /* Free input's internal handles */ ivas_rend_closeCrend( &inputSba->crendWrapper ); -#else - ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#endif if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { @@ -3449,11 +3397,7 @@ static int16_t getCldfbRendFlag( { isCldfbRend = 0; } -#ifdef FIX_HRTF_LOAD else if ( ( numMasaInputs > 0 ) || ( numSbaInputs > 0 && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) -#else - else if ( ( numMasaInputs > 0 ) || ( numSbaInputs > 0 && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) -#endif { isCldfbRend = 1; } @@ -4002,11 +3946,7 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) { -#ifdef FIX_HRTF_LOAD if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; } @@ -6683,11 +6623,7 @@ static ivas_error renderSbaToSplitBinaural( push_wmops( "renderSbaToSplitBinaural" ); error = IVAS_ERR_OK; -#ifdef FIX_HRTF_LOAD if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); @@ -6723,11 +6659,7 @@ static ivas_error renderSbaToBinaural( int16_t subframe_idx; push_wmops( "renderSbaToBinaural" ); -#ifdef FIX_HRTF_LOAD if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) -#else - if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) -#endif { float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index dfd0ee473..73f9b5fc9 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -32,17 +32,10 @@ #include "hrtf_file_reader.h" #include -#if defined FIX_989_TD_REND_ROM || defined FIX_CREND_SIMPLIFY_CODE #include #include -#else -#include "prot.h" -#endif #include "ivas_prot_rend.h" #include "ivas_prot.h" -#ifndef FIX_CREND_SIMPLIFY_CODE -#include "ivas_rom_binaural_crend_head.h" -#endif /*---------------------------------------------------------------------* * Local structures @@ -63,22 +56,7 @@ typedef struct ivas_hrtfs_file_header_t } ivas_hrtfs_file_header_t; -#ifndef FIX_989_TD_REND_ROM -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - -#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) -#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) - -/*---------------------------------------------------------------------* - * Local function declarations - *---------------------------------------------------------------------*/ - -static void HRTF_energy_sections_precalc( ModelParams_t *model ); - -#endif /*---------------------------------------------------------------------* * hrtfFileReader_open() * @@ -105,15 +83,9 @@ ivas_error hrtfFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } -#ifdef FIX_CREND_SIMPLIFY_CODE self = calloc( 1, sizeof( hrtfFileReader ) ); self->file = file; self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); -#else - self = calloc( sizeof( hrtfFileReader ), 1 ); - self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); -#endif strcpy( self->file_path, filePath ); *hrtfReader = self; @@ -158,12 +130,10 @@ static ivas_error read_and_check_hrtf_binary_file_header( { int32_t file_size; -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_file_header == NULL || f_hrtf == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif /* [Declaration of the binary file] */ /* File Identifier (8 bytes) */ @@ -208,21 +178,15 @@ static ivas_error read_and_check_hrtf_binary_file_header( static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_header == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif /* Check the renderer type */ if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && -#ifdef FIX_CREND_SIMPLIFY_CODE ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && -#else - ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) && -#endif ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_REVERB_ALL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" ); @@ -254,12 +218,11 @@ static ivas_error read_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header, FILE *f_hrtf ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_header == NULL || f_hrtf == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif + /* HRTF Header */ /* Renderer type (4 bytes) : See "HRTF_READER_RENDERER_TYPE" */ /* Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */ @@ -274,7 +237,7 @@ static ivas_error read_hrtf_binary_header( return IVAS_ERR_END_OF_FILE; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*-------------------------------------------------------------------* * audio_cfg_2_binaural_cfg() * @@ -309,9 +272,8 @@ static BINAURAL_INPUT_AUDIO_CONFIG audio_cfg_2_binaural_cfg( return hrtf_set_binaural_cfg; } -#endif -#ifdef FIX_989_TD_REND_ROM + /*-------------------------------------------------------------------* * TDREND_LoadBSplineBinaryITD() * @@ -466,67 +428,8 @@ static ivas_error TDREND_LoadBSplineBinaryITD( return IVAS_ERR_OK; } -#else -/*-------------------------------------------------------------------* - * LoadBSplineBinaryITD() - * - * Loads the B Spline HR filter model ITD data from file. - --------------------------------------------------------------------*/ - -static void LoadBSplineBinaryITD( - ModelParamsITD_t *modelITD, /* i/o: ITD model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ -) -{ - int16_t tmp; - fread( &modelITD->N, sizeof( int16_t ), 1, f_hrtf ); - fread( &modelITD->elevDim2, sizeof( int16_t ), 1, f_hrtf ); - fread( &modelITD->elevDim3, sizeof( int16_t ), 1, f_hrtf ); - modelITD->elevKSeq_dyn = (float *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); - fread( modelITD->elevKSeq_dyn, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf ); - - fread( &modelITD->azimDim2, sizeof( int16_t ), 1, f_hrtf ); - fread( &modelITD->azimDim3, sizeof( int16_t ), 1, f_hrtf ); - modelITD->azimKSeq_dyn = (float *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ - fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - modelITD->W_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->W_dyn, sizeof( float ), tmp, f_hrtf ); - - /* azimuth */ - fread( modelITD->azimBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - fread( modelITD->azimBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->azimBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->azimBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &modelITD->azimSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - /* elevation */ - fread( modelITD->elevBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - fread( modelITD->elevBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &modelITD->elevSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->elevKSeq = (const float *) modelITD->elevKSeq_dyn; - modelITD->azimKSeq = (const float *) modelITD->azimKSeq_dyn; - modelITD->W = (const float *) modelITD->W_dyn; - modelITD->azimBsShape = (const float *) modelITD->azimBsShape_dyn; - modelITD->elevBsShape = (const float *) modelITD->elevBsShape_dyn; - return; -} -#endif -#ifdef FIX_989_TD_REND_ROM /*-------------------------------------------------------------------* * TDREND_LoadBSplineBinary() * @@ -810,150 +713,9 @@ static ivas_error TDREND_LoadBSplineBinary( } } - return IVAS_ERR_OK; -} -#else -/*-------------------------------------------------------------------* - * LoadBSplineBinary() - * - * Loads the B Spline HR filter model data from file. - --------------------------------------------------------------------*/ - -static ivas_error LoadBSplineBinary( - IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ -) -{ - ModelParams_t *model; - int16_t i, tmp; - - fread( &HrFiltSet_p->latency_s, sizeof( float ), 1, f_hrtf ); - - model = &( HrFiltSet_p->ModelParams ); - - /* Set ROM flag for correct deallocation */ - model->modelROM = FALSE; - - fread( &model->UseItdModel, sizeof( int16_t ), 1, f_hrtf ); /* Indicates if ITD model is active */ - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - switch ( tmp ) - { - case 16: - HrFiltSet_p->SampleRate = 16000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_16_48; - } - break; - case 32: - HrFiltSet_p->SampleRate = 32000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_32_48; - } - break; - case 48: - HrFiltSet_p->SampleRate = 48000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = 1.0f; - } - break; - default: - return IVAS_ERROR( IVAS_ERR_INVALID_HRTF, "Error: HR filter file had an unsupported sampling rate (%d kHz)", tmp ); - } - - fread( &model->SplineDegree, sizeof( int16_t ), 1, f_hrtf ); - fread( &model->K, sizeof( int16_t ), 1, f_hrtf ); - - fread( &model->elevDim2, sizeof( int16_t ), 1, f_hrtf ); - fread( &model->elevDim3, sizeof( int16_t ), 1, f_hrtf ); - model->elevKSeq_dyn = (float *) malloc( ( model->elevDim3 - 2 ) * sizeof( float ) ); - fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf ); - model->azimDim2_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - model->azimDim3_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - model->azim_start_idx_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ); - for ( i = 0; i < model->elevDim3; i++ ) - { - fread( &model->azimDim2_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - fread( &model->azimDim3_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - fread( &model->azim_start_idx_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - model->azimKSeq[i] = (float *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); - fread( model->azimKSeq[i], sizeof( float ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); - } - fread( &model->AlphaN, sizeof( int16_t ), 1, f_hrtf ); - - model->AlphaL_dyn = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); - fread( model->AlphaL_dyn, sizeof( float ), model->AlphaN * model->K, f_hrtf ); - - model->AlphaR_dyn = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); - fread( model->AlphaR_dyn, sizeof( float ), model->AlphaN * model->K, f_hrtf ); - - /* azimuth */ - fread( &model->num_unique_azim_splines, sizeof( int16_t ), 1, f_hrtf ); - model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); - model->azimBsShape_dyn = (float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); - model->azimSegSamples_dyn = (int16_t *) malloc( model->num_unique_azim_splines * sizeof( int16_t ) ); - for ( i = 0; i < model->num_unique_azim_splines; i++ ) - { - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - model->azimBsShape_dyn[i] = (float *) malloc( tmp * sizeof( float ) ); - fread( model->azimBsShape_dyn[i], sizeof( float ), tmp, f_hrtf ); - fread( &model->azimSegSamples_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - } - - model->azimShapeIdx_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - fread( model->azimShapeIdx_dyn, sizeof( int16_t ), model->elevDim3, f_hrtf ); - model->azimShapeSampFactor_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - fread( model->azimShapeSampFactor_dyn, sizeof( int16_t ), model->elevDim3, f_hrtf ); - - /* elevation */ - fread( model->elevBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - fread( model->elevBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - model->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( model->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &model->elevSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - /* Set const pointers */ - model->AlphaL = (const float *) model->AlphaL_dyn; - model->AlphaR = (const float *) model->AlphaR_dyn; - model->EL = (const float *) model->EL_dyn; - model->ER = (const float *) model->ER_dyn; - model->elevBsShape = (const float *) model->elevBsShape_dyn; - model->elevKSeq = (const float *) model->elevKSeq_dyn; - model->azimDim2 = (const int16_t *) model->azimDim2_dyn; - model->azimDim3 = (const int16_t *) model->azimDim3_dyn; - model->azim_start_idx = (const int16_t *) model->azim_start_idx_dyn; - model->azimSegSamples = (const int16_t *) model->azimSegSamples_dyn; - model->azimShapeIdx = (const int16_t *) model->azimShapeIdx_dyn; - model->azimShapeSampFactor = (const int16_t *) model->azimShapeSampFactor_dyn; - - for ( i = 0; i < model->num_unique_azim_splines; i++ ) - { - model->azimBsShape[i] = (const float *) model->azimBsShape_dyn[i]; - } - - HRTF_model_precalc( model ); - HRTF_energy_sections_precalc( model ); - HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; - - HrFiltSet_p->ModelEval.hrfModL = (float *) malloc( model->K * sizeof( float ) ); - HrFiltSet_p->ModelEval.hrfModR = (float *) malloc( model->K * sizeof( float ) ); - - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf ); - } - - return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* * load_reverb_from_binary() @@ -963,12 +725,8 @@ static ivas_error LoadBSplineBinary( static ivas_error load_reverb_from_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const int32_t sampleRate, /* i : sample rate */ -#else - int32_t sampleRate, /* i : sample rate */ -#endif - FILE *f_hrtf /* i : HR filter data file handle */ + const int32_t sampleRate, /* i : sample rate */ + FILE *f_hrtf /* i : HR filter data file handle */ ) { bool is_reverb; @@ -979,16 +737,12 @@ static ivas_error load_reverb_from_binary( int32_t hrtf_data_size_max; char *hrtf_data; int16_t lr_iac_len; -#ifdef FIX_CREND_SIMPLIFY_CODE int16_t ind; Word16 factorQ; Word16 tmp16; float factorQ_f; if ( hHrtfStatistics == NULL || f_hrtf == NULL ) -#else - if ( hHrtfStatistics == NULL ) -#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1045,7 +799,6 @@ static ivas_error load_reverb_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } } -#ifdef FIX_CREND_SIMPLIFY_CODE else { if ( hrtf_header.frequency != sampleRate ) @@ -1054,7 +807,6 @@ static ivas_error load_reverb_from_binary( return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; } } -#endif } free( hrtf_data ); @@ -1064,18 +816,13 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_l_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); hHrtfStatistics->average_energy_r_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); hHrtfStatistics->inter_aural_coherence_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) -#else - if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } hHrtfStatistics->average_energy_l = hHrtfStatistics->average_energy_l_dyn; hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; -#ifdef FIX_CREND_SIMPLIFY_CODE fread( &factorQ, sizeof( Word16 ), 1, f_hrtf ); factorQ_f = powf( 2.f, -1.f * factorQ ); for ( ind = 0; ind < lr_iac_len; ind++ ) @@ -1093,11 +840,7 @@ static ivas_error load_reverb_from_binary( fread( &tmp16, sizeof( Word16 ), 1, f_hrtf ); hHrtfStatistics->inter_aural_coherence_dyn[ind] = factorQ_f * tmp16; } -#else - fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); -#endif + hHrtfStatistics->fromROM = FALSE; } else @@ -1116,20 +859,15 @@ static ivas_error load_reverb_from_binary( ivas_error load_reverb_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const int32_t sampleRate, /* i : sample rate */ -#else - int32_t sampleRate, /* i : sample rate */ -#endif - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ + const int32_t sampleRate, /* i : sample rate */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtfReader == NULL || hrtfReader->file == NULL || hHrtfStatistics == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif + fseek( hrtfReader->file, 0, SEEK_SET ); return load_reverb_from_binary( hHrtfStatistics, sampleRate, hrtfReader->file ); @@ -1142,10 +880,8 @@ ivas_error load_reverb_binary( --------------------------------------------------------------------*/ static ivas_error TDREND_MIX_LoadHRTF( - FILE *f_hrtf, /* i/o: File pointer to HRTF file */ -#ifdef FIX_989_TD_REND_ROM - const int32_t sampleRate, /* i : sample rate */ -#endif + FILE *f_hrtf, /* i/o: File pointer to HRTF file */ + const int32_t sampleRate, /* i : sample rate */ IVAS_DEC_HRTF_HANDLE HrFiltSet_p /* o : Loaded HR filter set */ ) { @@ -1160,12 +896,10 @@ static ivas_error TDREND_MIX_LoadHRTF( header_check_result = IVAS_ERR_OK; -#ifdef FIX_CREND_SIMPLIFY_CODE if ( f_hrtf == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK ) { @@ -1183,11 +917,7 @@ static ivas_error TDREND_MIX_LoadHRTF( } else { -#ifdef FIX_989_TD_REND_ROM header_check_result = TDREND_LoadBSplineBinary( HrFiltSet_p, f_hrtf ); -#else - header_check_result = LoadBSplineBinary( HrFiltSet_p, f_hrtf ); -#endif } return header_check_result; @@ -1206,9 +936,7 @@ static ivas_error TDREND_MIX_LoadHRTF( hrtf_data = (char *) malloc( hrtf_data_size_max ); if ( hrtf_data == NULL ) { -#ifdef FIX_989_TD_REND_ROM free( hrtf_data ); -#endif return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } @@ -1216,17 +944,13 @@ static ivas_error TDREND_MIX_LoadHRTF( { if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK ) { -#ifdef FIX_989_TD_REND_ROM free( hrtf_data ); -#endif return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "HRTF binary file not compliant (number of HRTF)" ); } if ( ( header_check_result = check_hrtf_binary_header( &hrtf_header ) ) != IVAS_ERR_OK ) { -#ifdef FIX_989_TD_REND_ROM free( hrtf_data ); -#endif return header_check_result; } @@ -1239,7 +963,6 @@ static ivas_error TDREND_MIX_LoadHRTF( return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } } -#ifdef FIX_989_TD_REND_ROM else { if ( hrtf_header.frequency != sampleRate ) @@ -1248,7 +971,6 @@ static ivas_error TDREND_MIX_LoadHRTF( return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; } } -#endif } free( hrtf_data ); @@ -1268,11 +990,7 @@ static ivas_error TDREND_MIX_LoadHRTF( } else { -#ifdef FIX_989_TD_REND_ROM header_check_result = TDREND_LoadBSplineBinary( HrFiltSet_p, f_hrtf ); -#else - header_check_result = LoadBSplineBinary( HrFiltSet_p, f_hrtf ); -#endif } } else @@ -1283,7 +1001,7 @@ static ivas_error TDREND_MIX_LoadHRTF( return header_check_result; } -#ifdef FIX_989_TD_REND_ROM + /*---------------------------------------------------------------------* * load_TDrend_HRTF_binary() * @@ -1305,85 +1023,7 @@ ivas_error load_TDrend_HRTF_binary( return TDREND_MIX_LoadHRTF( hrtfReader->file, sampleRate, hHrtf ); } -#else -/*---------------------------------------------------------------------* - * load_HRTF_binary() - * - * Load HRTF binary data into the HRTF handle - *---------------------------------------------------------------------*/ - -ivas_error load_HRTF_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ -) -{ - ivas_error error; - - fseek( hrtfReader->file, 0, SEEK_SET ); - - error = TDREND_MIX_LoadHRTF( hrtfReader->file, hHrtf ); - - return error; -} - -/*---------------------------------------------------------------------* - * HRTF_energy_sections_precalc() - * - * Calculate energies of each section and store in model->EL/model->ER - *---------------------------------------------------------------------*/ - -static void HRTF_energy_sections_precalc( - ModelParams_t *model /* i/o: HRTF model parameters */ -) -{ - int16_t i, k, j; - float *pEL; - float *pER; - const float *pAlphaL; - const float *pAlphaR; - float tmp; - int16_t AlphaN; - - if ( !model->modelROM ) - { - AlphaN = model->AlphaN; - - /* Precalculated energies for each section and each row of the alpha matrices */ - model->EL_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * AlphaN * sizeof( float ) ); - model->ER_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * AlphaN * sizeof( float ) ); - pEL = model->EL_dyn; - pER = model->ER_dyn; - for ( i = 0; i < HRTF_MODEL_N_SECTIONS; i++ ) - { - for ( j = 0; j < AlphaN; j++ ) /* rows of Alpha matrices */ - { - *pEL = 0.0f; - *pER = 0.0f; - - pAlphaL = &model->AlphaL[model->iSecFirst[i] * AlphaN + j]; - pAlphaR = &model->AlphaR[model->iSecFirst[i] * AlphaN + j]; - - for ( k = model->iSecFirst[i]; k < model->iSecLast[i]; k++ ) /* k within the sections */ - { - /* Energy calculation */ - tmp = *pAlphaL; - *pEL += tmp * tmp; - tmp = *pAlphaR; - *pER += tmp * tmp; - pAlphaL += AlphaN; - pAlphaR += AlphaN; - } - pEL++; - pER++; - } - } - model->EL = (const float *) model->EL_dyn; - model->ER = (const float *) model->ER_dyn; - } - return; -} -#endif /*---------------------------------------------------------------------* * destroy_td_hrtf() @@ -1411,18 +1051,13 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelParamsITD.W_dyn ); free( ( *hHrtf )->ModelParamsITD.azimBsShape_dyn ); free( ( *hHrtf )->ModelParamsITD.elevBsShape_dyn ); -#ifdef FIX_989_TD_REND_ROM free( ( *hHrtf )->ModelParamsITD.azimBsLen_dyn ); free( ( *hHrtf )->ModelParamsITD.azimBsStart_dyn ); free( ( *hHrtf )->ModelParamsITD.elevBsLen_dyn ); free( ( *hHrtf )->ModelParamsITD.elevBsStart_dyn ); -#endif } free( ( *hHrtf )->ModelParams.elevKSeq_dyn ); free( ( *hHrtf )->ModelParams.azim_start_idx_dyn ); -#ifndef FIX_989_TD_REND_ROM - free( ( *hHrtf )->ModelParams.azimDim2_dyn ); -#endif free( ( *hHrtf )->ModelParams.azimDim3_dyn ); free( ( *hHrtf )->ModelParams.AlphaL_dyn ); free( ( *hHrtf )->ModelParams.AlphaR_dyn ); @@ -1430,10 +1065,8 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelParams.azimShapeIdx_dyn ); free( ( *hHrtf )->ModelParams.azimShapeSampFactor_dyn ); -#ifdef FIX_989_TD_REND_ROM free( ( *hHrtf )->ModelParams.elevBsLen_dyn ); free( ( *hHrtf )->ModelParams.elevBsStart_dyn ); -#endif free( ( *hHrtf )->ModelParams.elevBsShape_dyn ); for ( i = 0; i < ( *hHrtf )->ModelParams.num_unique_azim_splines; i++ ) @@ -1461,7 +1094,7 @@ void destroy_td_hrtf( return; } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*---------------------------------------------------------------------* * create_Crend_HRTF_from_rawdata() * @@ -2041,617 +1674,45 @@ static ivas_error create_parambin_HRTF_from_rawdata( return IVAS_ERR_OK; } -#else + + /*---------------------------------------------------------------------* - * create_HRTF_from_rawdata() + * load_fastconv_HRTF_from_binary() * - * Create HRTF from the raw data (to the HRTF CRend handle) + * Load FastConv HRTF binary data into the handle *---------------------------------------------------------------------*/ -static ivas_error create_HRTF_from_rawdata( - HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ - char *hrtf_data /* i : pointer to binary file */ +ivas_error load_fastconv_HRTF_from_binary( + IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ + const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ + const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ) { - int16_t i, j, k; - int16_t max_num_iterations_diffuse; - uint16_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; - uint32_t mem_size; - char *hrtf_data_rptr; - float *pOut_to_bin_wptr; - ivas_error error; + FILE *f_hrtf; + int32_t hrtf_data_size_max; + char *hrtf_data; + ivas_hrtfs_header_t hrtf_header; + ivas_error header_check_result; + ivas_hrtfs_file_header_t hrtfs_file_header; + int16_t hrtf_id; + int16_t asFastconv = 0; + bool load = false; + BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; - if ( *hHRTF == NULL ) - { - if ( ( ( *hHRTF ) = (HRTFS_HANDLE) malloc( sizeof( HRTFS_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); - } + /* convert audio config. to HRTF binaural config */ + hrtf_set_binaural_cfg = audio_cfg_2_binaural_cfg( hrtf_set_audio_cfg ); - if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else + if ( hrtfReader == NULL || hrtfReader->file == NULL ) { - return IVAS_ERR_INTERNAL; + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ( *hHRTF )->init_from_rom = 0; - hrtf_data_rptr = hrtf_data; - - /* latency_s */ - ( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - /* max_num_ir */ - ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + f_hrtf = hrtfReader->file; - /* BINAURAL_CHANNELS */ - if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) + if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* max_num_iterations */ - ( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); - - /* num_iterations */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - ( *hHRTF )->num_iterations[i][j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - } - } - - /* pIndex_frequency_max */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t ); - ( *hHRTF )->pIndex_frequency_max[i][j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); - } - memcpy( ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - } - } - - /* max_num_iterations_diffuse */ - max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); - - if ( max_num_iterations_diffuse != 0 ) - { - /* num_iterations_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - ( *hHRTF )->num_iterations_diffuse[j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - } - - /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); - ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); - } - memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - } - } - - /* index_frequency_max_diffuse */ - ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight[0][i] = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - } - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight[1][i] = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - } - - - /* max_total_num_fsamp_per_iteration */ - max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - /* coeff_re (the size depends on pIndex_frequency_max) */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - ( *hHRTF )->pOut_to_bin_re[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_re[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re[i][j]; - for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) - { - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; - } - } - } - - /* coeff_im (the size depends on pIndex_frequency_max) */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - ( *hHRTF )->pOut_to_bin_im[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_im[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im[i][j]; - for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) - { - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; - } - } - } - - /* max_total_num_fsamp_per_iteration_diff */ - max_total_num_fsamp_per_iteration_diff = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - if ( max_total_num_fsamp_per_iteration_diff != 0 ) - { - /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - ( *hHRTF )->pOut_to_bin_diffuse_re[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re[j]; - for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) - { - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; - } - } - - /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - ( *hHRTF )->pOut_to_bin_diffuse_im[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im[j]; - for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) - { - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; - } - } - } - - return IVAS_ERR_OK; -} - - -static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ -) -{ - int16_t i, j; - char *hrtf_data_rptr; - ivas_error error; - - ( *hHRTF )->allocate_init_flag = 0; - - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) - { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); - } - - hrtf_data_rptr = hrtf_data; - - - /* HRIR */ - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - ( *hHRTF )->FASTCONV_HRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) - { - /* HRIR_HOA3 */ - ( *hHRTF )->FASTCONV_HOA3_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA3_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRReal_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRImag_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRReal_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRImag_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { - /* HRIR_HOA2 */ - ( *hHRTF )->FASTCONV_HOA2_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRReal_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRImag_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRReal_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRImag_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { - /* HRIR_FOA */ - ( *hHRTF )->FASTCONV_FOA_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRReal_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftHRIRImag_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRReal_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightHRIRImag_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); - } - } - } - /* BRIR */ - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - ( *hHRTF )->FASTCONV_BRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftBRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftBRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightBRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->rightBRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } - } - - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - memcpy( ( *hHRTF )->fastconvReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - } - - return IVAS_ERR_OK; -} - -#endif - -/*---------------------------------------------------------------------* - * load_fastconv_HRTF_from_binary() - * - * Load FastConv HRTF binary data into the handle - *---------------------------------------------------------------------*/ - -ivas_error load_fastconv_HRTF_from_binary( - IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ - const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ -#endif - const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ -) -{ - FILE *f_hrtf; - int32_t hrtf_data_size_max; - char *hrtf_data; - ivas_hrtfs_header_t hrtf_header; - ivas_error header_check_result; - ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - int16_t asFastconv = 0; -#ifdef FIX_CREND_SIMPLIFY_CODE - bool load = false; - BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; - - /* convert audio config. to HRTF binaural config */ - hrtf_set_binaural_cfg = audio_cfg_2_binaural_cfg( hrtf_set_audio_cfg ); - - if ( hrtfReader == NULL || hrtfReader->file == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } -#endif - f_hrtf = hrtfReader->file; - - if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK ) - { - return header_check_result; + return header_check_result; } hrtf_data_size_max = hrtfs_file_header.max_data_size; @@ -2677,7 +1738,7 @@ ivas_error load_fastconv_HRTF_from_binary( free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && /* BRIRs */ @@ -2693,10 +1754,7 @@ ivas_error load_fastconv_HRTF_from_binary( { return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; } -#else - if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { -#endif + if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { free( hrtf_data ); @@ -2709,9 +1767,8 @@ ivas_error load_fastconv_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create FastConv HRTF from binary file" ); } asFastconv = 1; -#ifdef FIX_CREND_SIMPLIFY_CODE + break; /* read just one set */ -#endif } else { @@ -2730,77 +1787,6 @@ ivas_error load_fastconv_HRTF_from_binary( } } -#ifndef FIX_CREND_SIMPLIFY_CODE -/*---------------------------------------------------------------------* - * create_parambin_HRTF_from_rawdata() - * - * - *---------------------------------------------------------------------*/ - -static ivas_error create_parambin_HRTF_from_rawdata( - HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ - char *hrtf_data /* i : pointer to binary file */ -) -{ - int16_t i, j; - char *hrtf_data_rptr; - uint32_t data_size_tmp; - - hrtf_data_rptr = hrtf_data; - - /* HRTF_SH_CHANNELS */ - if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF_NUM_BINS */ - if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF */ - data_size_tmp = HRTF_NUM_BINS * sizeof( float ); - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->hrtfShCoeffsRe[i][j], hrtf_data_rptr, data_size_tmp ); - hrtf_data_rptr += data_size_tmp; - } - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->hrtfShCoeffsIm[i][j], hrtf_data_rptr, data_size_tmp ); - hrtf_data_rptr += data_size_tmp; - } - } - - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - memcpy( ( *hHRTF )->parametricReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - memcpy( ( *hHRTF )->parametricReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - return IVAS_ERR_OK; -} - -#endif /*---------------------------------------------------------------------* * load_parambin_HRTF_from_binary() @@ -2821,12 +1807,12 @@ ivas_error load_parambin_HRTF_from_binary( ivas_hrtfs_file_header_t hrtfs_file_header; int16_t hrtf_id; int16_t asParam = 0; -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( hrtfReader == NULL || hrtfReader->file == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#endif + f_hrtf = hrtfReader->file; if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK ) @@ -2862,12 +1848,11 @@ ivas_error load_parambin_HRTF_from_binary( if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) /* Parametric binauralizer data is represented as single entity */ { -#ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */ { return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; } -#endif + if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { free( hrtf_data ); @@ -2898,7 +1883,7 @@ ivas_error load_parambin_HRTF_from_binary( } } -#ifdef FIX_CREND_SIMPLIFY_CODE + /*---------------------------------------------------------------------* * load_Crend_HRTF_from_binary() * @@ -3016,115 +2001,7 @@ ivas_error load_Crend_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); } } -#else -/*---------------------------------------------------------------------* - * create_SetOfHRTF_from_binary() - * - * Create the HRTF data set from the binary file - *---------------------------------------------------------------------*/ - -ivas_error create_SetOfHRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ - int32_t output_Fs ) /* i : Output sampling frequency */ -{ - FILE *f_hrtf; - int32_t hrtf_data_size_max; - char *hrtf_data; - ivas_hrtfs_header_t hrtf_header; - HRTFS_DATA **hHRTF; - ivas_error header_check_result; - ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - - f_hrtf = hrtfReader->file; - - if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK ) - { - return header_check_result; - } - - hrtf_data_size_max = hrtfs_file_header.max_data_size; - - /* Allocate the memory */ - - if ( hrtf_data_size_max == 0 ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (hrtf_data_size_max)" ); - } - - hrtf_data = (char *) malloc( hrtf_data_size_max ); - if ( hrtf_data == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - /* Read & load */ - - memset( hSetOfHRTF, 0x00, sizeof( HRTFS_CREND ) ); - - for ( hrtf_id = 0; hrtf_id < hrtfs_file_header.nb_hrtf; hrtf_id++ ) - { - if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK ) - { - free( hrtf_data ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); - } - - hHRTF = NULL; - if ( hrtf_header.frequency == output_Fs ) - { - if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) - { - if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_combined ); - } - else if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) - { - hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_hoa3 ); - } - else if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { - hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_hoa2 ); - } - else if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { - hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_foa ); - } - } - else if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - hHRTF = &( ( *hSetOfHRTF ).hHRTF_brir_combined ); - } - } - } - - if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) - { - - free( hrtf_data ); - return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); - } - - if ( hHRTF != NULL ) - { - /* Create the HRTF reading the raw data from the binary file */ - if ( ( create_HRTF_from_rawdata( hHRTF, hrtf_data ) ) != IVAS_ERR_OK ) - { - - free( hrtf_data ); - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); - } - } - } - free( hrtf_data ); - return IVAS_ERR_OK; -} -#endif /*---------------------------------------------------------------------* * destroy_crend_hrtf() @@ -3132,18 +2009,12 @@ ivas_error create_SetOfHRTF_from_binary( * Destroy the Crend HRTF data set *---------------------------------------------------------------------*/ -#ifdef FIX_CREND_SIMPLIFY_CODE void destroy_crend_hrtf( IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ ) -#else -static void destroy_HRTF( - HRTFS_HANDLE *hHRTF /* i/o: Crend HRTF handle */ -) -#endif { uint16_t i, j; -#ifdef FIX_CREND_SIMPLIFY_CODE + if ( *hHrtfCrend != NULL && hHrtfCrend != NULL ) { for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -3182,77 +2053,10 @@ static void destroy_HRTF( free( *hHrtfCrend ); *hHrtfCrend = NULL; } -#else - if ( hHRTF != NULL && *hHRTF != NULL && ( *hHRTF )->init_from_rom == 0 ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) - { - free( ( *hHRTF )->pIndex_frequency_max[i][j] ); - } - if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_re[i][j] ); - } - if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_im[i][j] ); - } - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) - { - free( ( *hHRTF )->pIndex_frequency_max_diffuse[j] ); - } - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_diffuse_re[j] ); - } - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_diffuse_im[j] ); - } - } - - free( *hHRTF ); - *hHRTF = NULL; - } -#endif - - return; -} -#ifndef FIX_CREND_SIMPLIFY_CODE -/*---------------------------------------------------------------------* - * destroy_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -void destroy_SetOfHRTF( - HRTFS_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -) -{ - if ( ( hSetOfHRTF != NULL ) && ( *hSetOfHRTF != NULL ) ) - { - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_combined ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa3 ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa2 ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_foa ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_brir_combined ) ); - } - - ivas_HRTF_CRend_binary_close( hSetOfHRTF ); return; } -#endif - /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index e5e7801f9..27dc8d179 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -38,33 +38,18 @@ typedef struct hrtfFileReader hrtfFileReader; -#ifndef FIX_CREND_SIMPLIFY_CODE -typedef struct ivas_hrtfs_header_t -{ - int32_t rend_type; - int32_t input_cfg; - int32_t frequency; - uint32_t data_size; - -} ivas_hrtfs_header_t; -#endif - typedef enum { HRTF_READER_RENDERER_BINAURAL_INVALID, HRTF_READER_RENDERER_BINAURAL_FASTCONV, HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, HRTF_READER_RENDERER_BINAURAL_PARAMETRIC, -#ifndef FIX_CREND_SIMPLIFY_CODE - HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, -#endif HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, HRTF_READER_RENDERER_BINAURAL_REVERB_ALL } HRTF_READER_RENDERER_TYPE; -#ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtfs_header_t { int32_t rend_type; @@ -73,7 +58,6 @@ typedef struct ivas_hrtfs_header_t uint32_t data_size; } ivas_hrtfs_header_t; -#endif /*---------------------------------------------------------------------* * hrtfFileReader_open() @@ -102,15 +86,9 @@ void hrtfFileReader_close( * Load TD renderer HRTF binary data into the HRTF handle *---------------------------------------------------------------------*/ -#ifdef FIX_989_TD_REND_ROM ivas_error load_TDrend_HRTF_binary( -#else -ivas_error load_HRTF_binary( -#endif - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ -#ifdef FIX_989_TD_REND_ROM - const int32_t sampleRate, /* i : sample rate */ -#endif + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ + const int32_t sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); @@ -122,12 +100,8 @@ ivas_error load_HRTF_binary( ivas_error load_reverb_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const int32_t sampleRate, /* i : sample rate */ -#else - int32_t sampleRate, /* i : sample rate */ -#endif - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ + const int32_t sampleRate, /* i : sample rate */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); /*---------------------------------------------------------------------* @@ -136,21 +110,12 @@ ivas_error load_reverb_binary( * Create the Crend HRTF data set from the binary file *---------------------------------------------------------------------*/ -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_error load_Crend_HRTF_from_binary( -#else -ivas_error create_SetOfHRTF_from_binary( - -#endif - IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE + IVAS_DEC_HRTF_CREND_HANDLE hHrtfCrend, /* i/o: HRTF CRend handle */ + const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ const int32_t sampleRate /* i : sample rate */ -#else - int32_t output_Fs /* i : Output sampling frequency */ -#endif ); @@ -160,11 +125,7 @@ ivas_error create_SetOfHRTF_from_binary( * Destroy the Crend HRTF data set *---------------------------------------------------------------------*/ -#ifdef FIX_CREND_SIMPLIFY_CODE void destroy_crend_hrtf( -#else -void destroy_SetOfHRTF( -#endif IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ ); @@ -176,11 +137,9 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ -#ifdef FIX_CREND_SIMPLIFY_CODE - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ - const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ -#endif - const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ + const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ + const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); /*---------------------------------------------------------------------* diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 829152e1d..9bd5e019d 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2648,35 +2648,19 @@ ivas_error RenderConfigReader_read( { if ( strcmp( pValue, "CREND" ) == 0 ) { -#ifdef FIX_HRTF_LOAD hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_CREND; -#else - hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_CREND; -#endif } else if ( strcmp( pValue, "FASTCONV" ) == 0 ) { -#ifdef FIX_HRTF_LOAD hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_FASTCONV; -#else - hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV; -#endif } else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) { -#ifdef FIX_HRTF_LOAD hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_PARAMBIN; -#else - hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN; -#endif } else if ( strcmp( pValue, "TDREND" ) == 0 ) { -#ifdef FIX_HRTF_LOAD hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_TDREND; -#else - hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND; -#endif } else { -- GitLab