Commit 91212866 authored by emerit's avatar emerit
Browse files

tested, switchs USE_NEW_HRTF_BINARY_FILE_FORMAT, FIX_INV_DIFFUSE_WEIGHT,...

tested, switchs USE_NEW_HRTF_BINARY_FILE_FORMAT, FIX_INV_DIFFUSE_WEIGHT, FIX_638_ENERGIE_IAC_ROM_TABLES and  NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
parent 19a67945
Loading
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -735,7 +735,6 @@ int main(
        }

#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
        if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
        {
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
@@ -744,7 +743,6 @@ int main(
                goto cleanup;
            }
        }
#endif
#endif

        if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK )
@@ -832,7 +830,6 @@ int main(


#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -851,12 +848,14 @@ int main(
            }
        }
#else
        if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
        if ( ( hHrtfTD != NULL ) && ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
        {
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                goto cleanup;
            }
#endif
        }
#endif
    }

+0 −4
Original line number Diff line number Diff line
@@ -933,7 +933,6 @@ int main(
            }

#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
            if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
@@ -942,7 +941,6 @@ int main(
                    goto cleanup;
                }
            }
#endif
#endif

            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
@@ -1026,7 +1024,6 @@ int main(
            }

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
            if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" );
@@ -1044,7 +1041,6 @@ int main(
                    destroy_hrtf_statistics( hHrtfStatistics );
                }
            }
#endif
#endif
        }

+5 −4
Original line number Diff line number Diff line
@@ -184,10 +184,11 @@
#define FIX_960_SYN_OUTPUT                              /* VA: issue 960: unused function syn_output() is removed */

#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES       /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers	*/
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format */
/*#define FIX_OLD_BINARY_FORMAT*/                           /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/      
/*#define FIX_OLD_BINARY_FILE*/                             /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/      
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
#define FIX_OLD_BINARY_FORMAT                           /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/      
#endif
//#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES       /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers	*/
//#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format */
#define FIX_WARNING_RENDER_CONFIG                       /* Orange: fix warning on windows build */
#define FIX_INV_DIFFUSE_WEIGHT                          /* Orange : Fix error in energy compensation in late binaural */

+4 −0
Original line number Diff line number Diff line
@@ -38,7 +38,11 @@
#include "wmc_auto.h"
#include "ivas_prot.h"
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#include "ivas_rom_binaural_crend_head.h"
#else
#include "ivas_rom_rend.h"
#endif
#endif

/*-----------------------------------------------------------------------*
+41 −47
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@
#include "ivas_prot.h"
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#include "ivas_rom_binaural_crend_head.h"
#else
#include "ivas_rom_rend.h"
#endif

/*---------------------------------------------------------------------*
@@ -191,7 +193,7 @@ static ivas_error check_hrtf_binary_header(
{
    /* Check the renderer type */

#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) &&
         ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) &&
         ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) &&
@@ -445,7 +447,7 @@ static ivas_error LoadBSplineBinary(
        LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf );
    }

#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifndef USE_NEW_HRTF_BINARY_FILE_FORMAT
    /* left/right energy and interaural coherence for late reverb */
    for ( i = 0; i < 3; i++ )
    {
@@ -462,7 +464,6 @@ static ivas_error LoadBSplineBinary(
    return IVAS_ERR_OK;
}

#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
/*-------------------------------------------------------------------*
 * set_default_reverb_iac_energy()
@@ -501,12 +502,10 @@ static ivas_error set_default_reverb_iac_energy(
#else
            HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
#endif
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
            if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
#endif
        }
        switch ( HrFiltSet_p->SampleRate )
        {
@@ -559,8 +558,6 @@ static ivas_error set_default_reverb_iac_energy(
}
#endif

#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES

/*-------------------------------------------------------------------*
 * load_reverb_from_binary()
 *
@@ -587,9 +584,7 @@ static ivas_error load_reverb_from_binary(
    ivas_hrtfs_header_t hrtf_header;
    int32_t hrtf_data_size_max;
    char *hrtf_data;
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
    int16_t lr_iac_len;

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    if ( hHrtfStatistics == NULL )
#else
@@ -600,6 +595,7 @@ static ivas_error load_reverb_from_binary(
    }

    lr_iac_len = LR_IAC_LENGTH_NR_FC;
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    if ( sampleRate == 16000 )
#else
@@ -647,7 +643,11 @@ static ivas_error load_reverb_from_binary(
            return header_check_result;
        }

#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
        is_reverb = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_REVERB_ALL );
#else
        is_reverb = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_REVERB_ALL );
#endif
        if ( !is_reverb )
        {
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
@@ -682,27 +682,13 @@ static ivas_error load_reverb_from_binary(
        /* left/right energy and interaural coherence for late reverb */
        for ( i = 0; i < 3; i++ )
        {
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
            HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( lr_iac_len * sizeof( float ) );
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
            if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
#endif
            fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), lr_iac_len, f_hrtf );
            HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i];
