Commit 47b6824d authored by multrus's avatar multrus
Browse files

[cleanup] accept USE_NEW_HRTF_BINARY_FILE_FORMAT

parent 545f05d1
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@

/* #################### Start BASOP porting switches ############################ */

#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#define FIX_WARNING_RENDER_CONFIG                       /* Orange: fix warning on windows build */
#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF              /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to actiate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on  )*/
#define LC3PLUS_LEA_COMPAT_BITRATES_48_6                /* FhG: treat split-rendering 256kbps lc3plus 10ms 0dof bitrate as sentinel value for LEA compatible 48_6 bitrate (124 kbps per channel)  */
+0 −105
Original line number Diff line number Diff line
@@ -189,7 +189,6 @@ static ivas_error check_hrtf_binary_header(
{
    /* Check the renderer type */

#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 ) &&
@@ -197,15 +196,6 @@ static ivas_error check_hrtf_binary_header(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" );
    }
#else
    if ( ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) &&
         ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV_ROOM ) &&
         ( hrtf_header->rend_type != RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) &&
         ( hrtf_header->rend_type != RENDERER_BINAURAL_OBJECTS_TD ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" );
    }
#endif
    /* Check the output format of the decoder */

    if ( ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_FOA ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED ) )
@@ -443,19 +433,6 @@ static ivas_error LoadBSplineBinary(
        LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf );
    }

#ifndef USE_NEW_HRTF_BINARY_FILE_FORMAT
    /* left/right energy and interaural coherence for late reverb */
    for ( i = 0; i < 3; i++ )
    {
        HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) );
        if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
        }
        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

    return IVAS_ERR_OK;
}
@@ -529,11 +506,7 @@ 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 )
@@ -663,11 +636,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
            return header_check_result;
        }

#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 );
#endif
        if ( !is_tdrend )
        {
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
@@ -962,7 +931,6 @@ 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
    for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
    {
        ( *hHRTF )->inv_diffuse_weight[0][i] = *( (float *) ( hrtf_data_rptr ) );
@@ -973,15 +941,6 @@ static ivas_error create_HRTF_from_rawdata(
        ( *hHRTF )->inv_diffuse_weight[1][i] = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );
    }
#else
    /* 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 );
    }
#endif


    /* max_total_num_fsamp_per_iteration */
@@ -1092,23 +1051,16 @@ 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 USE_NEW_HRTF_BINARY_FILE_FORMAT
    HRTF_READER_RENDERER_TYPE rend_type, /* i  : Renderer type           */
#else
    RENDERER_TYPE rend_type, /* i  : Renderer type           */
#endif
    BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i  : Input binaural config   */
)
{
    int16_t i, j;
    char *hrtf_data_rptr;
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
    ivas_error error;
#endif

    ( *hHRTF )->allocate_init_flag = 0;

#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 )
@@ -1127,38 +1079,21 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" );
    }
#else
    ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag );
#endif

    hrtf_data_rptr = hrtf_data;

#if !defined USE_NEW_HRTF_BINARY_FILE_FORMAT
    /* BINAURAL_CONVBANDS */
    if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
    }
    hrtf_data_rptr += sizeof( uint16_t );
#endif

/* HRIR */
#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 )
#endif
    {
        ( *hHRTF )->FASTCONV_HRIR_latency_s = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );

#if defined USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
        }
        hrtf_data_rptr += sizeof( uint16_t );
#endif

        if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
@@ -1205,23 +1140,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#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 )
#endif
    {
        /* HRIR_HOA3 */
        ( *hHRTF )->FASTCONV_HOA3_latency_s = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );

#if defined USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
        }
        hrtf_data_rptr += sizeof( uint16_t );
#endif

        if ( HOA3_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
@@ -1267,23 +1196,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#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 )
#endif
    {
        /* HRIR_HOA2 */
        ( *hHRTF )->FASTCONV_HOA2_latency_s = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );

#if defined USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
        }
        hrtf_data_rptr += sizeof( uint16_t );
#endif

        if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
@@ -1330,23 +1253,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
            }
        }
    }
#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 )
#endif
    {
        /* HRIR_FOA */
        ( *hHRTF )->FASTCONV_FOA_latency_s = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );

#if defined USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
        }
        hrtf_data_rptr += sizeof( uint16_t );
#endif

        if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
@@ -1395,22 +1312,16 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
        }
    }
/* BRIR */
#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 )
#endif
    {
        ( *hHRTF )->FASTCONV_BRIR_latency_s = *( (float *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( float );

#if defined USE_NEW_HRTF_BINARY_FILE_FORMAT
        if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
        }
        hrtf_data_rptr += sizeof( uint16_t );
#endif

        if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
        {
@@ -1524,11 +1435,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 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 ) )
#endif
        {
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
            {
@@ -1686,11 +1593,7 @@ ivas_error load_parambin_HRTF_from_binary(
        }


#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 */
#endif
        {
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
            {
@@ -1780,11 +1683,7 @@ ivas_error create_SetOfHRTF_from_binary(
        hHRTF = NULL;
        if ( hrtf_header.frequency == output_Fs )
        {
#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 )
#endif
            {
                if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
                {
@@ -1803,11 +1702,7 @@ ivas_error create_SetOfHRTF_from_binary(
                    hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_foa );
                }
            }
#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 )
#endif
            {
                if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
                {