Commit 2bd3b09c authored by vaclav's avatar vaclav
Browse files

add 'const' to HRTF coefficients tables

parent 37bf3e82
Loading
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -145,8 +145,8 @@ static void ivas_hrtf_close(
{
#ifdef FIX_1123_CREND_16BIT_ROM
    int16_t i, j;
#endif

#endif
    if ( hHrtf == NULL || *hHrtf == NULL )
    {
        return;
@@ -182,8 +182,8 @@ static void ivas_hrtf_close(
            }
        }
    }
#endif

#endif
    free( *hHrtf );
    *hHrtf = NULL;

@@ -191,7 +191,7 @@ static void ivas_hrtf_close(
}

/*-------------------------------------------------------------------------
 * initCrend_from_rom()
 * ivas_rend_initCrend()
 *
 * Allocate and initialize crend renderer handle
 *------------------------------------------------------------------------*/
@@ -1971,7 +1971,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
@@ -2088,10 +2088,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.

+9 −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;
@@ -1316,9 +1316,9 @@ 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;
    int16_t fromROM; /*  Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/
} HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE;

+27 −23
Original line number Diff line number Diff line
@@ -924,6 +924,7 @@ static ivas_error load_reverb_from_binary(
    Word16 factorQ;
    Word16 tmp16;
    float factorQ_f;
    float average_energy;
#endif

    if ( hHrtfStatistics == NULL || f_hrtf == NULL )
@@ -1004,17 +1005,20 @@ static ivas_error load_reverb_from_binary(
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->average_energy_l[ind] = factorQ_f * tmp16;
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->average_energy_l[ind], &average_energy, sizeof( float ) );
        }
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->average_energy_r[ind] = factorQ_f * tmp16;
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->average_energy_r[ind], &average_energy, sizeof( float ) );
        }
        for ( ind = 0; ind < lr_iac_len; ind++ )
        {
            fread( &tmp16, sizeof( Word16 ), 1, f_hrtf );
            hHrtfStatistics->inter_aural_coherence[ind] = factorQ_f * tmp16;
            average_energy = factorQ_f * tmp16;
            memcpy( (float *) &hHrtfStatistics->inter_aural_coherence[ind], &average_energy, sizeof( float ) );
        }
#else
        fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf );
@@ -1661,7 +1665,7 @@ static ivas_error create_HRTF_from_rawdata(
            {
                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 );
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1684,11 +1688,11 @@ static ivas_error create_HRTF_from_rawdata(
        {
            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 )
            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 );
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1731,9 +1735,9 @@ static ivas_error create_HRTF_from_rawdata(
            {
                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];

            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
@@ -1765,9 +1769,9 @@ static ivas_error create_HRTF_from_rawdata(
            {
                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];
            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
#ifdef FIX_1123_CREND_16BIT_FMT
@@ -1804,9 +1808,9 @@ static ivas_error create_HRTF_from_rawdata(
            {
                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];

            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
@@ -1835,9 +1839,9 @@ static ivas_error create_HRTF_from_rawdata(
            {
                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];
            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
#ifdef FIX_1123_CREND_16BIT_FMT
@@ -3703,15 +3707,15 @@ static void destroy_HRTF(
            {
                if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL )
                {
                    free( ( *hHRTF )->pIndex_frequency_max[i][j] );
                    free( (float *) ( *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] );
                }
            }
        }
@@ -3719,15 +3723,15 @@ static void destroy_HRTF(
        {
            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( (uint16_t *) ( *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( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j] );
            }
        }

@@ -3812,9 +3816,9 @@ void destroy_hrtf_statistics(
{
    if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) )
    {
        free( ( *hHrtfStatistics )->average_energy_l );
        free( ( *hHrtfStatistics )->average_energy_r );
        free( ( *hHrtfStatistics )->inter_aural_coherence );
        free( (float *) ( *hHrtfStatistics )->average_energy_l );
        free( (float *) ( *hHrtfStatistics )->average_energy_r );
        free( (float *) ( *hHrtfStatistics )->inter_aural_coherence );
    }

    ivas_HRTF_statistics_close( hHrtfStatistics );