Commit 0eb861f0 authored by Jan Brouwer's avatar Jan Brouwer
Browse files

moved load hrtf statistics from binary to after load hrtfs for all renderers...

moved load hrtf statistics from binary to after load hrtfs for all renderers in decoder.c and renderer.c; added calls to destroy_hrtf_statistics()
parent 48035f1e
Loading
Loading
Loading
Loading
+32 −9
Original line number Diff line number Diff line
@@ -806,18 +806,10 @@ int main(
        }
#endif

#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
        if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK )
#else
        if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
#endif
        {
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
            {
@@ -833,6 +825,7 @@ int main(
        }
#endif
#endif
#endif

#ifndef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
@@ -926,6 +919,36 @@ int main(
            fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName );
            goto cleanup;
        }
#endif

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
        if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, 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;
            }
            else
            {
                destroy_hrtf_statistics( hHrtfStatistics );
            }
        }
#else
        if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
            goto cleanup;
        }
#endif
#endif
#endif
    }

+24 −9
Original line number Diff line number Diff line
@@ -1111,17 +1111,9 @@ int main(
                }
            }

#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
            if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" );
                goto cleanup;
            }
            if ( ( hHrtfStatistics != NULL ) && ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
#else
            if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -1129,6 +1121,7 @@ int main(
                    goto cleanup;
                }
            }
#endif
#endif

            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
@@ -1187,6 +1180,28 @@ int main(
                    destroy_parambin_hrtf( hHrtfParambin );
                }
            }

#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" );
                goto cleanup;
            }
            if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    goto cleanup;
                }
                else
                {
                    destroy_hrtf_statistics( hHrtfStatistics );
                }
            }
#endif
#endif
        }

        hrtfFileReader_close( &hrtfFileReader );
+2 −1
Original line number Diff line number Diff line
@@ -2262,12 +2262,13 @@ ivas_error destroy_hrtf_statistics(
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle  */
)
{
    if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == TRUE )
    if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE )
    {
        free( ( *hHrtfStatistics )->average_energy_l );
        free( ( *hHrtfStatistics )->average_energy_r );
        free( ( *hHrtfStatistics )->inter_aural_coherence );
    }
    ivas_HRTF_statistics_binary_close( hHrtfStatistics );
    return IVAS_ERR_OK;
}
#endif