Commit cf168393 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_POINT_ROM_CONST

parent ee4d2d3a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -169,7 +169,6 @@

#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */

#define FIX_POINT_ROM_CONST                             /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/
#define FIX_1158_FASTCONV_REVERB_HRTF                   /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */

/* #################### End BE switches ################################## */
+0 −4
Original line number Diff line number Diff line
@@ -1175,14 +1175,12 @@ 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;


@@ -1307,11 +1305,9 @@ typedef struct ivas_hrtfs_statistics_struct
    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;

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

    if ( hHrtfStatistics == NULL || f_hrtf == NULL )
    {
@@ -773,7 +770,6 @@ 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 ) );
@@ -785,47 +781,22 @@ static ivas_error load_reverb_from_binary(
        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 ) );

        if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
        }
#endif
        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 );
#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 );
#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 );
#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
        }

        hHrtfStatistics->fromROM = FALSE;
@@ -1156,7 +1127,6 @@ 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 )
            {
@@ -1164,14 +1134,6 @@ static ivas_error create_HRTF_from_rawdata(
            }
            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( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size );
#endif
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1193,7 +1155,6 @@ 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 )
            {
@@ -1201,14 +1162,6 @@ static ivas_error create_HRTF_from_rawdata(
            }
            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 ( (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( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size );
#endif
            hrtf_data_rptr += mem_size;
        }
    }
@@ -1246,7 +1199,6 @@ 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 )
            {
@@ -1255,16 +1207,6 @@ static ivas_error create_HRTF_from_rawdata(
            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( (float *) ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size );

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

            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
@@ -1286,7 +1228,6 @@ 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 )
            {
@@ -1296,16 +1237,6 @@ static ivas_error create_HRTF_from_rawdata(
            ( *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( (float *) ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size );

            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_im[i][j];
#endif
            for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ )
            {
                mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t );
@@ -1332,7 +1263,6 @@ 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 )
            {
@@ -1342,16 +1272,6 @@ static ivas_error create_HRTF_from_rawdata(
            ( *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( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size );

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

            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
@@ -1370,7 +1290,6 @@ 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 )
            {
@@ -1380,16 +1299,6 @@ static ivas_error create_HRTF_from_rawdata(
            ( *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( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size );

            pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j];
#endif
            for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ )
            {
                mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t );
@@ -2280,7 +2189,6 @@ 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] );
@@ -2293,25 +2201,10 @@ static void destroy_HRTF(
                {
                    free( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] );
                }
#else
                if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL )
                {
                    free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL )
                {
                    free( (float *) ( *hHRTF )->pOut_to_bin_re[i][j] );
                }
                if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL )
                {
                    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] );
@@ -2324,20 +2217,6 @@ static void destroy_HRTF(
            {
                free( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] );
            }
#else
            if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL )
            {
                free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] );
            }
            if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL )
            {
                free( (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j] );
            }
            if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL )
            {
                free( (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j] );
            }
#endif
        }

        free( *hHRTF );
@@ -2422,7 +2301,6 @@ void destroy_hrtf_statistics(

    if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) )
    {
#ifdef FIX_POINT_ROM_CONST
        if ( ( *hHrtfStatistics )->average_energy_l != NULL )
        {
            free( ( *hHrtfStatistics )->average_energy_l_dyn );
@@ -2435,11 +2313,6 @@ void destroy_hrtf_statistics(
        {
            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 );