Commit 4bdb9b2b authored by emerit's avatar emerit
Browse files

add hrtf load for renderer

parent 4ca90741
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -757,26 +757,31 @@ int main(
        }
#endif
#endif
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
        IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
        if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

        if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_BINARY_BINAURAL_READING
        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != 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;
            }
            fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
            goto cleanup;
        }
#else
        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
            goto cleanup;
#endif
        }
#endif

#ifdef FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
@@ -913,9 +918,13 @@ cleanup:
#endif
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        dealloc_HRTF_binary( *hHrtfTD );
#ifdef FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
#else
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
#endif
        IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF );
        destroy_SetOfHRTF( hSetOfHRTF );
        destroy_SetOfHRTF( *hSetOfHRTF );
    }

    IVAS_DEC_Close( &hIvasDec );
+109 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@
*******************************************************************************************************/

#include "lib_rend.h"
#ifdef FIX_BINARY_BINAURAL_READING
#include "ivas_prot_rend.h"
#endif
#include <assert.h>
#include <math.h>
#include <string.h>
@@ -745,6 +748,12 @@ int main(
#endif
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
#ifdef FIX_BINARY_BINAURAL_READING
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
    IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
    IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
#endif
    IsmPositionProvider *positionProvider;
    LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS];
    RenderConfigReader *renderConfigReader = NULL;
@@ -1011,12 +1020,108 @@ int main(
    IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] = { 0 };
#endif

#ifdef FIX_BINARY_BINAURAL_READING
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }

#ifdef FIX_BINARY_BINAURAL_READING
    if ( hrtfFileReader )
    {
        if ( ( error = IVAS_REND_GetHrtfHandle( hIvasRend, &hHrtfTD ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_REND_GetHrtfHandle failed\n\n" );
            exit( -1 );
        }

        if ( ( error = load_HRTF_binary( *hHrtfTD, 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 );
                exit( -1 );
            }
            else
            {
                free( hHrtfTD );
                hHrtfTD = NULL;
            }
        }

#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 )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                exit( -1 );
            }
        }
#endif

        if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed\n\n" );
            exit( -1 );
        }

        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != 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 );
                exit( -1 );
            }
        }

        if ( ( error = IVAS_REND_GetHrtfFastConvHandle( hIvasRend, &hHrtfFastConv ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_REND_GetHrtfFastConvHandle failed\n\n" );
            exit( -1 );
        }

        if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 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 );
                exit( -1 );
            }
            else
            {
                free( *hHrtfFastConv );
                *hHrtfFastConv = NULL;
            }
        }

        if ( ( error = IVAS_REND_GetHrtfParamBinHandle( hIvasRend, &hHrtfParambin ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed\n\n" );
            exit( -1 );
        }

        if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, 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 );
                exit( -1 );
            }
            else
            {
                free( *hHrtfParambin );
                *hHrtfParambin = NULL;
            }
        }
    }
#endif


    /* === Configure === */
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
    {
@@ -2083,6 +2188,10 @@ int main(
    RotationFileReader_close( &referenceRotReader );
    Vector3PairFileReader_close( &referenceVectorReader );
    hrtfFileReader_close( &hrtfFileReader );
#ifdef FIX_BINARY_BINAURAL_READING
    destroy_SetOfHRTF( *hSetOfHRTF );
    dealloc_HRTF_binary( *hHrtfTD );
#endif
    IVAS_REND_Close( &hIvasRend );
    IsmPositionProvider_close( positionProvider );
    RenderConfigReader_close( &renderConfigReader );
+9 −1
Original line number Diff line number Diff line
@@ -1793,7 +1793,11 @@ ivas_error IVAS_DEC_GetHrtfHandle(

ivas_error IVAS_DEC_GetHrtfCRendHandle(
    IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle      */
#ifdef FIX_BINARY_BINAURAL_READING
    IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o  : Set of HRTF handle       */
#else
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o  : Set of HRTF handle       */
#endif
)
{
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL )
@@ -1801,7 +1805,11 @@ ivas_error IVAS_DEC_GetHrtfCRendHandle(
        return IVAS_ERR_WRONG_PARAMS;
    }

#ifdef FIX_BINARY_BINAURAL_READING
    *hSetOfHRTF = &hIvasDec->st_ivas->hSetOfHRTF;
#else
    *hSetOfHRTF = hIvasDec->st_ivas->hSetOfHRTF;
#endif

    return IVAS_ERR_OK;
}
+4 −0
Original line number Diff line number Diff line
@@ -387,7 +387,11 @@ ivas_error IVAS_DEC_GetHrtfHandle(
/*! r: error code */
ivas_error IVAS_DEC_GetHrtfCRendHandle(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
#ifdef FIX_BINARY_BINAURAL_READING
    IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF      /* o  : Set of HRTF handle                                                      */
#else
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF      /* o  : Set of HRTF handle                                                      */
#endif
);

ivas_error IVAS_DEC_GetHrtfFastConvHandle(
+1 −1
Original line number Diff line number Diff line
@@ -1770,7 +1770,7 @@ void ivas_rend_closeCrend(

#ifdef SPLIT_REND_WITH_HEAD_ROT
/*-------------------------------------------------------------------------
 * ivas_rend_openCldfbRend()
 * ivas_rend_closeCldfbRend()
 *
 * Close CLDFB based fastconv binaural renderer memories
 *------------------------------------------------------------------------*/
Loading