Commit 337da8b1 authored by bayers's avatar bayers
Browse files

JBM + rate switching for OSBA

parent d2be344b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3449,6 +3449,16 @@ void ivas_sba_set_cna_cng_flag(

ivas_error ivas_sba_dec_reconfigure(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
#ifdef JBM_FOR_OSBA
    ,
    uint16_t *nSamplesFlushed,            /* o  : number of samples flushed */
#if defined SPLIT_REND_WITH_HEAD_ROT
    const PCM_RESOLUTION pcm_resolution, /* i  : type for the decoded PCM resolution */
    void *data                           /* o  : output synthesis signal     */
#else
    int16_t *data /* o  : output synthesis signal                 */
#endif
#endif
);

ivas_error ivas_sba_digest_tc(
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@
#define CR_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods */
#define CR_FIX_698_SBA_MSAN                             /* Dlb: issue 698: Uninitialized memory read in SBA init */
#define CR_FIX_OSBA_FLOAT_BUFFER_INIT                   /* FhG: */
#define CR_FIX_JBM_FLUSH_OFFSET

/* ##################### End NON-BE CR switches ########################### */

+31 −3
Original line number Diff line number Diff line
@@ -361,7 +361,17 @@ ivas_error ivas_dec_setup(
            num_bits_read += SBA_ORDER_BITS;
            if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 )
            {
                if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_sba_dec_reconfigure( st_ivas
#ifdef JBM_FOR_OSBA
                                                         ,
                                                         nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
                                                         pcm_resolution,
#endif
                                                         data
#endif

                                                         ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -472,7 +482,16 @@ ivas_error ivas_dec_setup(

            if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate )
            {
                if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_sba_dec_reconfigure( st_ivas 
                #ifdef JBM_FOR_OSBA
                                                         ,
                                                         nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
                                                         pcm_resolution,
#endif
                                                         data
#endif
                ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -598,7 +617,16 @@ ivas_error ivas_dec_setup(
                    st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4;
                }

                if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_sba_dec_reconfigure( st_ivas 
                #ifdef JBM_FOR_OSBA
                                                         ,
                                                         nSamplesRendered,
#if defined SPLIT_REND_WITH_HEAD_ROT
                                                         pcm_resolution,
#endif
                                                         data
#endif
                ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
+87 −7
Original line number Diff line number Diff line
@@ -958,7 +958,11 @@ ivas_error ivas_jbm_dec_render(
                    + MAX_NUM_OBJECTS
#endif
    ];
    float *p_tc[MAX_TRANSPORT_CHANNELS];
    float *p_tc[MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
                + MAX_NUM_OBJECTS
#endif
    ];
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;

    error = IVAS_ERR_OK;
@@ -1532,7 +1536,11 @@ ivas_error ivas_jbm_dec_flush_renderer(
        hTcBuffer->n_samples_buffered = hTcBuffer->n_samples_granularity + n_samples_still_available;
        hTcBuffer->n_samples_available = 0;
        hTcBuffer->n_samples_flushed = n_samples_to_render;
#ifdef CR_FIX_JBM_FLUSH_OFFSET
        hTcBuffer->n_samples_rendered = 0;
#else
        hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity;
#endif

        for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ )
        {
@@ -1631,12 +1639,59 @@ ivas_error ivas_jbm_dec_flush_renderer(
                }
            }
        }
#ifdef JBM_FOR_OSBA
        else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
        {
            float *tc_local[MAX_TRANSPORT_CHANNELS];
            int16_t last_spar_md_idx;
            int16_t last_dirac_md_idx;
            uint16_t nSamplesAvailableNext;

            last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
            last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
#ifdef DEBUGGING
            assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV );
#endif
            /* copy from ISM delay buffer to the correct place in tcs */
            for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
            {
                tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
                mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size );
            }
            /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */
            st_ivas->hSpar->nb_subframes = 1;
            st_ivas->hSpar->subframes_rendered = 0;
            st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
            st_ivas->hSpar->slots_rendered = 0;
            st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
            st_ivas->hSpatParamRendCom->nb_subframes = 1;
            st_ivas->hSpatParamRendCom->subframes_rendered = 0;
            st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
            st_ivas->hSpatParamRendCom->slots_rendered = 0;
            st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
            /* also adapt md maps, just use the last index */
            set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available );
            set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
            /* render the last subframe */
            if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
#endif
        else
        {
            return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" );
        }
#ifdef CR_FIX_JBM_FLUSH_OFFSET
        hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity;
#endif
    }

#ifdef JBM_FOR_OSBA
    *nSamplesRendered = n_samples_to_render;
#endif

    /* Only write out the valid data*/
#if defined SPLIT_REND_WITH_HEAD_ROT
    if ( st_ivas->hDecoderConfig->Opt_Limiter )
@@ -2002,8 +2057,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels(
        {
            num_tc++;
        }
        if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
            num_tc += st_ivas->nchan_ism;
        }
    }
#endif
    else if ( st_ivas->ivas_format == MC_FORMAT )
    {
@@ -2208,7 +2266,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
    if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE )
    {
        hTcBuffer->tc_buffer = NULL;
        for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
        for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
                                       + MAX_NUM_OBJECTS
#endif
            ; ch_idx++ )
        {
            hTcBuffer->tc[ch_idx] = NULL;
        }
@@ -2235,7 +2297,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
        if ( nsamp_to_allocate == 0 )
        {
            hTcBuffer->tc_buffer = NULL;
            for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
            for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
        + MAX_NUM_OBJECTS
#endif
                ; ch_idx++ )
            {
                hTcBuffer->tc[ch_idx] = NULL;
            }
@@ -2259,7 +2325,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
                hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
                offset += n_samp_residual;
            }
            for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
            for ( ; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
                                 + MAX_NUM_OBJECTS
#endif
                ; ch_idx++ )
            {
                hTcBuffer->tc[ch_idx] = NULL;
            }
@@ -2372,7 +2442,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
        hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset];
        offset += n_samp_residual;
    }
    for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ )
    for ( ; ch_idx < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
        + MAX_NUM_OBJECTS
#endif

          ;
          ch_idx++ )
    {
        hTcBuffer->tc[ch_idx] = NULL;
    }
