Commit 9ca578dd authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '744-fix-sofa-to-rom-tables-and-binaural-binary-files' of...

Merge branch '744-fix-sofa-to-rom-tables-and-binaural-binary-files' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 744_main_all_changes
parents 4056354b a35ddd65
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@
    </Midl>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_dec;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ExceptionHandling />
      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -109,7 +109,7 @@
      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
      <OmitFramePointers>false</OmitFramePointers>
      <EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <AdditionalIncludeDirectories>..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_dec;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <ExceptionHandling />
+116 −4
Original line number Diff line number Diff line
@@ -745,7 +745,11 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
#else
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
#endif

        if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK )
        {
@@ -753,50 +757,136 @@ int main(
            goto cleanup;
        }

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

        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, 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
        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
        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 NONBE_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;
            }
            else
            {
                destroy_SetOfHRTF( hSetOfHRTF );
            }
        }
#else
        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfFileName );
            goto cleanup;
        }
#endif

#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
#else
        IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv = NULL;
#endif
        if ( ( error = IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfFastConvHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

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

#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
#else
        IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin = NULL;
#endif
        if ( ( error = IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, 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_parambin_hrtf( hHrtfParambin );
            }
        }
#else
        if ( ( error = load_parambin_HRTF_from_binary( hHrtfParambin, hrtfReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName );
            goto cleanup;
        }
#endif
    }

    /*------------------------------------------------------------------------------------------*
@@ -877,13 +967,35 @@ cleanup:
#endif
    if ( arg.hrtfReaderEnabled )
    {
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
#else
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
#endif
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        dealloc_HRTF_binary( hHrtfTD );
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( hHrtfTD != NULL )
        {
            destroy_td_hrtf( hHrtfTD );
        }
#else
        dealloc_HRTF_binary( *hHrtfTD );
#endif
#ifdef NONBE_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 );
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( hSetOfHRTF != NULL )
        {
            destroy_SetOfHRTF( hSetOfHRTF );
        }
#else
        destroy_SetOfHRTF( *hSetOfHRTF );
#endif
    }

    IVAS_DEC_Close( &hIvasDec );
    CustomLsReader_close( &hLsCustomReader );
+141 −2
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@
*******************************************************************************************************/

#include "lib_rend.h"
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
#include "ivas_prot_rend.h"
#endif
#include <assert.h>
#include <math.h>
#include <string.h>
@@ -758,6 +761,12 @@ int main(
#endif
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
#ifdef NONBE_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;
@@ -883,6 +892,7 @@ int main(
        }
    }

#ifndef NONBE_FIX_BINARY_BINAURAL_READING
    if ( !isEmptyString( args.customHrtfFilePath ) )
    {
        if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
@@ -891,6 +901,7 @@ int main(
            exit( -1 );
        }
    }
#endif

    if ( !isEmptyString( args.renderConfigFilePath ) )
    {
@@ -1021,15 +1032,126 @@ int main(
#endif

#ifdef NONBE_UNIFIED_DECODING_PATHS
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig,
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
                                   !isEmptyString( args.customHrtfFilePath ),
#endif
                                   args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != 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 )
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig,
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
                                   !isEmptyString( args.customHrtfFilePath ),
#endif
                                   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 NONBE_FIX_BINARY_BINAURAL_READING
    if ( !isEmptyString( args.customHrtfFilePath ) )
    {
        if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error opening file: %s\n", args.customHrtfFilePath );
            exit( -1 );
        }

        if ( hrtfFileReader != NULL )
        {
            if ( ( error = IVAS_REND_GetHrtfHandle( hIvasRend, &hHrtfTD ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfHandle failed\n\n" );
                goto cleanup;
            }

            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 );
                    goto cleanup;
                }
                else
                {
                    destroy_td_hrtf( hHrtfTD );
                }
            }

#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 );
                    goto cleanup;
                }
            }
#endif

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

            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 );
                    goto cleanup;
                }
                else
                {
                    destroy_SetOfHRTF( hSetOfHRTF );
                }
            }

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

            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 );
                    goto cleanup;
                }
                else
                {
                    destroy_fastconv_hrtf( hHrtfFastConv );
                }
            }

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

            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 );
                    goto cleanup;
                }
                else
                {
                    destroy_parambin_hrtf( hHrtfParambin );
                }
            }
        }
        hrtfFileReader_close( &hrtfFileReader );
    }
