Commit 60ef3077 authored by kinuthia's avatar kinuthia
Browse files

Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend

- under FIX_330_ENABLE_TD_RENDERER_REVERB_REND define
- Also fix bug affecting TD renderer reverb introduced in commit c5de9c9a
parent f384a864
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@
#define LOW_RATE_TRANS_CORE_CODER                       /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */
#define FIX_197_CREND_INTERFACE 
#define FIX_329_ENABLE_TD_RENDERER_REVERB_MC            /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */
#define FIX_330_ENABLE_TD_RENDERER_REVERB_REND          /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */

#define FIX_347_DTX_CRASH                               /* FhG: Fix crash that can happen with DTX */
#define DISABLE_RES_CHANNELS_MCT                        /* decode only W and residual for Y when outputting to stereo */
#define FIX_107_5MS_SUBFRAME_RENDERING
+14 −0
Original line number Diff line number Diff line
@@ -1210,6 +1210,12 @@ ivas_error ivas_init_decoder(

        if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
        {
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
            if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#else
#ifdef FIX_197_CREND_INTERFACE
#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC
            if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK )
@@ -1226,6 +1232,7 @@ ivas_error ivas_init_decoder(
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" );
            }
#endif
        }
    }
    else if ( st_ivas->renderer_type == RENDERER_MC )
@@ -1579,6 +1586,9 @@ void ivas_initialize_handles_dec(
    st_ivas->hMonoDmxRenderer = NULL;
#ifdef FIX_197_CREND_INTERFACE
    st_ivas->hCrendWrapper = NULL;
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    st_ivas->hReverb = NULL;
#endif
#else
    st_ivas->hCrend = NULL;
    st_ivas->hHrtf = NULL;
@@ -1745,6 +1755,10 @@ void ivas_destroy_dec(
#else
    ivas_crend_close( st_ivas );
#endif
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    /* Reverb handle */
    ivas_reverb_close( &st_ivas->hReverb );
#endif

    /* LS config converter handle */
    ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+8 −1
Original line number Diff line number Diff line
@@ -71,13 +71,20 @@ void ivas_td_binaural_renderer(
    const int16_t output_frame  /* i  : output frame length               */
)
{
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    ivas_td_binaural_renderer_unwrap( st_ivas->hReverb,
#else
    ivas_td_binaural_renderer_unwrap( st_ivas->hRenderConfig, st_ivas->ini_frame,
#ifdef FIX_197_CREND_INTERFACE
                                      st_ivas->hCrendWrapper,
#else
                                      st_ivas->hCrend,
#endif
#endif
                                      st_ivas->transport_config,
                                      st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format,
#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
                                      st_ivas->hDecoderConfig->output_Fs,
#endif
                                      st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format,
                                      st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame );
}
+5 −2
Original line number Diff line number Diff line
@@ -1217,6 +1217,9 @@ typedef struct Decoder_Struct
    MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer;             /* Mono downmix structure */
#ifdef FIX_197_CREND_INTERFACE
    CREND_WRAPPER_HANDLE hCrendWrapper;
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    REVERB_HANDLE hReverb; /* Reverb handle             */
#endif
#else
    CREND_HANDLE hCrend;                                       /* Convolution mixer renderer structure */
    HRTFS_HANDLE hHrtf;                                        /* HRTFs handle */
+55 −7
Original line number Diff line number Diff line
@@ -221,15 +221,21 @@ void ivas_td_binaural_close(
 *---------------------------------------------------------------------*/

void ivas_td_binaural_renderer_unwrap(
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    REVERB_HANDLE hReverb, /* i  : reverb handle */
#else
    RENDER_CONFIG_DATA *hRenderConfig,  /* i  : Renderer configuration               */
    const int16_t ini_frame,            /* i  : Initialization frame counter         */
#ifdef FIX_197_CREND_INTERFACE
    CREND_WRAPPER_HANDLE hCrendWrapper, /* i  : Crend wrapper handle                 */
#else
    CREND_HANDLE hCrend, /* i  : Crend handle                         */
#endif
#endif
    AUDIO_CONFIG transport_config, /* i  : Transport configuration              */
#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    const int32_t output_Fs, /* i  : Output sampling rate                 */
#endif
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle   */
    const int16_t nchan_transport,                     /* i  : Transport channels (ISms)            */
    const int16_t lfe_idx,                             /* i  : LFE channel index                    */
@@ -246,6 +252,7 @@ void ivas_td_binaural_renderer_unwrap(
    float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k];

    subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    if ( hRenderConfig != NULL )
    {

@@ -263,6 +270,7 @@ void ivas_td_binaural_renderer_unwrap(
                output_Fs );
        }
    }
#endif

    /* Update object position(s) */
    TDREND_Update_object_positions( hBinRendererTd, nchan_transport, lfe_idx, ivas_format, hIsmMetaData, output );
@@ -272,11 +280,19 @@ void ivas_td_binaural_renderer_unwrap(
        /* Update the listener's location/orientation */
        TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL );

#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
        if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) )
#else
        if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) )