@@ -2436,7 +2512,11 @@ void ivas_jbm_dec_tc_buffer_close(

    if ( *phTcBuffer != NULL )
    {
        for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ )
        for ( i = 0; i < MAX_TRANSPORT_CHANNELS
#ifdef JBM_FOR_OSBA
                             + MAX_NUM_OBJECTS
#endif
            ; i++ )
        {
            ( *phTcBuffer )->tc[i] = NULL;
        }
+204 −30
Original line number Diff line number Diff line
@@ -102,6 +102,16 @@ void ivas_sba_set_cna_cng_flag(

ivas_error ivas_sba_dec_reconfigure(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
#ifdef JBM_FOR_OSBA
    ,
    uint16_t *nSamplesFlushed, /* o  : number of samples flushed */
#if defined SPLIT_REND_WITH_HEAD_ROT
    const PCM_RESOLUTION pcm_resolution, /* i  : type for the decoded PCM resolution */
    void *data                           /* o  : output synthesis signal     */
#else
    int16_t *data /* o  : output synthesis signal                 */
#endif
#endif
)
{
    int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old;
@@ -115,8 +125,13 @@ ivas_error ivas_sba_dec_reconfigure(
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
    ISM_MODE ism_mode_old;
#ifdef JBM_FOR_OSBA
    int16_t granularity_new;
    int16_t sba_analysis_order_old;
#endif
    ism_mode_old = st_ivas->ism_mode;


    error = IVAS_ERR_OK;

    hDecoderConfig = st_ivas->hDecoderConfig;
@@ -127,7 +142,9 @@ ivas_error ivas_sba_dec_reconfigure(
     * Set SBA high-level parameters
     * Save old SBA high-level parameters
     *-----------------------------------------------------------------*/

#ifdef JBM_FOR_OSBA
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas );
#endif
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    nchan_hp20_old = getNumChanSynthesis( st_ivas );
    if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
@@ -150,11 +167,96 @@ ivas_error ivas_sba_dec_reconfigure(
    nCPE_old = st_ivas->nCPE;
    nchan_transport_old = st_ivas->nchan_transport;
    sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag;
#ifndef JBM_FOR_OSBA
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas );
#endif
#ifdef JBM_FOR_OSBA
    sba_analysis_order_old = st_ivas->sba_analysis_order;
#endif
    st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );

#ifdef JBM_FOR_OSBA
    *nSamplesFlushed = 0;
    granularity_new = st_ivas->hTcBuffer->n_samples_granularity;
    /* we may need to flush only for binaural and OSBA and TSM */
    if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
        RENDERER_TYPE renderer_type_new;
        int16_t sba_order_internal;
        sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );

        /* get new renderer type */
        /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */
        if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 )
        {

            if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL
#ifdef SPLIT_REND_WITH_HEAD_ROT
                 || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
            )
            {
                renderer_type_new = RENDERER_BINAURAL_PARAMETRIC;
            }
            else
            {
                renderer_type_new = RENDERER_BINAURAL_PARAMETRIC_ROOM;
            }
        }
        else
        {
            if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
                 || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
            )
            {
                renderer_type_new = RENDERER_BINAURAL_FASTCONV;
            }
            else
            {
                renderer_type_new = RENDERER_BINAURAL_FASTCONV_ROOM;
            }
        }
        /* determine new granularity */
        granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
        /* this will change anyway only with binaural */
        if ( renderer_type_new == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
        {
            granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME;
        }
        /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */

        if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
        {
            /* write back info for correct rendering */
            st_ivas->sba_analysis_order = sba_analysis_order_old;
            if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed,
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                        pcm_resolution,
#endif
                                                        data ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
        }
        else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
        {
            if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }
#endif

    /* save old */
#ifdef JBM_FOR_OSBA
    if ( ism_mode_old != ISM_SBA_MODE_DISC )
    /* only necessary for SBA and OSBA w/o disrcrete objects, otherwise hTcBuffer is in sync anyway */
    {
#endif
        if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) // ToDo; this never happens
        {
            st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots;
@@ -171,7 +273,7 @@ ivas_error ivas_sba_dec_reconfigure(
            st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
            mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }

    }
    /*-----------------------------------------------------------------*
     * Allocate, initialize, and configure SBA handles
     *-----------------------------------------------------------------*/
@@ -227,12 +329,14 @@ ivas_error ivas_sba_dec_reconfigure(
    hSpar = st_ivas->hSpar;
    st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );

#ifndef JBM_FOR_OSBA
    /* synchronize subframe info */
    st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots;
    st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
    st_ivas->hSpar->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
    st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
    mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
#endif

    if ( st_ivas->nchan_transport == 1 )
    {
@@ -289,6 +393,7 @@ ivas_error ivas_sba_dec_reconfigure(
            return error;
        }

#ifndef JBM_FOR_OSBA
        /* synchronize subframe info */
        if ( st_ivas->hSpatParamRendCom != NULL )
        {
@@ -298,6 +403,7 @@ ivas_error ivas_sba_dec_reconfigure(
            st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
            mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }
#endif
    }

    if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
@@ -465,7 +571,12 @@ ivas_error ivas_sba_dec_reconfigure(
    /*-----------------------------------------------------------------*
     * JBM TC buffer
     *-----------------------------------------------------------------*/
    if ( st_ivas->hDecoderConfig->Opt_5ms == 1 )
    if ( st_ivas->hDecoderConfig->Opt_5ms == 1
#ifdef JBM_FOR_OSBA
         || st_ivas->ivas_format == SBA_ISM_FORMAT
#endif

    )
    {
        int16_t tc_nchan_to_allocate;
        int16_t tc_nchan_tc;
@@ -476,19 +587,39 @@ ivas_error ivas_sba_dec_reconfigure(
        tc_nchan_to_allocate = tc_nchan_tc;
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO )
        {
#ifdef JBM_FOR_OSBA
            if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) )
            {
                tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism;
                tc_nchan_to_allocate = tc_nchan_tc;
            }
            else
#endif
            {
                tc_buffer_mode = TC_BUFFER_MODE_BUFFER;
                tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out;
                tc_nchan_to_allocate = tc_nchan_tc;
            }
        }
        else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
        {
            tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
        }
        else if ( st_ivas->ivas_format == SBA_FORMAT )
        else if ( st_ivas->ivas_format == SBA_FORMAT
#ifdef JBM_FOR_OSBA
                  || st_ivas->ivas_format == SBA_ISM_FORMAT
#endif
        )
        {
            tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
#ifdef JBM_FOR_OSBA
            if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
            {
                tc_nchan_to_allocate += st_ivas->nchan_ism;
            }
        else
#endif
        }
        else /* :TODO: looks obsolete, needs to be checked */
        {
            if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
            {
@@ -496,15 +627,58 @@ ivas_error ivas_sba_dec_reconfigure(
            }
        }

        if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode )
        if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode
#ifdef JBM_FOR_OSBA
             || granularity_new != st_ivas->hTcBuffer->n_samples_granularity
#endif
        )
        {
            if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
#ifdef JBM_FOR_OSBA
            if ( !st_ivas->hDecoderConfig->Opt_5ms )
            {
                tc_nchan_tc = 0;
                tc_nchan_to_allocate = 0;
            }
#endif
            if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate,
#ifdef JBM_FOR_OSBA
                                                               granularity_new
#else
                                                           NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS )
#endif
                                                               ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }

#ifdef JBM_FOR_OSBA
    /* resync SPAR and DirAC JBM info from TC Buffer */
    if ( st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity )
    {
        if ( st_ivas->hSpatParamRendCom != NULL )
        {
            mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
            st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
            st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
        }
        mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
        st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
    }

    if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
    {
        int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size;
        int16_t n;
        for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ )
        {
            st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier;
        }
    }
#endif

    /*-----------------------------------------------------------------*
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/
Loading