Commit dd12b72b authored by emerit's avatar emerit
Browse files

Merge branch 'main' into hrtf_binary

parents 1a8f0d14 9faaf9ec
Loading
Loading
Loading
Loading
+77 −17
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
#include "stat_enc.h"
#include "stat_dec.h"
#include "stat_com.h"
#ifdef FIX_197_CREND_INTERFACE
#include "ivas_stat_rend.h"
#endif
#include "ivas_stat_enc.h"
#include "ivas_stat_dec.h"
#include "ivas_stat_com.h"
@@ -5371,23 +5374,6 @@ int16_t ivas_get_num_bands_from_bw_idx(
 * Crend renderer
 *----------------------------------------------------------------------------------*/

ivas_error ivas_crend_init_from_rom(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_close(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_process(
     Decoder_Struct *st_ivas,                                   /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k]                                  /* i/o: input/output audio channels             */
);

#ifdef HRTF_BINARY_FILE

ivas_error ivas_HRTF_CRend_binary_open(
@@ -5398,6 +5384,8 @@ void ivas_HRTF_CRend_binary_close(
	HRTFS_CREND **hSetOfHRTF                                    /* i/o: Set of HRTF handle                      */
);

#ifndef FIX_197_CREND_INTERFACE

ivas_error ivas_crend_init_from_setofhrtf(
	Decoder_Struct *st_ivas     /* i/o: IVAS decoder structure                                 */
);
@@ -5405,6 +5393,7 @@ ivas_error ivas_crend_init_from_setofhrtf(
ivas_error ivas_crend_init_from_hrtf_handle(
	Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
	HRTFS_HANDLE hrtf);
#endif

ivas_error destroy_SetOfHRTF(
	HRTFS_CREND_HANDLE hSetOfHRTF    /* i/o: Set of HRTF CRend handle              */
@@ -5412,6 +5401,77 @@ ivas_error destroy_SetOfHRTF(

#endif

#ifndef FIX_197_CREND_INTERFACE

ivas_error ivas_crend_init_from_rom(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_close(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_crend_process(
     Decoder_Struct *st_ivas,                                   /* i/o: IVAS decoder structure                  */
    float output[][L_FRAME48k]                                  /* i/o: input/output audio channels             */
);

#else

IVAS_REND_AudioConfigType getAudioConfigType(
    const IVAS_REND_AudioConfig config );

ivas_error getAudioConfigNumChannels(
    const IVAS_REND_AudioConfig config,
    int16_t *numChannels );

IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig(
    AUDIO_CONFIG config );

ivas_error ivas_rend_initCrend(
    CREND_WRAPPER *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRendCfg,
#ifdef HRTF_BINARY_FILE
    HRTFS_CREND_HANDLE hSetOfHRTF,
#endif
    const int32_t output_Fs );    

ivas_error ivas_rend_openCrend(
    CREND_WRAPPER_HANDLE *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRendCfg,
    int16_t Opt_Headrotation,
#ifdef HRTF_BINARY_FILE
    HRTFS_CREND_HANDLE hSetOfHRTF,
#endif    
    const int32_t output_Fs );

#ifdef FIX_197_CREND_INTERFACE
void ivas_rend_closeCrend(
#else
ivas_error ivas_rend_closeCrend(
#endif
    CREND_WRAPPER_HANDLE *pCrend );

ivas_error ivas_rend_crendProcess(
    const CREND_WRAPPER *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
    DECODER_CONFIG_HANDLE hDecoderConfig,
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,   
    IVAS_OUTPUT_SETUP_HANDLE hIntSetup, 
    EFAP_HANDLE hEFAPdata,     
    float output[][L_FRAME48k], /* i/o: input/output audio channels     */
    const int32_t output_Fs );
#endif

/*----------------------------------------------------------------------------------*
 * Renderer configuration
 *----------------------------------------------------------------------------------*/
+2 −1
Original line number Diff line number Diff line
@@ -155,9 +155,10 @@
#define FIX_292_VBAP_CALLOC_REMOVAL                     /* Nokia: Fixes issue 292 by removing the remnant callocs */
#define FIX_293_EXT_RENDERER_CLI                        /* FhG: Fix bugs in external renderer CLI */
#define FIX_268                                         /* Issue 268: Add low cost dry-run of memory analysis */
#define HRTF_BINARY_FILE                                /* HRTF filters' binary file used for binaural rendering. */
//#define HRTF_BINARY_FILE                                /* HRTF filters' binary file used for binaural rendering. */
#define LOW_RATE_TRANS_FIX                              /* Eri: Fix for critical item during transitions */

#define FIX_197_CREND_INTERFACE 
/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
+30 −0
Original line number Diff line number Diff line
@@ -207,7 +207,22 @@ ivas_error ivas_dec(
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
#ifdef FIX_197_CREND_INTERFACE
                if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper,
                                                       IVAS_REND_AUDIO_CONFIG_7_1_4,
                                                       IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM,
                                                       NULL,
                                                       NULL,
                                                       NULL,
                                                       NULL,
                                                       output,
                                                       output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                ivas_crend_process( st_ivas, output );
#endif
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
            }
#ifdef DEBUGGING
@@ -389,7 +404,22 @@ ivas_error ivas_dec(
            /* Rendering */
            if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
#ifdef FIX_197_CREND_INTERFACE
                if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper,
                                                       getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
                                                       getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ),
                                                       st_ivas->hDecoderConfig,
                                                       st_ivas->hHeadTrackData,
                                                       &st_ivas->hIntSetup,
                                                       st_ivas->hEFAPdata,
                                                       output,
                                                       output_Fs ) != IVAS_ERR_OK ) )
                {
                    return error;
                }
#else
                ivas_crend_process( st_ivas, output );
#endif
                ivas_binaural_add_LFE( st_ivas, output_frame, output );
            }
            else if ( st_ivas->renderer_type == RENDERER_MC )
+43 −1
Original line number Diff line number Diff line
@@ -1176,9 +1176,17 @@ ivas_error ivas_init_decoder(

        if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
        {
#ifdef FIX_197_CREND_INTERFACE
            if ( ( st_ivas->hCrendWrapper = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" );
            }
            if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL )
#else
            if ( ( st_ivas->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL )
#endif
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR Crend\n" );
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" );
            }
        }
    }
@@ -1198,10 +1206,36 @@ ivas_error ivas_init_decoder(
    }
    else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
    {
#ifdef FIX_197_CREND_INTERFACE
        if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation )
        {
            if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ),
                                           st_ivas->hIntSetup.ls_azimuth,
                                           st_ivas->hIntSetup.ls_elevation,
                                           st_ivas->hIntSetup.nchan_out_woLFE,
                                           EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
                                            getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
                                            getRendAudioConfigFromIvasAudioConfig( st_ivas->hDecoderConfig->output_config ),
                                            st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation,
#ifdef HRTF_BINARY_FILE
                                            st_ivas->hSetOfHRTF,
#endif
                                            st_ivas->hDecoderConfig->output_Fs ) != IVAS_ERR_OK ) )
        {
            return error;
        }
        st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
#else
        if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" );
        }
#endif
    }

    if ( st_ivas->ivas_format == ISM_FORMAT &&
@@ -1505,8 +1539,12 @@ void ivas_initialize_handles_dec(
    st_ivas->hIsmRendererData = NULL;
    st_ivas->hBinRendererTd = NULL;
    st_ivas->hMonoDmxRenderer = NULL;
#ifdef FIX_197_CREND_INTERFACE
    st_ivas->hCrendWrapper = NULL;
#else
    st_ivas->hCrend = NULL;
    st_ivas->hHrtf = NULL;
#endif
#ifdef HRTF_BINARY_FILE
    st_ivas->hSetOfHRTF = NULL;
    st_ivas->hHrtfFastConv = NULL;
@@ -1666,7 +1704,11 @@ void ivas_destroy_dec(
    ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );

    /* Crend handle */
#ifdef FIX_197_CREND_INTERFACE
    ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
#else
    ivas_crend_close( st_ivas );
#endif

    /* LS config converter handle */
    ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+20 −0
Original line number Diff line number Diff line
@@ -1085,7 +1085,23 @@ static ivas_error ivas_ism_bitrate_switching(
            ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );

            /* Open Crend Binaural renderer */
#ifdef FIX_197_CREND_INTERFACE
            if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
                                                getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
                                                getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ),
                                                st_ivas->hRenderConfig,
                                                st_ivas->hDecoderConfig->Opt_Headrotation,
#ifdef HRTF_BINARY_FILE
                                                st_ivas->hSetOfHRTF,
#endif
                                                st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
#else
            ivas_crend_open( st_ivas );
#endif
        }
    }

@@ -1138,12 +1154,16 @@ static ivas_error ivas_ism_bitrate_switching(
#endif

            /* close the crend binaural renderer */
#ifdef FIX_197_CREND_INTERFACE
            ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
#else
            ivas_crend_close( st_ivas );

            if ( st_ivas->hHrtf != NULL )
            {
                st_ivas->hHrtf = NULL;
            }
#endif
        }
    }

Loading