Commit 5873222d authored by lefort's avatar lefort
Browse files

Compilation issue on Linux fixed.

parent 6fabec96
Loading
Loading
Loading
Loading
+58 −106
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ void hrtfFileReader_close(

#ifdef HRTF_BINARY_FILE

#ifndef HRTF_BINARY_FILE_NO_HEADER
/*-------------------------------------------------------------------*
 * read_and_check_hrtf_binary_file_header()
 *
@@ -159,7 +158,6 @@ static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header

    return IVAS_ERR_OK;
}
#endif


/*-------------------------------------------------------------------*
@@ -429,13 +427,13 @@ static ivas_error TDREND_MIX_LoadHRTF(

#ifdef HRTF_BINARY_FILE

    fpos_t f_pos, f_pos_tdrend;
    bool is_tdrend;
    ivas_error header_check_result;

#ifndef HRTF_BINARY_FILE_NO_HEADER
    ivas_hrtfs_file_header_t hrtfs_file_header;
    int16_t hrtf_id;
#endif
    ivas_hrtfs_header_t hrtf_header;
    int32_t hrtf_data_size_max;
    char *hrtf_data;

#endif

@@ -443,55 +441,55 @@ static ivas_error TDREND_MIX_LoadHRTF(

#ifdef HRTF_BINARY_FILE

#ifndef HRTF_BINARY_FILE_NO_HEADER

    if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK )
    {
        return header_check_result;
    }

#endif
    is_tdrend = FALSE;
    hrtf_data_size_max = hrtfs_file_header.max_data_size;

	ivas_hrtfs_header_t hrtf_header;
    /* Allocate the memory */

    if ( hrtf_data_size_max == 0 )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (hrtf_data_size_max)" );
    }

    f_pos_tdrend = 0;
    hrtf_data = (char *) count_malloc( hrtf_data_size_max );
    if ( hrtf_data == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
    }

#ifndef HRTF_BINARY_FILE_NO_HEADER
    for ( hrtf_id = 0; ( hrtf_id < hrtfs_file_header.nb_hrtf ) && ( f_pos_tdrend == 0 ); hrtf_id++ )
    for ( hrtf_id = 0; ( hrtf_id < hrtfs_file_header.nb_hrtf ) && ( !is_tdrend ); hrtf_id++ )
    {
        if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "HRTF binary file not compliant (number of HRTF)" );
        }
#else
    while ( ( f_pos_tdrend == 0 ) && ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) == IVAS_ERR_OK ) )
    {
#endif

        if ( ( header_check_result = check_hrtf_binary_header( &hrtf_header ) ) != IVAS_ERR_OK )
        {
            return header_check_result;
        }

        // Get the position in file & jump or read
        fgetpos( f_hrtf, &f_pos );
        if ( hrtf_header.rend_type == RENDERER_BINAURAL_OBJECTS_TD )
        is_tdrend = ( hrtf_header.rend_type == RENDERER_BINAURAL_OBJECTS_TD );
        if ( !is_tdrend )
        {
            f_pos_tdrend = f_pos;
        }
        else
        {
            f_pos += hrtf_header.data_size;
            if ( fsetpos( f_hrtf, &f_pos ) != 0 )
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (data size)" );
                return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
            }
		}
    }

    if ( f_pos_tdrend != 0 )
	count_free( hrtf_data );

    if ( is_tdrend )
#endif
    {
    if ( fread( &tmp, sizeof( int16_t ), 1, f_hrtf ) == 0 )
        if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
        }
@@ -835,22 +833,16 @@ ivas_error create_SetOfHRTF_from_binary(
    int32_t output_Fs )               /* i: Output sampling frequency */
{
    FILE *f_hrtf;
    fpos_t f_pos;
    int32_t hrtf_data_size_max;
    char *hrtf_data;
    ivas_hrtfs_header_t hrtf_header;
    HRTFS_DATA **hHRTF;
    ivas_error header_check_result;

#ifndef HRTF_BINARY_FILE_NO_HEADER
    ivas_hrtfs_file_header_t hrtfs_file_header;
    int16_t hrtf_id;
#endif

    f_hrtf = hrtfReader->file;

#ifndef HRTF_BINARY_FILE_NO_HEADER

    if ( ( header_check_result = read_and_check_hrtf_binary_file_header( &hrtfs_file_header, f_hrtf ) ) != IVAS_ERR_OK )
    {
        return header_check_result;
@@ -858,39 +850,6 @@ ivas_error create_SetOfHRTF_from_binary(

    hrtf_data_size_max = hrtfs_file_header.max_data_size;

#else

    fseek( f_hrtf, 0, SEEK_SET );

    /* Get the max data size & allocate the memory */

    hrtf_data_size_max = 0;
    while ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) == IVAS_ERR_OK )
    {
        if ( ( header_check_result = check_hrtf_binary_header( &hrtf_header ) ) != IVAS_ERR_OK )
        {
            return header_check_result;
        }

        // Get the hrtf data size
        if ( hrtf_data_size_max < hrtf_header.data_size )
        {
            hrtf_data_size_max = hrtf_header.data_size;
        }

        // Jump the raw data to reach the next header
        fgetpos( f_hrtf, &f_pos );
        f_pos += hrtf_header.data_size;
        if ( fsetpos( f_hrtf, &f_pos ) != 0 )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF section in binary file not compliant (data size)" );
        }
    }

    fseek( f_hrtf, 0, SEEK_SET );

#endif

    /* Allocate the memory */

    if ( hrtf_data_size_max == 0 )
@@ -908,17 +867,13 @@ ivas_error create_SetOfHRTF_from_binary(

    memset( hSetOfHRTF, 0x00, sizeof( HRTFS_CREND ) );

#ifndef HRTF_BINARY_FILE_NO_HEADER
    for ( hrtf_id = 0; hrtf_id < hrtfs_file_header.nb_hrtf; hrtf_id++ )
    {
        if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" );
        }
#else
    while ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) == IVAS_ERR_OK )
    {
#endif

        hHRTF = NULL;
        if ( hrtf_header.frequency == output_Fs )
        {
@@ -942,22 +897,19 @@ ivas_error create_SetOfHRTF_from_binary(
            }
        }

        if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
        }

        if ( hHRTF != NULL )
        {
            // Create the HRTF reading the raw data from the binary file
            fread( hrtf_data, hrtf_header.data_size, 1, f_hrtf );
            if ( ( create_HRTF_from_rawdata( hHRTF, hrtf_data ) ) != IVAS_ERR_OK )
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" );
            }
        }
        else
        {
            // Jump the useless data
            fgetpos( f_hrtf, &f_pos );
            f_pos += hrtf_header.data_size;
            fsetpos( f_hrtf, &f_pos );
        }
    }

    count_free( hrtf_data );
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in

void usage_tables_format_converter( void )
{
    fprintf( stdout, "Usage:  tables_format_converter [Options] input_file_path \n\n" );
    fprintf( stdout, "Usage:  tables_format_converter [Options]\n\n" );

    fprintf( stdout, "Mandatory parameters : \n" );
    fprintf( stdout, "----------------------\n" );