Commit 9d74510e authored by emerit's avatar emerit
Browse files

Merge branch '1150-hrtf-rom-tables-should-be-defined-as-const' into 'main'

Resolve "HRTF ROM tables should be defined as 'const'"

See merge request !1741
parents 9d077975 9879bb9b
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@

#define FIX_POINT_HRTF_FILE_FORMAT                     /* All: fix point hrtf binary file format */
#ifdef FIX_POINT_HRTF_FILE_FORMAT
#define FIX_POINT_ROM_CONST                             /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/
#define FIX_1123_CREND_16BIT_FMT                        /* Ora: update CREND binary file format to 16 bit */
#define FIX_1123_CREND_FLTFX_BE                         /* Ora: make CREND FLT ROM tables BE to FX file */
#define FIX_1123_FASTCONV_16BIT_FMT                     /* FhG: issue 1123: update FastConv binary file format and scripts to 16 bit */
+3 −8
Original line number Diff line number Diff line
@@ -143,13 +143,11 @@ static void ivas_hrtf_close(
    HRTFS_HANDLE *hHrtf /* i/o: HRTF handle         */
)
{

    if ( hHrtf == NULL || *hHrtf == NULL )
    {
        return;
    }


    free( *hHrtf );
    *hHrtf = NULL;

@@ -157,7 +155,7 @@ static void ivas_hrtf_close(
}

/*-------------------------------------------------------------------------
 * initCrend_from_rom()
 * ivas_rend_initCrend()
 *
 * Allocate and initialize crend renderer handle
 *------------------------------------------------------------------------*/
@@ -1569,7 +1567,7 @@ static ivas_error ivas_rend_crendConvolver(
    int16_t nchan_in, nchan_out;
    const float *pIn;
#ifdef FIX_CREND_SIMPLIFY_CODE
    float *pFreq_filt_re, *pFreq_filt_im;
    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;
#else
@@ -1686,10 +1684,7 @@ static ivas_error ivas_rend_crendConvolver(
            }

#ifdef FIX_CREND_SIMPLIFY_CODE
            pFreq_filt_re = &hCrend->freq_buffer_re[i][offset];
            pFreq_filt_im = &hCrend->freq_buffer_im[i][offset];

            ivas_mdft( pIn, pFreq_filt_re, pFreq_filt_im, subframe_length, subframe_length );
            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];
+178 −176

File changed.

Preview size limit exceeded, changes collapsed.

+22 −9
Original line number Diff line number Diff line
@@ -1159,15 +1159,15 @@ typedef struct

typedef struct ivas_hrtfs_structure
{
    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];
    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];
    float latency_s;
    uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
    uint16_t num_iterations_diffuse[BINAURAL_CHANNELS];
    uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
    uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];
    const uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
    const uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];
    uint16_t index_frequency_max_diffuse;
    int16_t max_num_ir;
    int16_t max_num_iterations;
@@ -1175,6 +1175,14 @@ 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_POINT_ROM_CONST
    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];
    float *pOut_to_bin_diffuse_im_dyn[BINAURAL_CHANNELS];
    uint16_t *pIndex_frequency_max_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
    uint16_t *pIndex_frequency_max_diffuse_dyn[BINAURAL_CHANNELS];
#endif
} HRTFS_DATA, *HRTFS_HANDLE;


@@ -1303,9 +1311,14 @@ typedef struct ivas_hrtfs_fastconv_struct

