Loading apps/decoder.c +236 −3 Original line number Diff line number Diff line Loading @@ -167,6 +167,25 @@ typedef struct } DecArguments; #ifdef FIX_CREND_SIMPLIFY_CODE typedef struct { hrtfFileReader *hrtfReader; char *hrtfFileName; IVAS_DEC_HRTF_HANDLE *hHrtfTD; IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics; IVAS_BIN_RENDERER_TYPE binaural_renderer; IVAS_BIN_RENDERER_TYPE binaural_renderer_old; IVAS_BIN_RENDERER_TYPE binaural_renderer_sec; IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old; IVAS_AUDIO_CONFIG hrtf_set_audio_cfg; } IVAS_DEC_HRTF_BINARY_WRAPPER; #endif /*------------------------------------------------------------------------------------------* * Local functions prototypes Loading @@ -176,7 +195,9 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); 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 ); #ifdef FIX_CREND_SIMPLIFY_CODE 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 ); #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 ); Loading Loading @@ -211,9 +232,13 @@ 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; Loading @@ -230,6 +255,11 @@ 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; /*------------------------------------------------------------------------------------------* Loading Loading @@ -769,11 +799,24 @@ int main( } /*------------------------------------------------------------------------------------------* * Load HRTF binary file data * Initialize HRTF binary file data *------------------------------------------------------------------------------------------*/ 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; if ( ( error = load_hrtf_from_file( &hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } #else if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); Loading Loading @@ -871,6 +914,7 @@ int main( destroy_hrtf_statistics( hHrtfStatistics ); } } #endif } /*------------------------------------------------------------------------------------------* Loading @@ -885,7 +929,13 @@ 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 *-----------------------------------------------------------------*/ Loading @@ -912,7 +962,11 @@ 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; } Loading Loading @@ -951,6 +1005,10 @@ 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 ) { Loading @@ -963,6 +1021,7 @@ cleanup: } IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); destroy_hrtf_statistics( hHrtfStatistics ); #endif } IVAS_DEC_Close( &hIvasDec ); Loading Loading @@ -3764,4 +3823,178 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( } #endif #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * load_hrtf_from_file() * * Load HRTF coefficients from external binary file *---------------------------------------------------------------------*/ static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, /* i/o: HRTF binary wrapper handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; IVAS_BIN_RENDERER_TYPE binaural_renderer, binaural_renderer_sec; if ( hHrtfBinary == NULL || hIvasDec == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } binaural_renderer = hHrtfBinary->binaural_renderer; binaural_renderer_sec = hHrtfBinary->binaural_renderer_sec; if ( ( binaural_renderer != hHrtfBinary->binaural_renderer_old ) || ( binaural_renderer_sec != hHrtfBinary->binaural_renderer_sec_old ) || ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) { /*------------------------------------------------------------------------------------------* * Release HRTF binary data *------------------------------------------------------------------------------------------*/ if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL ) { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK ) { return error; } /*------------------------------------------------------------------------------------------* * Load HRTF binary data *------------------------------------------------------------------------------------------*/ if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer_sec ) ) != IVAS_ERR_OK ) { return error; } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfCrend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hHrtfBinary->hrtfReader, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, 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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_crend_hrtf( hHrtfCrend ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { 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 ) ); return error; } if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_fastconv_hrtf( hHrtfFastConv ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_PARAMBIN || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { 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 ) ); return error; } if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_parambin_hrtf( hHrtfParambin ); } } } } if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); } } } return IVAS_ERR_OK; } #endif #undef WMC_TOOL_SKIP apps/renderer.c +29 −0 Original line number Diff line number Diff line Loading @@ -678,7 +678,11 @@ 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; Loading Loading @@ -967,7 +971,11 @@ int main( goto cleanup; } #ifdef FIX_CREND_SIMPLIFY_CODE 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 ) { Loading @@ -980,7 +988,15 @@ int main( } } #ifdef FIX_CREND_SIMPLIFY_CODE IVAS_AUDIO_CONFIG hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4; if ( args.inConfig.ambisonicsBuses->audioConfig != IVAS_AUDIO_CONFIG_INVALID && args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hrtf_set_audio_cfg = args.inConfig.ambisonicsBuses->audioConfig; } 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 ) ); Loading @@ -988,6 +1004,7 @@ int main( } if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) #endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { Loading @@ -996,7 +1013,11 @@ int main( } else { #ifdef FIX_CREND_SIMPLIFY_CODE destroy_crend_hrtf( hHrtfCrend ); #else destroy_SetOfHRTF( hSetOfHRTF ); #endif } } Loading @@ -1006,7 +1027,11 @@ 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 ) { Loading Loading @@ -2047,6 +2072,9 @@ cleanup: RotationFileReader_close( &referenceRotReader ); Vector3PairFileReader_close( &referenceVectorReader ); #ifdef FIX_CREND_SIMPLIFY_CODE destroy_td_hrtf( hHrtfTD ); #else if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL ) { destroy_SetOfHRTF( hSetOfHRTF ); Loading @@ -2055,6 +2083,7 @@ cleanup: { destroy_td_hrtf( hHrtfTD ); } #endif destroy_hrtf_statistics( hHrtfStatistics ); IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); Loading lib_com/common_api_types.h +20 −0 Original line number Diff line number Diff line Loading @@ -165,11 +165,19 @@ 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; Loading Loading @@ -201,6 +209,18 @@ 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, IVAS_BIN_RENDERER_TYPE_CREND, IVAS_BIN_RENDERER_TYPE_FASTCONV, IVAS_BIN_RENDERER_TYPE_PARAMBIN, IVAS_BIN_RENDERER_TYPE_TDREND, IVAS_BIN_RENDERER_TYPE_DEFAULT, } IVAS_BIN_RENDERER_TYPE; #endif /*----------------------------------------------------------------------------------* * Split rendering API constants, structures, and enums Loading lib_com/ivas_cnst.h +4 −0 Original line number Diff line number Diff line Loading @@ -1556,6 +1556,10 @@ typedef enum #define MAX_ANGULAR_STEP_INV ( 1.0f / MAX_ANGULAR_STEP ) #define MAX_INTERPOLATION_STEPS 12 #ifdef FIX_CREND_SIMPLIFY_CODE #define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) #define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) #endif /* ----- Enums - TD Renderer ----- */ Loading lib_com/ivas_error.h +7 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,9 @@ typedef enum IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, IVAS_ERR_INVALID_HRTF, #ifdef FIX_CREND_SIMPLIFY_CODE IVAS_ERR_INVALID_HRTF_SAMPLING_RATE, #endif IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA, IVAS_ERR_INVALID_INPUT_FORMAT, IVAS_ERR_INVALID_INDEX, Loading Loading @@ -256,6 +259,10 @@ 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"; #ifdef FIX_CREND_SIMPLIFY_CODE 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: Loading Loading
apps/decoder.c +236 −3 Original line number Diff line number Diff line Loading @@ -167,6 +167,25 @@ typedef struct } DecArguments; #ifdef FIX_CREND_SIMPLIFY_CODE typedef struct { hrtfFileReader *hrtfReader; char *hrtfFileName; IVAS_DEC_HRTF_HANDLE *hHrtfTD; IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics; IVAS_BIN_RENDERER_TYPE binaural_renderer; IVAS_BIN_RENDERER_TYPE binaural_renderer_old; IVAS_BIN_RENDERER_TYPE binaural_renderer_sec; IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old; IVAS_AUDIO_CONFIG hrtf_set_audio_cfg; } IVAS_DEC_HRTF_BINARY_WRAPPER; #endif /*------------------------------------------------------------------------------------------* * Local functions prototypes Loading @@ -176,7 +195,9 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); 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 ); #ifdef FIX_CREND_SIMPLIFY_CODE 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 ); #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 ); Loading Loading @@ -211,9 +232,13 @@ 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; Loading @@ -230,6 +255,11 @@ 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; /*------------------------------------------------------------------------------------------* Loading Loading @@ -769,11 +799,24 @@ int main( } /*------------------------------------------------------------------------------------------* * Load HRTF binary file data * Initialize HRTF binary file data *------------------------------------------------------------------------------------------*/ 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; if ( ( error = load_hrtf_from_file( &hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } #else if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); Loading Loading @@ -871,6 +914,7 @@ int main( destroy_hrtf_statistics( hHrtfStatistics ); } } #endif } /*------------------------------------------------------------------------------------------* Loading @@ -885,7 +929,13 @@ 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 *-----------------------------------------------------------------*/ Loading @@ -912,7 +962,11 @@ 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; } Loading Loading @@ -951,6 +1005,10 @@ 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 ) { Loading @@ -963,6 +1021,7 @@ cleanup: } IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); destroy_hrtf_statistics( hHrtfStatistics ); #endif } IVAS_DEC_Close( &hIvasDec ); Loading Loading @@ -3764,4 +3823,178 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( } #endif #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * load_hrtf_from_file() * * Load HRTF coefficients from external binary file *---------------------------------------------------------------------*/ static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, /* i/o: HRTF binary wrapper handle */ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; IVAS_BIN_RENDERER_TYPE binaural_renderer, binaural_renderer_sec; if ( hHrtfBinary == NULL || hIvasDec == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } binaural_renderer = hHrtfBinary->binaural_renderer; binaural_renderer_sec = hHrtfBinary->binaural_renderer_sec; if ( ( binaural_renderer != hHrtfBinary->binaural_renderer_old ) || ( binaural_renderer_sec != hHrtfBinary->binaural_renderer_sec_old ) || ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) { /*------------------------------------------------------------------------------------------* * Release HRTF binary data *------------------------------------------------------------------------------------------*/ if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL ) { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK ) { return error; } /*------------------------------------------------------------------------------------------* * Load HRTF binary data *------------------------------------------------------------------------------------------*/ if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer_sec ) ) != IVAS_ERR_OK ) { return error; } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfCrend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hHrtfBinary->hrtfReader, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, 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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_crend_hrtf( hHrtfCrend ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { 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 ) ); return error; } if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_fastconv_hrtf( hHrtfFastConv ); } } } if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_PARAMBIN || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { 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 ) ); return error; } if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_parambin_hrtf( hHrtfParambin ); } } } } if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->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", hHrtfBinary->hrtfFileName ); return error; } else { destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); } } } return IVAS_ERR_OK; } #endif #undef WMC_TOOL_SKIP
apps/renderer.c +29 −0 Original line number Diff line number Diff line Loading @@ -678,7 +678,11 @@ 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; Loading Loading @@ -967,7 +971,11 @@ int main( goto cleanup; } #ifdef FIX_CREND_SIMPLIFY_CODE 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 ) { Loading @@ -980,7 +988,15 @@ int main( } } #ifdef FIX_CREND_SIMPLIFY_CODE IVAS_AUDIO_CONFIG hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4; if ( args.inConfig.ambisonicsBuses->audioConfig != IVAS_AUDIO_CONFIG_INVALID && args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hrtf_set_audio_cfg = args.inConfig.ambisonicsBuses->audioConfig; } 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 ) ); Loading @@ -988,6 +1004,7 @@ int main( } if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) #endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { Loading @@ -996,7 +1013,11 @@ int main( } else { #ifdef FIX_CREND_SIMPLIFY_CODE destroy_crend_hrtf( hHrtfCrend ); #else destroy_SetOfHRTF( hSetOfHRTF ); #endif } } Loading @@ -1006,7 +1027,11 @@ 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 ) { Loading Loading @@ -2047,6 +2072,9 @@ cleanup: RotationFileReader_close( &referenceRotReader ); Vector3PairFileReader_close( &referenceVectorReader ); #ifdef FIX_CREND_SIMPLIFY_CODE destroy_td_hrtf( hHrtfTD ); #else if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL ) { destroy_SetOfHRTF( hSetOfHRTF ); Loading @@ -2055,6 +2083,7 @@ cleanup: { destroy_td_hrtf( hHrtfTD ); } #endif destroy_hrtf_statistics( hHrtfStatistics ); IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); Loading
lib_com/common_api_types.h +20 −0 Original line number Diff line number Diff line Loading @@ -165,11 +165,19 @@ 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; Loading Loading @@ -201,6 +209,18 @@ 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, IVAS_BIN_RENDERER_TYPE_CREND, IVAS_BIN_RENDERER_TYPE_FASTCONV, IVAS_BIN_RENDERER_TYPE_PARAMBIN, IVAS_BIN_RENDERER_TYPE_TDREND, IVAS_BIN_RENDERER_TYPE_DEFAULT, } IVAS_BIN_RENDERER_TYPE; #endif /*----------------------------------------------------------------------------------* * Split rendering API constants, structures, and enums Loading
lib_com/ivas_cnst.h +4 −0 Original line number Diff line number Diff line Loading @@ -1556,6 +1556,10 @@ typedef enum #define MAX_ANGULAR_STEP_INV ( 1.0f / MAX_ANGULAR_STEP ) #define MAX_INTERPOLATION_STEPS 12 #ifdef FIX_CREND_SIMPLIFY_CODE #define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) #define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) #endif /* ----- Enums - TD Renderer ----- */ Loading
lib_com/ivas_error.h +7 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,9 @@ typedef enum IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, IVAS_ERR_INVALID_HRTF, #ifdef FIX_CREND_SIMPLIFY_CODE IVAS_ERR_INVALID_HRTF_SAMPLING_RATE, #endif IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA, IVAS_ERR_INVALID_INPUT_FORMAT, IVAS_ERR_INVALID_INDEX, Loading Loading @@ -256,6 +259,10 @@ 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"; #ifdef FIX_CREND_SIMPLIFY_CODE 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: Loading