Commit 9faaf9ec authored by emerit's avatar emerit
Browse files

Merge branch 'orange/197-merge-crend-api' into 'main'

[rendering] refactor Crend interface to be independent of decoder struct

See merge request !395
parents 5500e3f9 611af30f
Loading
Loading
Loading
Loading
Loading
+49 −0
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"
@@ -5334,6 +5337,7 @@ int16_t ivas_get_num_bands_from_bw_idx(
/*----------------------------------------------------------------------------------*
 * Crend renderer
 *----------------------------------------------------------------------------------*/
#ifndef FIX_197_CREND_INTERFACE

ivas_error ivas_crend_init_from_rom(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
@@ -5352,6 +5356,51 @@ ivas_error ivas_crend_process(
    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_openCrend(
    CREND_WRAPPER_HANDLE *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRendCfg,
    int16_t Opt_Headrotation,
    const int32_t output_Fs );

ivas_error ivas_rend_initCrend(
    CREND_WRAPPER *pCrend,
    const IVAS_REND_AudioConfig inConfig,
    const IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRendCfg,
    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
+1 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@
#define FIX_268                                         /* Issue 268: Add low cost dry-run of memory analysis */
#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 )
+40 −1
Original line number Diff line number Diff line
@@ -1145,9 +1145,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" );
            }
        }
    }
@@ -1167,10 +1175,33 @@ 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,
                                            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 &&
@@ -1474,8 +1505,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
    st_ivas->hoa_dec_mtx = NULL;

    st_ivas->hHeadTrackData = NULL;
@@ -1630,7 +1665,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 );
+17 −0
Original line number Diff line number Diff line
@@ -1085,7 +1085,20 @@ 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,
                                                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
        }
    }

@@ -1128,12 +1141,16 @@ static ivas_error ivas_ism_bitrate_switching(
            ivas_dirac_dec_init_binaural_data( st_ivas );

            /* 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