Commit d30fd051 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

HRTF statistics handling update

parent b7bfe2da
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2190,7 +2190,7 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle(

ivas_error IVAS_DEC_GetHrtfStatisticsHandle(
    IVAS_DEC_HANDLE hIvasDec,                         /* i/o: IVAS decoder handle       */
    IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o  : Parametric binauralizer HRTF handle */
    IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o  : HRTF statistics handle    */
)
{
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL )
+0 −2
Original line number Diff line number Diff line
@@ -256,7 +256,6 @@ ivas_error ivas_HRTF_statistics_binary_open(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" );
    }

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    ( *hHrtfStatistics )->average_energy_l = NULL;
    ( *hHrtfStatistics )->average_energy_r = NULL;
    ( *hHrtfStatistics )->inter_aural_coherence = NULL;
@@ -280,7 +279,6 @@ ivas_error ivas_HRTF_statistics_binary_open(
            break;
    }
    ( *hHrtfStatistics )->fromROM = TRUE;
#endif

    return IVAS_ERR_OK;
}
+3 −3
Original line number Diff line number Diff line
@@ -1358,9 +1358,9 @@ typedef struct ivas_hrtfs_parambin_struct
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
typedef struct ivas_hrtfs_statistics_struct
{
    const float *average_energy_l;
    const float *average_energy_r;
    const float *inter_aural_coherence;
    float *average_energy_l;
    float *average_energy_r;
    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;
#endif
+30 −15
Original line number Diff line number Diff line
@@ -591,10 +591,6 @@ static ivas_error load_reverb_from_binary(
    int16_t lr_iac_len;

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    float *average_energy_l_dyn;
    float *average_energy_r_dyn;
    float *inter_aural_coherence_dyn;

    if ( hHrtfStatistics == NULL )
#else
    if ( HrFiltSet_p == NULL )
@@ -665,20 +661,18 @@ static ivas_error load_reverb_from_binary(
    if ( is_reverb )
    {
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        average_energy_l_dyn = (float *) malloc( lr_iac_len * sizeof( float ) );
        average_energy_r_dyn = (float *) malloc( lr_iac_len * sizeof( float ) );
        inter_aural_coherence_dyn = (float *) malloc( lr_iac_len * sizeof( float ) );
        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 ( average_energy_l_dyn == NULL || average_energy_r_dyn == NULL || inter_aural_coherence_dyn == NULL )
        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" );
        }
        fread( average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        fread( average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        fread( inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        hHrtfStatistics->average_energy_l = (const float *) average_energy_l_dyn;
        hHrtfStatistics->average_energy_r = (const float *) average_energy_r_dyn;
        hHrtfStatistics->inter_aural_coherence = (const float *) inter_aural_coherence_dyn;
        fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf );
        fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf );
        fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf );

        hHrtfStatistics->fromROM = FALSE;
#else
        /* left/right energy and interaural coherence for late reverb */
@@ -2249,4 +2243,25 @@ ivas_error destroy_parambin_hrtf(
    return IVAS_ERR_OK;
}

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
/*---------------------------------------------------------------------*
 * destroy_hrtf_statistics()
 *
 * Destroy the HRTF statistics set.
 *---------------------------------------------------------------------*/

ivas_error destroy_hrtf_statistics(
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle  */
)
{
    if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == TRUE )
    {
        free( ( *hHrtfStatistics )->average_energy_l );
        free( ( *hHrtfStatistics )->average_energy_r );
        free( ( *hHrtfStatistics )->inter_aural_coherence );
    }
    return IVAS_ERR_OK;
}
#endif

#endif
+11 −0
Original line number Diff line number Diff line
@@ -198,6 +198,17 @@ ivas_error destroy_parambin_hrtf(
ivas_error destroy_td_hrtf(
    IVAS_DEC_HRTF_HANDLE *hHRTF /* i/o: HRTF handle */
);

/*---------------------------------------------------------------------*
 * destroy_hrtf_statistics()
 *
 * free memory allocated for HRTF statistics binary data
 *---------------------------------------------------------------------*/

ivas_error destroy_hrtf_statistics(
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle  */
);

#else
/*---------------------------------------------------------------------*
 * dealloc_HRTF_binary()
+2 −2

File changed.

Contains only whitespace changes.

Loading