#endif
        {
            ivas_reverb_process(
#ifdef FIX_197_CREND_INTERFACE
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
                hReverb,
#else
                hCrendWrapper->hCrend->hReverb,
#endif
#else
                hCrend->hReverb,
#endif
@@ -286,6 +302,7 @@ void ivas_td_binaural_renderer_unwrap(
                reverb_signal,
                subframe_idx );

#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
            ivas_reverb_process(
#ifdef FIX_197_CREND_INTERFACE
                hCrendWrapper->hCrend->hReverb,
@@ -297,15 +314,26 @@ void ivas_td_binaural_renderer_unwrap(
                output,
                reverb_signal,
                subframe_idx );
#endif
        }

        /* Render subframe */
        TDREND_GetMix( hBinRendererTd, output, subframe_length, subframe_idx );
    }


#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    if ( hReverb != NULL )
#else
    if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
#endif
    {

#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
        if ( hReverb != NULL )
#else
        if ( hRenderConfig->roomAcoustics.late_reverb_on )
#endif
        {
            /* add reverb to rendered signals */
            v_add( reverb_signal[0], output[0], output[0], output_frame );
@@ -577,6 +605,9 @@ ivas_error ivas_td_binaural_renderer_ext(
    const LSSETUP_CUSTOM_STRUCT *customLsInput,      /* i  : Input custom loudspeaker layout   */
    const IVAS_REND_HeadRotData *headRotData,        /* i  : Input head positions              */
    const IVAS_REND_AudioObjectPosition *currentPos, /* i  : Object position                   */
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    const REVERB_HANDLE reverb, /* i  : reverb handle */
#endif
    const int16_t output_frame, /* i  : output frame length               */
    float output[][L_FRAME48k]  /* i/o: SCE channels / Binaural synthesis */
)
@@ -585,12 +616,16 @@ ivas_error ivas_td_binaural_renderer_ext(
    ISM_METADATA_HANDLE hIsmMetaData[1];
    int16_t lfe_idx;
    int16_t num_src;
#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    /* TODO tmu : pass down renderer config struct */
    // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k];
#endif
    IVAS_FORMAT ivas_format;
    IVAS_REND_AudioConfigType inConfigType;
    AUDIO_CONFIG transport_config;
#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    int32_t output_Fs;
#endif

    push_wmops( "ivas_td_binaural_renderer_ext" );

@@ -601,6 +636,9 @@ ivas_error ivas_td_binaural_renderer_ext(
    if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
    {
        ivas_format = MC_FORMAT;
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
        transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig );
#endif
        if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
        {
            getAudioConfigNumChannels( inConfig, &num_src );
@@ -615,22 +653,32 @@ ivas_error ivas_td_binaural_renderer_ext(
    {
        ivas_format = ISM_FORMAT;
        num_src = 1;
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
        transport_config = AUDIO_CONFIG_ISM1;
#endif
        hIsmMetaData[0] = &hIsmMetaDataFrame;
        hIsmMetaData[0]->azimuth = currentPos->azimuth;
        hIsmMetaData[0]->elevation = currentPos->elevation;
    }


#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
#ifdef FIX_197_CREND_INTERFACE
    transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig );
#else
    transport_config = rendAudioConfigToIvasAudioConfig( inConfig );
#endif
    output_Fs = output_frame * 50;

#endif
#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND
    ivas_td_binaural_renderer_unwrap( reverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx,
                                      ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL,
                                      output, output_frame );
#else
    ivas_td_binaural_renderer_unwrap( NULL, 1, NULL, transport_config, output_Fs, pTDRend->hBinRendererTd, num_src, lfe_idx,
                                      ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL,
                                      output, output_frame );
#endif

    pop_wmops();

Loading