Commit c2fbd1a8 authored by lefort's avatar lefort
Browse files

Merge branch 'float-pc' into 1522_ref_PortFlpMR1349

parents d75f2d46 fad62286
Loading
Loading
Loading
Loading
Loading
+136 −1
Original line number Diff line number Diff line
@@ -197,6 +197,10 @@ int main(
    RenderConfigReader *renderConfigReader = NULL;
    int16_t *pcmBuf = NULL;
    IVAS_RENDER_FRAMESIZE asked_frame_size;
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
#endif
#ifdef DEBUGGING
    int32_t noClipping;
    int32_t cnt_frames_limited;
@@ -724,58 +728,171 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifndef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;

#endif
        if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            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 )
            {
#ifdef FIX_OLD_BINARY_FORMAT
                hrtfFileReader_close( &hrtfReader );
                strcat( arg.hrtfFileName, "new" );

                if ( hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                    goto cleanup;
                }

                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
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                goto cleanup;
#endif
            }
            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

#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
#ifndef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL;
#endif
        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;
        }

#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
    }

    /*------------------------------------------------------------------------------------------*
@@ -852,13 +969,31 @@ cleanup:
#endif
    if ( arg.hrtfReaderEnabled )
    {
#ifndef NONBE_FIX_BINARY_BINAURAL_READING
        IVAS_DEC_HRTF_HANDLE hHrtfTD = NULL;
#endif
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( hHrtfTD != NULL )
        {
            destroy_td_hrtf( hHrtfTD );
        }
#else
        dealloc_HRTF_binary( hHrtfTD );
#endif
#ifndef NONBE_FIX_BINARY_BINAURAL_READING
        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 );
+154 −2
Original line number Diff line number Diff line
@@ -613,7 +613,6 @@ static float dBToLin(
    return powf( 10.0f, gain_dB / 20.0f );
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
static int16_t get_cldfb_in_flag(
    const IVAS_AUDIO_CONFIG audioConfig,
@@ -673,6 +672,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;
@@ -814,6 +819,7 @@ int main(
        }
    }

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

    if ( !isEmptyString( args.renderConfigFilePath ) )
    {
@@ -908,12 +915,142 @@ int main(

    const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) );


#ifdef NONBE_FIX_BINARY_BINAURAL_READING
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), 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, (int16_t) args.render_framesize ) ) != 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: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

            if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
#ifdef FIX_OLD_BINARY_FORMAT
                    hrtfFileReader_close( &hrtfFileReader );
                    strcat( args.customHrtfFilePath, "new" );
                    if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                        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: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                            goto cleanup;
                        }
                        else
                        {
                            destroy_td_hrtf( hHrtfTD );
                        }
                    }
#else
                    fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
#endif
                }
                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: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
            }
#endif

            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
                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:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
                {
                    destroy_SetOfHRTF( hSetOfHRTF );
                }
            }

            if ( ( error = IVAS_REND_GetHrtfFastConvHandle( hIvasRend, &hHrtfFastConv ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfFastConvHandle failed: %s\n\n", ivas_error_to_string( error ) );
                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:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
                {
                    destroy_fastconv_hrtf( hHrtfFastConv );
                }
            }

            if ( ( error = IVAS_REND_GetHrtfParamBinHandle( hIvasRend, &hHrtfParambin ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", ivas_error_to_string( error ) );
                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: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
                {
                    destroy_parambin_hrtf( hHrtfParambin );
                }
            }
        }

        hrtfFileReader_close( &hrtfFileReader );
    }
#endif

    fprintf( stdout, "Input audio file:       %s\n", args.inputFilePath );
    fprintf( stdout, "Output audio file:      %s\n\n", args.outputFilePath );

@@ -959,7 +1096,7 @@ int main(
    /* === Configure === */
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error in Renderer Config Init\n" );
        fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }

@@ -1954,6 +2091,9 @@ int main(
    free( outInt16Buffer );
    free( outFloatBuffer );

#ifdef NONBE_FIX_BINARY_BINAURAL_READING
cleanup:
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( bitsBufferData != NULL )
@@ -1988,7 +2128,19 @@ int main(
    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 );
+9 −0
Original line number Diff line number Diff line
@@ -1536,7 +1536,9 @@ typedef enum
#define MAX_ANGULAR_STEP_INV                    ( 1.0f / MAX_ANGULAR_STEP )
#define MAX_INTERPOLATION_STEPS                 12

#ifndef NONBE_FIX_BINARY_BINAURAL_READING
#define LR_IAC_LENGTH_NR_FC                     ( RV_LENGTH_NR_FC )
#endif

/* ----- Enums - TD Renderer ----- */

@@ -1590,8 +1592,15 @@ typedef enum
#define RV_FILTER_MAX_HISTORY                   ( 512 - 160 )               /* for longest history */
#define RV_LENGTH_NR_FC                         ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1

#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
#define RV_LENGTH_NR_FC_16KHZ                   ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1
#endif
#define IVAS_REVERB_DEFAULT_N_BANDS             31

#define LR_IAC_LENGTH_NR_FC                     ( RV_LENGTH_NR_FC )
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
#define LR_IAC_LENGTH_NR_FC_16KHZ               ( RV_LENGTH_NR_FC_16KHZ )
#endif

/*----------------------------------------------------------------------------------*
 * FB mixer constants
+7 −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,
@@ -263,6 +266,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
            return "Acoustic environment not supported";
        case IVAS_ERR_INVALID_HRTF:
            return "Unsupported HRTF filter set";
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        case IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA:
            return "Renderer data missing in HRTF binary file";
#endif
        case IVAS_ERR_INVALID_INPUT_FORMAT:
            return "Invalid input format";
        case IVAS_ERR_INVALID_INDEX:
+11 −0
Original line number Diff line number Diff line
@@ -181,6 +181,17 @@
#define ISAR_BITSTREAM_UPDATE_LC3PLUS                   /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */
#endif
#define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM   /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */

#define NONBE_FIX_BINARY_BINAURAL_READING               /* Orange: Add support for reading binaural binary file */
//#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format*/
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#define NONBE_FIX_AVG_IAC_CLDFB_REVERB
#endif
#define FIX_OLD_BINARY_FORMAT                           /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/      
#define FIX_OLD_BINARY_FILE                             /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/      
#endif
#define FIX_963_USAN_ERROR                              /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */
#define NONBE_FIX_952_MC_PARAMUPMIX_5MS                       /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/
#define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER           /* Qualcomm: issue 953: fix order or ER channels in LC mode*/
Loading