Commit e2572235 authored by vaclav's avatar vaclav
Browse files

revert the previous revert

parent 9b895ef5
Loading
Loading
Loading
Loading
+228 −0
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@
#include "ivas_rom_com.h"
#include "ivas_stat_enc.h"
#include "prot.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "lib_isar_pre_rend.h"
#include "isar_prot.h"
#include "isar_stat.h"
#endif
#include <assert.h>
#include <math.h>
#include <stdint.h>
@@ -54,6 +59,187 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r

static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas );

#ifdef SPLIT_REND_WITH_HEAD_ROT
static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );


/*-------------------------------------------------------------------*
 * ivas_dec_reconfig_split_rend()
 *
 * IVAS decoder split rend reconfig
 *-------------------------------------------------------------------*/

static ivas_error ivas_dec_reconfig_split_rend(
    Decoder_Struct *st_ivas /* i  : IVAS decoder structure      */
)
{
    ivas_error error;
    int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag;
    SPLIT_REND_WRAPPER *hSplitRendWrapper;

    hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend;
    pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    cldfb_in_flag = 0;

    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
         st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
    {
        cldfb_in_flag = 1;
    }

    ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    isCldfbNeeded = 0;

    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
    {
        cldfb_in_flag = 0;
    }

    if ( st_ivas->renderer_type != RENDERER_DISABLE )
    {
        if ( cldfb_in_flag == 0 )
        {
            isCldfbNeeded = 1;
        }
        else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag )
        {
            isCldfbNeeded = 1;
        }
        else if ( pcm_out_flag && cldfb_in_flag )
        {
            isCldfbNeeded = 1;
        }
    }
    else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
    {
        isCldfbNeeded = 1;
    }

    if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL )
    {
        if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) );
        }

        num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS;
        for ( ch = 0; ch < num_ch; ch++ )
        {
            hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
        }

        num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS;

        for ( ch = 0; ch < num_ch; ch++ )
        {
            if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) );
            }
        }

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }
    else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL )
    {
        num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS;
        for ( ch = 0; ch < num_ch; ch++ )
        {
            if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL )
            {
                deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] );
                hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
            }
        }

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL )
            {
                deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] );
                hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
            }
        }

        free( hSplitRendWrapper->hCldfbHandles );
        hSplitRendWrapper->hCldfbHandles = NULL;
    }

    if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) &&
         ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) &&
         !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */
    {
        for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
        {
            if ( st_ivas->hTdRendHandles[i] != NULL )
            {
                st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
                ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] );
            }
        }
    }

    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------*
 * ivas_dec_init_split_rend()
 *
 * IVAS decoder split rend init
 *-------------------------------------------------------------------*/

static ivas_error ivas_dec_init_split_rend(
    Decoder_Struct *st_ivas /* i  : IVAS decoder structure      */
)
{
    ivas_error error;
    int16_t cldfb_in_flag, pcm_out_flag;
    int16_t mixed_td_cldfb_flag;

    pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    cldfb_in_flag = 0;

    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
         st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
    {
        cldfb_in_flag = 1;
    }

    ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) )
    {
        if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) );
        }
    }

    mixed_td_cldfb_flag = 0;
    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
    {
        mixed_td_cldfb_flag = 1;
    }

    error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
    return error;
}
#endif


/*-------------------------------------------------------------------*
 * ivas_dec_setup()
@@ -508,6 +694,20 @@ ivas_error ivas_dec_setup(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*-----------------------------------------------------------------*
     * reconfig split rendering as renderer might change after bitrate switching
     *-----------------------------------------------------------------*/

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif

    /*----------------------------------------------------------------*
     * Reset bitstream pointers
     *----------------------------------------------------------------*/
@@ -1040,6 +1240,25 @@ ivas_error ivas_init_decoder(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*-----------------------------------------------------------------*
     * Initialize binuaral split rendering
     *-----------------------------------------------------------------*/

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
    else
    {
        st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses = 1;
    }
#endif

    /*-----------------------------------------------------------------*
     * Allocate and initialize SCE/CPE and other handles
     *-----------------------------------------------------------------*/
@@ -2471,6 +2690,9 @@ void ivas_destroy_dec(
    ivas_binRenderer_close( &st_ivas->hBinRenderer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /* Split binaural renderer handle */
    ISAR_PRE_REND_close( &st_ivas->hSplitBinRend->splitrend, NULL );

    /* TD binaural renderer handles */
    for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
    {
@@ -2480,6 +2702,12 @@ void ivas_destroy_dec(
            ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] );
        }
    }

    if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL )
    {
        free( st_ivas->hSplitBinRend->hCldfbDataOut );
        st_ivas->hSplitBinRend->hCldfbDataOut = NULL;
    }
