Commit f2113d99 authored by vaclav's avatar vaclav
Browse files

Merge branch...

Merge branch '1227-ram-optimization-in-crend-binaural-renderer-with-external-binary-file' into 'main'

Resolve "RAM optimization in Crend binaural renderer with external binary file"

See merge request !1873
parents 6b08136c 724b802b
Loading
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -160,7 +160,10 @@ typedef struct
    char *hrtfFileName;

    IVAS_DEC_HRTF_HANDLE *hHrtfTD;
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF;
#endif

    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics;

    IVAS_BIN_RENDERER_TYPE binaural_renderer;
@@ -245,7 +248,9 @@ int main(
#endif

    hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
    hHrtfBinary.hSetOfHRTF = NULL; /* just to avoid compilation warning */
#endif
    hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */

    splitRendBits.bits_buf = splitRendBitsBuf;
@@ -813,7 +818,9 @@ cleanup:
    if ( arg.hrtfReaderEnabled )
    {
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
        destroy_SetOfHRTF( hHrtfBinary.hSetOfHRTF );
#endif
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
    }

@@ -3740,11 +3747,13 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
            destroy_td_hrtf( hHrtfBinary->hHrtfTD );
        }

#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
        if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && hHrtfBinary->hSetOfHRTF != NULL )
        {
            destroy_SetOfHRTF( hHrtfBinary->hSetOfHRTF );
        }

#endif
        if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -3788,13 +3797,22 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(

        if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
        {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
            if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfCrend ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfBinary->hSetOfHRTF ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hHrtfBinary->hrtfReader, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, output_Fs ) ) != IVAS_ERR_OK )
#else
            if ( ( error = create_SetOfHRTF_from_binary( *hHrtfBinary->hSetOfHRTF, hHrtfBinary->hrtfReader, output_Fs ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -3803,7 +3821,11 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
                }
                else
                {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
                    destroy_crend_hrtf( hHrtfCrend );
#else
                    destroy_SetOfHRTF( hHrtfBinary->hSetOfHRTF );
#endif
                }
            }
        }
+27 −0
Original line number Diff line number Diff line
@@ -665,7 +665,11 @@ int main(
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
#else
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
#endif
    IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
    IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
@@ -920,13 +924,27 @@ int main(
            }


#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hHrtfCrend ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            IVAS_AUDIO_CONFIG hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4;
            if ( args.inConfig.ambisonicsBuses->audioConfig != IVAS_AUDIO_CONFIG_INVALID && args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                hrtf_set_audio_cfg = args.inConfig.ambisonicsBuses->audioConfig;
            }

            if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hrtfFileReader, args.outConfig.audioConfig, hrtf_set_audio_cfg, args.sampleRate ) ) != IVAS_ERR_OK )
#else
            if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -935,7 +953,11 @@ int main(
                }
                else
                {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
                    destroy_crend_hrtf( hHrtfCrend );
#else
                    destroy_SetOfHRTF( hSetOfHRTF );
#endif
                }
            }

@@ -1956,7 +1978,9 @@ cleanup:

    Vector3PairFileReader_close( &referenceVectorReader );
    destroy_td_hrtf( hHrtfTD );
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
    destroy_SetOfHRTF( hSetOfHRTF );
#endif
    destroy_hrtf_statistics( hHrtfStatistics );
    IVAS_REND_Close( &hIvasRend );
    IsmPositionProvider_close( positionProvider );
@@ -2499,6 +2523,9 @@ static CmdlnArgs defaultArgs(
    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
    args.outConfig.outSetupCustom.num_spk = 0;
    args.outConfig.outSetupCustom.num_lfe = 0;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    args.inConfig.ambisonicsBuses->audioConfig = IVAS_AUDIO_CONFIG_INVALID;
#endif

    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    {
+4 −0
Original line number Diff line number Diff line
@@ -175,7 +175,11 @@ typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE;

typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
typedef struct ivas_hrtf_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
#else
typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
#endif
typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;
typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE;
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */
#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM            /* VA: issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed */
#define FIX_1227_Crend_HRTF_LOADING_OPTIM               /* VA: issue 1227: for Crend binaural renderer in decoder, load only HTRT coefficient set that is needed */


/* #################### End BE switches ################################## */
+13 −0
Original line number Diff line number Diff line
@@ -2175,8 +2175,13 @@ ivas_error ivas_init_decoder(
            }
        }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
        if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
                                            st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
                                            st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -2656,7 +2661,11 @@ void ivas_initialize_handles_dec(
    st_ivas->hMonoDmxRenderer = NULL;
    st_ivas->hCrendWrapper = NULL;
    st_ivas->hReverb = NULL;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    st_ivas->hHrtfCrend = NULL;
#else
    st_ivas->hSetOfHRTF = NULL;
#endif
    st_ivas->hHrtfFastConv = NULL;
    st_ivas->hHrtfParambin = NULL;
    st_ivas->hHrtfStatistics = NULL;
@@ -2874,7 +2883,11 @@ void ivas_destroy_dec(
    }

    /* CRend binaural renderer handle */
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    ivas_HRTF_CRend_binary_close( &st_ivas->hHrtfCrend );
#else
    ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF );
#endif

    /* Fastconv HRTF memories */
    ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv );
Loading