#else
            HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
            if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
#endif
            fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf );
            HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i];
#endif
        }
#endif
    }
@@ -720,7 +706,6 @@ static ivas_error load_reverb_from_binary(

    return IVAS_ERR_OK;
}
#endif

/*---------------------------------------------------------------------*
 * load_reverb_binary()
@@ -746,7 +731,6 @@ ivas_error load_reverb_binary(
    return load_reverb_from_binary( hHrtf, hrtfReader->file );
#endif
}
#endif

/*-------------------------------------------------------------------*
 * TDREND_MIX_LoadHRTF()
@@ -822,7 +806,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
            return header_check_result;
        }

#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
        is_tdrend = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD );
#else
        is_tdrend = ( hrtf_header.rend_type == RENDERER_BINAURAL_OBJECTS_TD );
@@ -1129,7 +1113,7 @@ static ivas_error create_HRTF_from_rawdata(
    ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) );
    hrtf_data_rptr += sizeof( uint16_t );


#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
#ifdef FIX_INV_DIFFUSE_WEIGHT
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
@@ -1141,6 +1125,23 @@ static ivas_error create_HRTF_from_rawdata(
        ( *hHRTF )->inv_diffuse_weight[1][i] = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );
    }
#else
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        ( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );
    }
    hrtf_data_rptr += sizeof( float ) * ( *hHRTF )->max_num_ir;
#endif
#else
#ifdef FIX_INV_DIFFUSE_WEIGHT
    /* inv_diffuse_weight */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        ( *hHRTF )->inv_diffuse_weight[0][i] = *( (float *) ( hrtf_data_rptr ) );
        ( *hHRTF )->inv_diffuse_weight[1][i] = ( *hHRTF )->inv_diffuse_weight[0][i];
        hrtf_data_rptr += sizeof( float );
    }
#else
    /* inv_diffuse_weight */
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
@@ -1149,6 +1150,7 @@ static ivas_error create_HRTF_from_rawdata(
        hrtf_data_rptr += sizeof( float );
    }
#endif
#endif

#ifdef FIX_OLD_BINARY_FORMAT
#ifdef FIX_INV_DIFFUSE_WEIGHT
@@ -1270,7 +1272,7 @@ static ivas_error create_HRTF_from_rawdata(
static ivas_error create_fastconv_HRTF_from_rawdata(
    HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle    */
    char *hrtf_data,              /* i  : pointer to binary file  */
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    HRTF_READER_RENDERER_TYPE rend_type, /* i  : Renderer type           */
#else
    RENDERER_TYPE rend_type, /* i  : Renderer type           */
@@ -1280,13 +1282,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
{
    int16_t i, j;
    char *hrtf_data_rptr;
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    ivas_error error;
#endif

    ( *hHRTF )->allocate_init_flag = 0;

#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV )
    {
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
@@ -1321,7 +1323,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif

/* HRIR */
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#else
    if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
@@ -1383,7 +1385,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 )
#else
    else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 )
@@ -1445,7 +1447,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 )
#else
    else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 )
@@ -1508,7 +1510,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA )
#else
    else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA )
@@ -1573,7 +1575,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
        }
    }
/* BRIR */
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#else
    else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
@@ -1642,18 +1644,10 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
        }
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_OLD_BINARY_FILE // old binary file contains wrong value use default one instead
        extern const Word32 fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX];
        memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) );
        hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );
        memcpy( ( *hHRTF )->fastconvReverberationTimes, fastconvReverberationTimes, CLDFB_NO_CHANNELS_MAX * sizeof( float ) );
        hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );
#else
        memcpy( ( *hHRTF )->fastconvReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) );
        hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );
        memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) );
        hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );
#endif
    }

    return IVAS_ERR_OK;
@@ -1710,7 +1704,7 @@ ivas_error load_fastconv_HRTF_from_binary(
            free( hrtf_data );
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" );
        }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) )
#else
        if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) )
@@ -1872,7 +1866,7 @@ ivas_error load_parambin_HRTF_from_binary(
        }


#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */
#else
        if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */
@@ -1966,7 +1960,7 @@ ivas_error create_SetOfHRTF_from_binary(
        hHRTF = NULL;
        if ( hrtf_header.frequency == output_Fs )
        {
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
            if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV )
#else
            if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV )
@@ -1989,7 +1983,7 @@ ivas_error create_SetOfHRTF_from_binary(
                    hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_foa );
                }
            }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
            else if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM )
#else
            else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )