Commit c0f22851 authored by emerit's avatar emerit
Browse files

fix memory bug for fatsconv, fix min angle à 10 degree for all renderer

parent 20f3fca1
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -707,7 +707,11 @@ ivas_error ivas_allocate_binaural_hrtf(
        }
    }

#ifdef FIX_1123_FASTCONV_16BIT_ROM
    if ( renderer_type == RENDERER_BINAURAL_FASTCONV && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#else
    if ( renderer_type == RENDERER_BINAURAL_FASTCONV || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#endif
    {
        if ( ( HrtfFastConv->leftHRIRReal == NULL ) && ( HrtfFastConv->leftHRIRImag == NULL ) && ( HrtfFastConv->rightHRIRReal == NULL ) && ( HrtfFastConv->rightHRIRImag == NULL ) )
        {
@@ -748,8 +752,11 @@ ivas_error ivas_allocate_binaural_hrtf(
#endif
        }
    }

#ifdef FIX_1123_FASTCONV_16BIT_ROM
    if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#else
    if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
#endif
    {
        if ( ( HrtfFastConv->leftBRIRReal == NULL ) && ( HrtfFastConv->leftBRIRImag == NULL ) && ( HrtfFastConv->rightBRIRReal == NULL ) && ( HrtfFastConv->rightBRIRImag == NULL ) )
        {
+75 −16
Original line number Diff line number Diff line
@@ -1821,24 +1821,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(

    ( *hHRTF )->allocate_init_flag = 0;

#ifndef FIX_1123_FASTCONV_16BIT_ROM
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
    }
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -1847,6 +1840,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" );
    }
#endif

    hrtf_data_rptr = hrtf_data;

@@ -1883,6 +1877,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2020,6 +2021,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2157,6 +2165,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2295,6 +2310,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* HRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2433,6 +2455,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        /* BRIR Q factor*/
        factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
        hrtf_data_rptr += sizeof( Word16 );
@@ -2693,24 +2722,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(

    ( *hHRTF )->allocate_init_flag = 0;

#ifndef FIX_1123_FASTCONV_16BIT_ROM
    if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
    }
    else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -2719,6 +2741,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" );
    }
#endif

    hrtf_data_rptr = hrtf_data;

@@ -2750,6 +2773,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
@@ -2830,6 +2860,14 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
        }
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HOA3_CHANNELS; j++ )
@@ -2911,6 +2949,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HOA2_CHANNELS; j++ )
@@ -2992,6 +3037,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < FOA_CHANNELS; j++ )
@@ -3073,6 +3125,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
#endif
        hrtf_data_rptr += sizeof( uint16_t );

#ifdef FIX_1123_FASTCONV_16BIT_ROM
        if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif

        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
+4 −12
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@
 * Constants
 *------------------------------------------------------------------------------------------*/

#define MAX_DIFF_AZI              5     /* angle in degree */
#define MAX_DIFF_ELE              20    /* angle in degree */
#define MAX_DIFF_ANGLE            10    /* angle in degree */
#define DEFAULT_SAMPLERATE        48000 /* Hz */
#define LAST_SAMPLERATE           16000 /* Hz */
#define TEMPLTATE_C_ROM_FILE_NAME "ivas_license_header.template"
@@ -1101,7 +1100,9 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
                a[2] = sofa_src_pos_val[nearest * 3 + 2];
            }

            if ( fabs( t[0] - a[0] ) > MAX_DIFF_AZI )
            float prodScal = ( t[0] * a[0] + t[1] * a[1] + t[2] * a[2] ) / ( sqrtf( ( t[0] * t[0] + t[1] * t[1] + t[2] * t[2] ) ) * sqrtf( ( a[0] * a[0] + a[1] * a[1] + a[2] * a[2] ) ) );
            float cosAngleMin = cosf( PI_OVER_180 * MAX_DIFF_ANGLE );
            if ( prodScal < cosAngleMin )
            {
                mxDestroyArray( sofa );
                fprintf( stderr, "Nearest position to far from target incomplete sofa file\n" );
@@ -1111,15 +1112,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
                free( index_pos );
                return -1;
            }
            if ( fabs( t[1] - a[1] ) > MAX_DIFF_ELE )
            {
                mxDestroyArray( sofa );
                fprintf( stderr, "Nearest position to far from target incomplete sofa file\n" );
                fprintf( stderr, "Searched for Position: %f, %f, %f\n", t[0], t[1], t[2] );
                fprintf( stderr, "Nearest Position: %f, %f, %f\n", a[0], a[1], a[2] );
                free( sofa_file_path );
                return -1;
            }
            if ( a[0] > 180. )
                a[0] -= 360.;
            if ( a[0] < -180. )
+2 −1
Original line number Diff line number Diff line
@@ -73,8 +73,9 @@ if generateCustomBinaryFile
    %hrir_file_name = 'RIEC_hrir_subject_001.sofa'; % fail for TD renderer
   % output_bin_name = 'ivas_binaural_custom_fabian_hrir';
    output_bin_name = 'ivas_binaural_custom';
    brir_file_name = 'bbcrdlr_all_speakers.sofa'; % fail loading binary file in IVAS_dec/IVAS_rend, fastconv TAPS_SIZE are hard coded
    %brir_file_name = 'bbcrdlr_all_speakers.sofa'; % fail loading binary file in IVAS_dec/IVAS_rend, fastconv TAPS_SIZE are hard coded
    %brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa';
    brir_file_name = 'BRIR_Auditorium_S1_R1.sofa';
else 
    hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa';
    output_bin_name = 'ivas_binaural';
+1 −1
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ if isfile(Lib_Name)
            for ch = 1:length(refAziRad)
                [valMax(ch), chSelect(ch)] = max(Sofa.PosCartesian'*refVectors(ch,:)');
            end
            assert(min(valMax(ch))> 0.99, 'Missing speaker layout Combined directions in sofa file')
            assert(min(valMax(ch))> cos(10 * pi /180), 'Missing speaker layout Combined directions in sofa file')
            Sofa.Data.IR = Sofa.Data.IR(:,:,chSelect);
            Sofa.PosCartesian = Sofa.PosCartesian(:,chSelect);
            Sofa.PosSpherical = Sofa.PosSpherical(:,chSelect);
Loading