#endif

    /* Parametric binaural renderer handle */
+30 −236
Original line number Diff line number Diff line
@@ -128,8 +128,6 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType
static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset );
static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples );
static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits );
static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );
static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas );
static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
#endif
@@ -1353,33 +1351,6 @@ static ivas_error IVAS_DEC_Setup(
        *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm;
        *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity;
        *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out;

#ifdef SPLIT_REND_WITH_HEAD_ROT
        /*-----------------------------------------------------------------*
         * ISAR:
         * - initialize ISAR handle at the first frame
         * - reconfigure the ISAR handle in case of bitrate switching (renderer might change)
         *-----------------------------------------------------------------*/

        if ( st_ivas->ini_frame == 0 && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ||
                                          st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
                                          ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) )
        {
            if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

#endif
    }

    return IVAS_ERR_OK;
@@ -4017,6 +3988,36 @@ PCM_RESOLUTION pcm_type_API_to_internal(
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_is_split_rendering_enabled()
 *
 *
 *---------------------------------------------------------------------*/

int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitRend;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
    st_ivas = hIvasDec->st_ivas;
    isSplitRend = 0;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        isSplitRend = 1;
    }

    return isSplitRend;
}


/*-------------------------------------------------------------------*
 * ivas_create_handle_isar()
 *
@@ -4071,213 +4072,6 @@ static void ivas_destroy_handle_isar(
}


/*-------------------------------------------------------------------*
 * ivas_dec_reconfig_split_rend()
 *
 * IVAS decoder split rend reconfig
 *-------------------------------------------------------------------*/

static ivas_error ivas_dec_reconfig_split_rend(
    Decoder_Struct *st_ivas /* i  : IVAS decoder structure      */
)
{
    ivas_error error;
    int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag;
    SPLIT_REND_WRAPPER *hSplitRendWrapper;

    hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend;
    pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    cldfb_in_flag = 0;

    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
         st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
    {
        cldfb_in_flag = 1;
    }

    ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    isCldfbNeeded = 0;

    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
    {
        cldfb_in_flag = 0;
    }

    if ( st_ivas->renderer_type != RENDERER_DISABLE )
    {
        if ( cldfb_in_flag == 0 )
        {
            isCldfbNeeded = 1;
        }
        else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag )
        {
            isCldfbNeeded = 1;
        }
        else if ( pcm_out_flag && cldfb_in_flag )
        {
            isCldfbNeeded = 1;
        }
    }
    else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
    {
        isCldfbNeeded = 1;
    }

    if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL )
    {
        if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) );
        }

        num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS;
        for ( ch = 0; ch < num_ch; ch++ )
        {
            hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
        }

        num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS;

        for ( ch = 0; ch < num_ch; ch++ )
        {
            if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) );
            }
        }

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }
    else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL )
    {
        num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS;
        for ( ch = 0; ch < num_ch; ch++ )
        {
            if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL )
            {
                deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] );
                hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL;
            }
        }

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL )
            {
                deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] );
                hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL;
            }
        }

        free( hSplitRendWrapper->hCldfbHandles );
        hSplitRendWrapper->hCldfbHandles = NULL;
    }

    if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) &&
         ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) &&
         !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */
    {
        for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
        {
            if ( st_ivas->hTdRendHandles[i] != NULL )
            {
                st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL;
                ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] );
            }
        }
    }

    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------*
 * ivas_dec_init_split_rend()
 *
 * IVAS decoder split rend init
 *-------------------------------------------------------------------*/

static ivas_error ivas_dec_init_split_rend(
    Decoder_Struct *st_ivas /* i  : IVAS decoder structure      */
)
{
    ivas_error error;
    int16_t cldfb_in_flag, pcm_out_flag;
    int16_t mixed_td_cldfb_flag;

    pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    cldfb_in_flag = 0;

    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
         st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ||
         st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
    {
        cldfb_in_flag = 1;
    }

    ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS );

    if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) )
    {
        if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) );
        }
    }

    mixed_td_cldfb_flag = 0;
    if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) ||
         ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
    {
        mixed_td_cldfb_flag = 1;
    }

    error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
    return error;
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_is_split_rendering_enabled()
 *
 *
 *---------------------------------------------------------------------*/

int16_t IVAS_DEC_is_split_rendering_enabled(
    IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle  */
)
{
    Decoder_Struct *st_ivas;
    int16_t isSplitRend;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
    st_ivas = hIvasDec->st_ivas;
    isSplitRend = 0;

    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
         ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) )
    {
        isSplitRend = 1;
    }

    return isSplitRend;
}


/*---------------------------------------------------------------------*
 * IVAS_DEC_is_split_rendering_coded_out()
 *