typedef struct ivas_hrtfs_statistics_struct
{
    float *average_energy_l;
    float *average_energy_r;
    float *inter_aural_coherence;
    const float *average_energy_l;
    const float *average_energy_r;
    const float *inter_aural_coherence;
#ifdef FIX_POINT_ROM_CONST
    float *average_energy_l_dyn;
    float *average_energy_r_dyn;
    float *inter_aural_coherence_dyn;
#endif
    int16_t fromROM; /*  Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/
} HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE;

+168 −24
Original line number Diff line number Diff line
@@ -924,6 +924,9 @@ static ivas_error load_reverb_from_binary(
    Word16 factorQ;
    Word16 tmp16;
    float factorQ_f;
#ifndef FIX_POINT_ROM_CONST
    float average_energy;
#endif
#endif

    if ( hHrtfStatistics == NULL || f_hrtf == NULL )
@@ -989,6 +992,19 @@ static ivas_error load_reverb_from_binary(

    if ( is_reverb )
    {
#ifdef FIX_POINT_ROM_CONST
        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 ) );

        if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL )
        {
            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;
#else
        hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) );
        hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) );
        hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) );
@@ -997,24 +1013,39 @@ static ivas_error load_reverb_from_binary(
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
        }

#endif
#ifdef FIX_POINT_HRTF_FILE_FORMAT
        fread( &factorQ, sizeof( Word16 ), 1, f_hrtf );
        factorQ_f = powf( 2.f, -1.f * factorQ );
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->average_energy_l[ind] = factorQ_f * tmp16;
#ifdef FIX_POINT_ROM_CONST
            hHrtfStatistics->average_energy_l_dyn[ind] = factorQ_f * tmp16;
#else
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->average_energy_l[ind], &average_energy, sizeof( float ) );
#endif
        }
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->average_energy_r[ind] = factorQ_f * tmp16;
#ifdef FIX_POINT_ROM_CONST
            hHrtfStatistics->average_energy_r_dyn[ind] = factorQ_f * tmp16;
#else
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->average_energy_r[ind], &average_energy, sizeof( float ) );
#endif
        }
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->inter_aural_coherence[ind] = factorQ_f * tmp16;
#ifdef FIX_POINT_ROM_CONST
            hHrtfStatistics->inter_aural_coherence_dyn[ind] = factorQ_f * tmp16;
#else
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->inter_aural_coherence[ind], &average_energy, sizeof( float ) );
#endif
        }
#else
        fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf );
@@ -1656,12 +1687,22 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pIndex_frequency_max_dyn[i][j] = (uint16_t *) malloc( mem_size );
            if ( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" );
            }
            memcpy( ( *hHRTF )->pIndex_frequency_max_dyn[i][j], hrtf_data_rptr, mem_size );
            ( *hHRTF )->pIndex_frequency_max[i][j] = ( *hHRTF )->pIndex_frequency_max_dyn[i][j];
#else
            ( *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 );
            memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size );
#endif
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1683,12 +1724,22 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] = (uint16_t *) malloc( mem_size );
            if ( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" );
            }
            memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j], hrtf_data_rptr, mem_size );
            ( *hHRTF )->pIndex_frequency_max_diffuse[j] = ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j];
#else
            ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size );
            if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL )
            if ( (uint16_t *) ( *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 );
            memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size );
#endif
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1726,14 +1777,25 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration * sizeof( float );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pOut_to_bin_re_dyn[i][j] = (float *) malloc( mem_size );
            if ( ( *hHRTF )->pOut_to_bin_re_dyn[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_dyn[i][j], 0x00, mem_size );
            ( *hHRTF )->pOut_to_bin_re[i][j] = ( *hHRTF )->pOut_to_bin_re_dyn[i][j];
            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re_dyn[i][j];
#else
            ( *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 );
            memset( (float *) ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size );

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re[i][j];
            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_re[i][j];
#endif

            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
@@ -1760,14 +1822,26 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration * sizeof( float );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pOut_to_bin_im_dyn[i][j] = (float *) malloc( mem_size );
            if ( ( *hHRTF )->pOut_to_bin_im_dyn[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_dyn[i][j], 0x00, mem_size );
            ( *hHRTF )->pOut_to_bin_im[i][j] = ( *hHRTF )->pOut_to_bin_im_dyn[i][j];

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im_dyn[i][j];
#else
            ( *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 );
            memset( (float *) ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size );

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im[i][j];
            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_im[i][j];
#endif
            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
#ifdef FIX_1123_CREND_16BIT_FMT
@@ -1799,14 +1873,26 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] = (float *) malloc( mem_size );
            if ( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[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_dyn[j], 0x00, mem_size );
            ( *hHRTF )->pOut_to_bin_diffuse_re[j] = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j];

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j];
#else
            ( *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 );
            memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size );

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re[j];
            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j];
#endif

            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
@@ -1830,14 +1916,26 @@ static ivas_error create_HRTF_from_rawdata(
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
#ifdef FIX_POINT_ROM_CONST
            ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] = (float *) malloc( mem_size );
            if ( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[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_dyn[j], 0x00, mem_size );
            ( *hHRTF )->pOut_to_bin_diffuse_im[j] = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j];

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j];
#else
            ( *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 );
            memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size );

            pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im[j];
            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j];
#endif
            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
#ifdef FIX_1123_CREND_16BIT_FMT
@@ -3584,34 +3682,64 @@ static void destroy_HRTF(
        {
            for ( j = 0; j < BINAURAL_CHANNELS; j++ )
            {
#ifdef FIX_POINT_ROM_CONST
                if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL )
                {
                    free( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL )
                {
                    free( ( *hHRTF )->pOut_to_bin_re_dyn[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL )
                {
                    free( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] );
                }
#else
                if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL )
                {
                    free( ( *hHRTF )->pIndex_frequency_max[i][j] );
                    free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL )
                {
                    free( ( *hHRTF )->pOut_to_bin_re[i][j] );
                    free( (float *) ( *hHRTF )->pOut_to_bin_re[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL )
                {
                    free( ( *hHRTF )->pOut_to_bin_im[i][j] );
                    free( (float *) ( *hHRTF )->pOut_to_bin_im[i][j] );
                }
#endif
            }
        }
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
#ifdef FIX_POINT_ROM_CONST
            if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL )
            {
                free( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] );
            }
            if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL )
            {
                free( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] );
            }
            if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL )
            {
                free( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] );
            }
#else
            if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL )
            {
                free( ( *hHRTF )->pIndex_frequency_max_diffuse[j] );
                free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] );
            }
            if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL )
            {
                free( ( *hHRTF )->pOut_to_bin_diffuse_re[j] );
                free( (float *) ( *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( (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j] );
            }
#endif
        }

        free( *hHRTF );
@@ -3693,11 +3821,27 @@ void destroy_hrtf_statistics(
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle  */
)
{

    if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) )
    {
        free( ( *hHrtfStatistics )->average_energy_l );
        free( ( *hHrtfStatistics )->average_energy_r );
        free( ( *hHrtfStatistics )->inter_aural_coherence );
#ifdef FIX_POINT_ROM_CONST
        if ( ( *hHrtfStatistics )->average_energy_l != NULL )
        {
            free( ( *hHrtfStatistics )->average_energy_l_dyn );
        }
        if ( ( *hHrtfStatistics )->average_energy_r != NULL )
        {
            free( ( *hHrtfStatistics )->average_energy_r_dyn );
        }
        if ( ( *hHrtfStatistics )->inter_aural_coherence != NULL )
        {
            free( ( *hHrtfStatistics )->inter_aural_coherence_dyn );
        }
#else
        free( (float *) ( *hHrtfStatistics )->average_energy_l );
        free( (float *) ( *hHrtfStatistics )->average_energy_r );
        free( (float *) ( *hHrtfStatistics )->inter_aural_coherence );
#endif
    }

    ivas_HRTF_statistics_close( hHrtfStatistics );
Loading