Loading lib_util/hrtf_file_reader.c +252 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include "hrtf_file_reader.h" #include <string.h> #include <math.h> #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" Loading Loading @@ -1047,6 +1048,256 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * create_HRTF_from_rawdata_fx() * * Create HRTF from the raw data (to the HRTF CRend handle) *---------------------------------------------------------------------*/ static ivas_error create_HRTF_from_rawdata_fx( HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ char *hrtf_data /* i : pointer to binary file */ ) { 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, l; char *hrtf_data_rptr; float *pOut_to_bin_wptr; ivas_error error; 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" ); } if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) { return error; } } else { return IVAS_ERR_INTERNAL; } ( *hHRTF )->init_from_rom = 0; hrtf_data_rptr = hrtf_data; /* latency_s */ ( *hHRTF )->latency_s = (float) ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -31.f ); hrtf_data_rptr += sizeof( Word32 ); /* max_num_ir */ ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); /* BINAURAL_CHANNELS */ if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) { 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 ); /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[0][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -15.f ); hrtf_data_rptr += sizeof( Word16 ); } for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[1][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -15.f ); hrtf_data_rptr += sizeof( Word16 ); } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_re[i][j][l]; ( *hHRTF )->pOut_to_bin_re[i][j][l] = ptW[0] * powf( 2.f, -29.f ); } } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_im[i][j][l]; ( *hHRTF )->pOut_to_bin_im[i][j][l] = ptW[0] * powf( 2.f, -29.f ); } } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_diffuse_re[j][l]; ( *hHRTF )->pOut_to_bin_diffuse_re[j][l] = ptW[0] * powf( 2.f, -29.f ); } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_diffuse_im[j][l]; ( *hHRTF )->pOut_to_bin_diffuse_im[j][l] = ptW[0] * powf( 2.f, -29.f ); } } } return IVAS_ERR_OK; } static ivas_error create_fastconv_HRTF_from_rawdata( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ Loading Loading @@ -1627,7 +1878,6 @@ ivas_error load_parambin_HRTF_from_binary( } } /*---------------------------------------------------------------------* * create_SetOfHRTF_from_binary() * Loading Loading @@ -1722,7 +1972,7 @@ ivas_error create_SetOfHRTF_from_binary( 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 ) if ( ( create_HRTF_from_rawdata_fx( hHRTF, hrtf_data ) ) != IVAS_ERR_OK ) { free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); Loading scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +9 −5 Original line number Diff line number Diff line Loading @@ -2740,7 +2740,11 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr } hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT hrtf_data_size += hrtf->max_num_ir * sizeof( Word16 ) * BINAURAL_CHANNELS; // inv_diffuse_weight #else hrtf_data_size += hrtf->max_num_ir * sizeof( float ) * BINAURAL_CHANNELS; // inv_diffuse_weight #endif hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration Loading Loading @@ -2967,7 +2971,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -2997,7 +3001,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -3031,7 +3035,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -3059,7 +3063,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading
lib_util/hrtf_file_reader.c +252 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include "hrtf_file_reader.h" #include <string.h> #include <math.h> #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" Loading Loading @@ -1047,6 +1048,256 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * create_HRTF_from_rawdata_fx() * * Create HRTF from the raw data (to the HRTF CRend handle) *---------------------------------------------------------------------*/ static ivas_error create_HRTF_from_rawdata_fx( HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ char *hrtf_data /* i : pointer to binary file */ ) { 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, l; char *hrtf_data_rptr; float *pOut_to_bin_wptr; ivas_error error; 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" ); } if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) { return error; } } else { return IVAS_ERR_INTERNAL; } ( *hHRTF )->init_from_rom = 0; hrtf_data_rptr = hrtf_data; /* latency_s */ ( *hHRTF )->latency_s = (float) ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -31.f ); hrtf_data_rptr += sizeof( Word32 ); /* max_num_ir */ ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); /* BINAURAL_CHANNELS */ if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) { 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 ); /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[0][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -15.f ); hrtf_data_rptr += sizeof( Word16 ); } for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[1][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -15.f ); hrtf_data_rptr += sizeof( Word16 ); } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_re[i][j][l]; ( *hHRTF )->pOut_to_bin_re[i][j][l] = ptW[0] * powf( 2.f, -29.f ); } } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_im[i][j][l]; ( *hHRTF )->pOut_to_bin_im[i][j][l] = ptW[0] * powf( 2.f, -29.f ); } } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_diffuse_re[j][l]; ( *hHRTF )->pOut_to_bin_diffuse_re[j][l] = ptW[0] * powf( 2.f, -29.f ); } } /* 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]; } for ( l = 0; l < mem_size; l++ ) { Word32 *ptW = (Word32 *) &( *hHRTF )->pOut_to_bin_diffuse_im[j][l]; ( *hHRTF )->pOut_to_bin_diffuse_im[j][l] = ptW[0] * powf( 2.f, -29.f ); } } } return IVAS_ERR_OK; } static ivas_error create_fastconv_HRTF_from_rawdata( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ Loading Loading @@ -1627,7 +1878,6 @@ ivas_error load_parambin_HRTF_from_binary( } } /*---------------------------------------------------------------------* * create_SetOfHRTF_from_binary() * Loading Loading @@ -1722,7 +1972,7 @@ ivas_error create_SetOfHRTF_from_binary( 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 ) if ( ( create_HRTF_from_rawdata_fx( hHRTF, hrtf_data ) ) != IVAS_ERR_OK ) { free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); Loading
scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file
scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file
scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin LFS (132 B) File changed.No diff preview for this file type. View original file View changed file
scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +9 −5 Original line number Diff line number Diff line Loading @@ -2740,7 +2740,11 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr } hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT hrtf_data_size += hrtf->max_num_ir * sizeof( Word16 ) * BINAURAL_CHANNELS; // inv_diffuse_weight #else hrtf_data_size += hrtf->max_num_ir * sizeof( float ) * BINAURAL_CHANNELS; // inv_diffuse_weight #endif hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration Loading Loading @@ -2967,7 +2971,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -2997,7 +3001,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -3031,7 +3035,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading Loading @@ -3059,7 +3063,7 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const { #ifdef FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT Word32 val = float2Word32( coeff_rptr[iTap], 29 ); memcpy( &( (Word32 *) hrtf_bin_wptr )[iIR], &val, sizeof( Word32 ) ); // latency_s memcpy( &( (Word32 *) hrtf_bin_wptr )[iTap], &val, sizeof( Word32 ) ); #else //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); Loading