#endif


    /* === Configure === */
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
    {
@@ -2103,6 +2225,11 @@ int main(
    free( inFloatBuffer );
    free( outInt16Buffer );
    free( outFloatBuffer );

#ifdef NONBE_FIX_BINARY_BINAURAL_READING
cleanup:
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( bitsBufferData != NULL )
    {
@@ -2134,7 +2261,19 @@ int main(
    RotationFileReader_close( &externalOrientationFileReader );
    RotationFileReader_close( &referenceRotReader );
    Vector3PairFileReader_close( &referenceVectorReader );
#ifndef NONBE_FIX_BINARY_BINAURAL_READING
    hrtfFileReader_close( &hrtfFileReader );
#endif
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
    if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL )
    {
        destroy_SetOfHRTF( hSetOfHRTF );
    }
    if ( hHrtfTD != NULL && *hHrtfTD != NULL )
    {
        destroy_td_hrtf( hHrtfTD );
    }
#endif
    IVAS_REND_Close( &hIvasRend );
    IsmPositionProvider_close( positionProvider );
    RenderConfigReader_close( &renderConfigReader );
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ typedef enum
    IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED,
    IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED,
    IVAS_ERR_INVALID_HRTF,
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
    IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA,
#endif
    IVAS_ERR_INVALID_INPUT_FORMAT,
    IVAS_ERR_INVALID_INDEX,
    IVAS_ERR_NOT_SUPPORTED_OPTION,
+7 −1
Original line number Diff line number Diff line
@@ -150,7 +150,6 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
/*#define SPLIT_REND_WITH_HEAD_ROT  */                  /* Dlb,FhG: Split Rendering contributions 21 and 35 */

/*#define FIX_312_FASTCONV_HRTF_LOAD*/                      /* FhG: update loading of FastConv HRTFs from binary data - to be enabled after Matlab binary blob generation is harmonised */
#define FIX_879_USAN_ERROR_IN_MASA_DECODING             /* FhG: Issue 879 : avoid arithmetic with NULL pointer in the DirAC decoder to fix USAN error */
#define FIX_740_MASA_PREREND_VALIDITY_CHECK             /* Nokia: issue 740: fix incorrect validity check in lib_rend to allow use of MASA prerenderer */
#define FIX_865_MOVE_TD_DECORR                          /* VA: issue 865: Move ivas_td_decorr.c from lib_com to lib_rend */
@@ -159,6 +158,12 @@
#define FIX_890_ARRAY_SIZE                              /* Nokia: issue #890: mismatch in 2D array size declaration and use */


#define FIX_INV_DIFFUSE_WEIGHT                          /* Orange : Fix error in energy compensation in late binaural reverb*/
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange : Missing left/right and coherence late reverb tables in binary format*/
#define FIX_CRASH_LONG_BRIR                             /* Orange : Fix crash when long BRIR is set */
#define FIX_20_MS_FRAME_LEN_TABLES_CONVERTER            /* Orange : generate_tables_convereter tools can generate rom for 5 and 20 ms frame length */
#define FIX_HOA_BRIR_EXT_RENDERER                       /* Orange : allow to create and load hoa brir binary files for renderer */

/* #################### End BE switches ################################## */


@@ -170,6 +175,7 @@
#define NONBE_UNIFIED_DECODING_PATHS                          /* FhG: unify decoding paths   */
#define NONBE_FIX_836_PARAMUPMIX_HEADROT                      /* Dlb: issue #836: Resolve "ParamUpmix MC to SBA conversion done on the already binaurlized output" */
#define NONBE_FIX_874_OMASA_BRSW_2TD                          /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/
#define NONBE_FIX_BINARY_BINAURAL_READING                      /* Add support reading binaural binary file */

/* ##################### End NON-BE switches ########################### */

Loading