LCOV - code coverage report
Current view: top level - lib_dec - ivas_sba_dec.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ b5bd5e0684ad2d9250297e1e7a0ddc986cb7b37e Lines: 257 285 90.2 %
Date: 2025-10-27 07:01:45 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <assert.h>
      34             : #include <stdint.h>
      35             : #include "options.h"
      36             : #include "cnst.h"
      37             : #include "ivas_cnst.h"
      38             : #include "prot.h"
      39             : #include "ivas_prot.h"
      40             : #include "ivas_prot_rend.h"
      41             : #include "ivas_rom_com.h"
      42             : #include "ivas_rom_dec.h"
      43             : #include <math.h>
      44             : #ifdef DEBUGGING
      45             : #include "debug.h"
      46             : #endif
      47             : #include "wmc_auto.h"
      48             : 
      49             : 
      50             : /*-------------------------------------------------------------------*
      51             :  * ivas_sba_set_cna_cng_flag()
      52             :  *
      53             :  * Set CNA/CNG flags in IVAS SBA decoder
      54             :  *-------------------------------------------------------------------*/
      55             : 
      56       68209 : void ivas_sba_set_cna_cng_flag(
      57             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
      58             : )
      59             : {
      60             :     int16_t n, cpe_id;
      61             : 
      62       68209 :     if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport == 1 )
      63             :     {
      64             :         /* skip as done in init function */
      65             :         /* st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 0; */
      66             :         /* st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 0; */
      67             :     }
      68       62202 :     else 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 || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) )
      69             :     {
      70       10301 :         st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
      71       10301 :         st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
      72             :     }
      73       51901 :     else if ( st_ivas->nchan_transport == 2 && st_ivas->ivas_format != SBA_ISM_FORMAT )
      74             :     {
      75       36015 :         for ( n = 0; n < CPE_CHANNELS; n++ )
      76             :         {
      77       24010 :             st_ivas->hCPE[0]->hCoreCoder[n]->cna_dirac_flag = 0;
      78       24010 :             st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1;
      79             :         }
      80             :     }
      81             :     else
      82             :     {
      83      122682 :         for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
      84             :         {
      85      248358 :             for ( n = 0; n < CPE_CHANNELS; n++ )
      86             :             {
      87      165572 :                 st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cna_dirac_flag = 0;
      88      165572 :                 st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 0;
      89             :             }
      90             :         }
      91             :     }
      92             : 
      93       68209 :     return;
      94             : }
      95             : 
      96             : 
      97             : /*-------------------------------------------------------------------*
      98             :  * ivas_sba_dec_reconfigure()
      99             :  *
     100             :  * Reconfigure IVAS SBA decoder
     101             :  *-------------------------------------------------------------------*/
     102             : 
     103       13935 : ivas_error ivas_sba_dec_reconfigure(
     104             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure              */
     105             : )
     106             : {
     107             :     int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old;
     108             :     AUDIO_CONFIG intern_config_old;
     109             :     int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
     110             :     int16_t sba_dirac_stereo_flag_old;
     111             :     int32_t ivas_total_brate;
     112             :     int32_t last_ivas_total_brate;
     113             :     int16_t num_channels, num_md_sub_frames;
     114             :     int16_t nchan_out_buff;
     115             :     DECODER_CONFIG_HANDLE hDecoderConfig;
     116             :     ivas_error error;
     117             :     ISM_MODE ism_mode_old;
     118             :     int16_t granularity_new;
     119             :     int16_t nchan_transport;
     120             : 
     121       13935 :     ism_mode_old = st_ivas->ism_mode;
     122       13935 :     hDecoderConfig = st_ivas->hDecoderConfig;
     123       13935 :     ivas_total_brate = hDecoderConfig->ivas_total_brate;
     124       13935 :     last_ivas_total_brate = st_ivas->last_active_ivas_total_brate;
     125             : 
     126             :     /*-----------------------------------------------------------------*
     127             :      * Set SBA high-level parameters
     128             :      * Save old SBA high-level parameters
     129             :      *-----------------------------------------------------------------*/
     130             : 
     131       13935 :     ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
     132       13935 :     nchan_hp20_old = getNumChanSynthesis( st_ivas );
     133             : 
     134       13935 :     if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
     135             :     {
     136        8928 :         if ( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ) == ISM_SBA_MODE_DISC )
     137             :         {
     138        5337 :             st_ivas->ism_mode = ISM_SBA_MODE_DISC;
     139             :         }
     140             :         else
     141             :         {
     142        3591 :             st_ivas->ism_mode = ISM_MODE_NONE;
     143             :         }
     144             :     }
     145             :     else
     146             :     {
     147        5007 :         st_ivas->ism_mode = ISM_MODE_NONE;
     148             :     }
     149             : 
     150       13935 :     nSCE_old = st_ivas->nSCE;
     151       13935 :     nCPE_old = st_ivas->nCPE;
     152       13935 :     nchan_transport_old = st_ivas->nchan_transport;
     153       13935 :     sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag;
     154             : 
     155       13935 :     st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
     156             : 
     157       13935 :     granularity_new = st_ivas->hTcBuffer->n_samples_granularity;
     158             : 
     159             :     /* we may need to flush only for binaural and OSBA and TSM */
     160       13935 :     if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     161             :     {
     162             :         /* determine new granularity */
     163        3630 :         granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs );
     164             : 
     165             :         /* flush renderer on granularity change from 5ms to 1.25ms, again only possible for binaural rendering */
     166        3630 :         if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
     167             :         {
     168             :             /* flush already done in IVAS_DEC_ReadFormat() */
     169             :         }
     170        2733 :         else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
     171             :         {
     172         912 :             if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
     173             :             {
     174           0 :                 return error;
     175             :             }
     176             : 
     177             :             /* make sure the changed number of slots in the last subframe is not lost in the following steps */
     178         912 :             if ( st_ivas->hSpatParamRendCom != NULL )
     179             :             {
     180         912 :                 st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
     181             :             }
     182         912 :             st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
     183             :         }
     184             :     }
     185             : 
     186             :     /* save old */
     187       13935 :     if ( ism_mode_old != ISM_SBA_MODE_DISC && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER )
     188             :     {
     189        7401 :         if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL )
     190             :         {
     191        1146 :             st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots;
     192        1146 :             st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes;
     193        1146 :             st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered;
     194        1146 :             st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered;
     195        1146 :             mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     196             :         }
     197        6255 :         else if ( st_ivas->hSpatParamRendCom != NULL )
     198             :         {
     199        6255 :             st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
     200        6255 :             st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
     201        6255 :             st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
     202        6255 :             st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
     203        6255 :             mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     204             :         }
     205             :     }
     206             : 
     207             :     /*-----------------------------------------------------------------*
     208             :      * Allocate, initialize, and configure SBA handles
     209             :      *-----------------------------------------------------------------*/
     210             : 
     211             :     int16_t sba_order_internal;
     212             :     SPAR_DEC_HANDLE hSpar;
     213       13935 :     hSpar = st_ivas->hSpar;
     214             : 
     215       13935 :     sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
     216             : 
     217       13935 :     if ( hSpar != NULL )
     218             :     {
     219       13935 :         if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) )
     220             :         {
     221          48 :             free( st_ivas->hSpar->hPCA );
     222          48 :             hSpar->hPCA = NULL;
     223             :         }
     224             : 
     225       13935 :         if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) )
     226             :         {
     227       12891 :             ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
     228             : 
     229       12891 :             if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK )
     230             :             {
     231           0 :                 return error;
     232             :             }
     233             :         }
     234        1044 :         else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 )
     235             :         {
     236         138 :             num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs;
     237         138 :             ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels );
     238             : 
     239         138 :             num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate );
     240         138 :             if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
     241             :             {
     242           0 :                 return error;
     243             :             }
     244             :         }
     245             : 
     246       13935 :         if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) )
     247             :         {
     248           0 :             if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
     249             :             {
     250           0 :                 return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" );
     251             :             }
     252             : 
     253           0 :             ivas_pca_dec_init( hSpar->hPCA );
     254             :         }
     255             : 
     256       13935 :         ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
     257             :     }
     258             :     else
     259             :     {
     260           0 :         if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
     261             :         {
     262           0 :             return error;
     263             :         }
     264             :     }
     265             : 
     266       13935 :     hSpar = st_ivas->hSpar;
     267       13935 :     st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
     268             : 
     269       13935 :     if ( st_ivas->nchan_transport == 1 )
     270             :     {
     271        4788 :         st_ivas->element_mode_init = IVAS_SCE;
     272             :     }
     273             :     else
     274             :     {
     275        9147 :         st_ivas->element_mode_init = IVAS_CPE_MDCT;
     276             :     }
     277             : 
     278             :     /*-----------------------------------------------------------------*
     279             :      * Renderer selection
     280             :      *-----------------------------------------------------------------*/
     281             : 
     282             :     /* renderer might have changed */
     283       13935 :     intern_config_old = st_ivas->intern_config;
     284       13935 :     ivas_renderer_select( st_ivas );
     285             : 
     286             :     /* side effect of the renderer selection can be a changed internal config */
     287       13935 :     if ( st_ivas->intern_config != intern_config_old )
     288             :     {
     289        2784 :         ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
     290             :     }
     291             : 
     292             :     /*-------------------------------------------------------------------*
     293             :      * Reallocate and initialize binaural rendering handles
     294             :      *--------------------------------------------------------------------*/
     295             : 
     296       13935 :     if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) )
     297             :     {
     298             :         /* open fastconv binaural renderer */
     299        1401 :         if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK )
     300             :         {
     301           0 :             return error;
     302             :         }
     303             :     }
     304       12534 :     else if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) )
     305             :     {
     306        1383 :         ivas_binRenderer_close( &st_ivas->hBinRenderer );
     307             :     }
     308             : 
     309       13935 :     if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer == NULL )
     310             :     {
     311         144 :         if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
     312             :         {
     313           0 :             return error;
     314             :         }
     315             :     }
     316             : 
     317       13935 :     if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX )
     318             :     {
     319       13647 :         ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
     320             :     }
     321             : 
     322       13935 :     if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order,
     323       13935 :                                           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 ),
     324             :                                           st_ivas->ivas_format ) ) != IVAS_ERR_OK )
     325             :     {
     326           0 :         return error;
     327             :     }
     328             : 
     329       13935 :     if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) )
     330       11592 :     {
     331             :         DIRAC_CONFIG_FLAG flag_config;
     332             : 
     333       11592 :         flag_config = DIRAC_OPEN;
     334       11592 :         if ( st_ivas->hDirAC != NULL )
     335             :         {
     336       11064 :             flag_config = DIRAC_RECONFIGURE_MODE;
     337             :         }
     338             : 
     339       11592 :         if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK )
     340             :         {
     341           0 :             return error;
     342             :         }
     343             :     }
     344             :     else
     345             :     {
     346             :         int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
     347             : 
     348        2343 :         st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
     349        2343 :         if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
     350             :         {
     351         276 :             st_ivas->hSpar->enc_param_start_band = 0;
     352             : 
     353         276 :             set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
     354         276 :             st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
     355             :         }
     356             : 
     357        2343 :         ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
     358        2343 :                                  st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 );
     359             : 
     360        2343 :         if ( st_ivas->hDirAC )
     361             :         {
     362         507 :             st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band;
     363             :         }
     364             :     }
     365             : 
     366       13935 :     if ( st_ivas->renderer_type == RENDERER_DISABLE )
     367             :     {
     368        1215 :         ivas_dirac_rend_close( &( st_ivas->hDirACRend ) );
     369        1215 :         ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) );
     370        1215 :         ivas_dirac_dec_close( &( st_ivas->hDirAC ) );
     371        1215 :         vbap_free_data( &( st_ivas->hVBAPdata ) );
     372             :     }
     373             : 
     374       13935 :     if ( st_ivas->hDirAC != NULL )
     375             :     {
     376       11736 :         st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
     377             :     }
     378             : 
     379             :     /*-----------------------------------------------------------------*
     380             :      * Allocate, initialize, and configure SCE/CPE/MCT handles
     381             :      *-----------------------------------------------------------------*/
     382             : 
     383       13935 :     nchan_transport = st_ivas->nchan_transport;
     384       13935 :     if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
     385             :     {
     386        8928 :         if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     387        2868 :         {
     388             :             int32_t temp_brate[MAX_SCE];
     389             : 
     390        2868 :             st_ivas->ism_mode = ISM_SBA_MODE_DISC;
     391        2868 :             if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
     392             :             {
     393           0 :                 return error;
     394             :             }
     395             : 
     396        2868 :             if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING ||
     397        2868 :                    st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ||
     398        2868 :                    st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ||
     399        2868 :                    st_ivas->renderer_type == RENDERER_OSBA_STEREO ||
     400        2646 :                    st_ivas->renderer_type == RENDERER_OSBA_AMBI ||
     401        2214 :                    st_ivas->renderer_type == RENDERER_OSBA_LS ||
     402        1494 :                    st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
     403         582 :                    st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
     404         366 :                    st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
     405             :             {
     406        2502 :                 if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
     407             :                 {
     408           0 :                     return error;
     409             :                 }
     410             :             }
     411             : 
     412        2868 :             if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
     413             :             {
     414         144 :                 if ( st_ivas->hMonoDmxRenderer == NULL )
     415             :                 {
     416           0 :                     if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
     417             :                     {
     418           0 :                         return error;
     419             :                     }
     420             :                 }
     421             :             }
     422             :             else
     423             :             {
     424        2724 :                 ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
     425             :             }
     426             : 
     427        2868 :             if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
     428             :             {
     429             :                 /* Allocate TD renderer for the objects in DISC mode */
     430         912 :                 if ( st_ivas->hBinRendererTd == NULL )
     431             :                 {
     432         912 :                     if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
     433             :                     {
     434           0 :                         return error;
     435             :                     }
     436             :                 }
     437             : 
     438         912 :                 if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
     439             :                 {
     440         366 :                     if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
     441             :                     {
     442           0 :                         return error;
     443             :                     }
     444             :                 }
     445             :             }
     446             : 
     447             :             /* Allocate memory for OSBA delay buffer */
     448        2868 :             if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK )
     449             :             {
     450           0 :                 return error;
     451             :             }
     452             : 
     453        2868 :             nchan_transport += st_ivas->nchan_ism;
     454        2868 :             st_ivas->nCPE = ( nchan_transport + 1 ) >> 1;
     455             :         }
     456        6060 :         else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE )
     457             :         {
     458             :             /* ISM renderer handle */
     459        2847 :             ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
     460        2847 :             ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
     461        2847 :             ivas_osba_data_close( &st_ivas->hSbaIsmData );
     462             : 
     463             :             /* Time Domain binaural renderer handle */
     464        2847 :             if ( st_ivas->hBinRendererTd != NULL )
     465             :             {
     466         897 :                 ivas_td_binaural_close( &st_ivas->hBinRendererTd );
     467             :             }
     468             : 
     469        2847 :             nchan_transport = st_ivas->nchan_transport;
     470        2847 :             nchan_transport_old += st_ivas->nchan_ism;
     471             : 
     472        2847 :             st_ivas->ism_mode = ISM_MODE_NONE;
     473             :         }
     474        3213 :         else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     475             :         {
     476        2469 :             nchan_transport = st_ivas->nchan_transport + st_ivas->nchan_ism;
     477        2469 :             st_ivas->nCPE = ( nchan_transport + 1 ) >> 1;
     478        2469 :             nchan_transport_old += st_ivas->nchan_ism;
     479             :         }
     480             :     }
     481             : 
     482       13935 :     if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
     483             :     {
     484           0 :         return error;
     485             :     }
     486             : 
     487             :     /*-----------------------------------------------------------------*
     488             :      * HP20 memories
     489             :      *-----------------------------------------------------------------*/
     490             : 
     491       13935 :     if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
     492             :     {
     493           0 :         return error;
     494             :     }
     495             : 
     496             :     /*-----------------------------------------------------------------*
     497             :      * TD Decorrelator
     498             :      *-----------------------------------------------------------------*/
     499             : 
     500       13935 :     if ( st_ivas->hDiracDecBin[0] != NULL )
     501             :     {
     502        1923 :         if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK )
     503             :         {
     504           0 :             return error;
     505             :         }
     506             :     }
     507             : 
     508             :     /*-----------------------------------------------------------------*
     509             :      * CLDFB instances
     510             :      *-----------------------------------------------------------------*/
     511             : 
     512       13935 :     if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK )
     513             :     {
     514           0 :         return error;
     515             :     }
     516             : 
     517             :     /*-----------------------------------------------------------------*
     518             :      * JBM TC buffers
     519             :      *-----------------------------------------------------------------*/
     520             : 
     521             :     {
     522             :         int16_t tc_nchan_to_allocate;
     523             :         int16_t tc_nchan_tc;
     524             :         TC_BUFFER_MODE tc_buffer_mode;
     525             : 
     526       13935 :         tc_buffer_mode = TC_BUFFER_MODE_RENDERER;
     527       13935 :         tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas );
     528       13935 :         tc_nchan_to_allocate = tc_nchan_tc;
     529       13935 :         if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )
     530             :         {
     531        1899 :             if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
     532             :             {
     533         396 :                 tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism;
     534         396 :                 tc_nchan_to_allocate = tc_nchan_tc;
     535             :             }
     536             :             else
     537             :             {
     538        1503 :                 tc_buffer_mode = TC_BUFFER_MODE_BUFFER;
     539        1503 :                 tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out;
     540        1503 :                 tc_nchan_to_allocate = tc_nchan_tc;
     541             :             }
     542             :         }
     543       12036 :         else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
     544             :         {
     545        1923 :             tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS;
     546             :         }
     547       10113 :         else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
     548             :         {
     549       10113 :             tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
     550             : 
     551       10113 :             if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     552             :             {
     553        4653 :                 tc_nchan_to_allocate += st_ivas->nchan_ism;
     554             :             }
     555             :         }
     556             :         else
     557             :         {
     558           0 :             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 ) ) )
     559             :             {
     560           0 :                 tc_nchan_to_allocate++; /* we need a channel for the CNG in this case*/
     561             :             }
     562             :         }
     563             : 
     564       13935 :         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 || granularity_new != st_ivas->hTcBuffer->n_samples_granularity )
     565             :         {
     566       10737 :             if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK )
     567             :             {
     568           0 :                 return error;
     569             :             }
     570             :         }
     571             :     }
     572             : 
     573             :     /* resync SPAR and DirAC JBM info from TC Buffer */
     574       13935 :     if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity )
     575             :     {
     576       10215 :         mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     577       10215 :         st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
     578       10215 :         st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
     579             :     }
     580       13935 :     mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     581       13935 :     st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
     582       13935 :     st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
     583             : 
     584       13935 :     if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     585             :     {
     586        1521 :         int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size;
     587             :         int16_t n;
     588       13689 :         for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ )
     589             :         {
     590       12168 :             st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier;
     591       12168 :             st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n];
     592             :         }
     593             :     }
     594             : 
     595             :     /*-----------------------------------------------------------------*
     596             :      * floating-point output audio buffers
     597             :      *-----------------------------------------------------------------*/
     598             : 
     599       13935 :     nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
     600       13935 :     if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
     601             :     {
     602           0 :         return error;
     603             :     }
     604             : 
     605       13935 :     return IVAS_ERR_OK;
     606             : }
     607             : 
     608             : 
     609             : /*-------------------------------------------------------------------*
     610             :  * ivas_sba_dec_digest_tc()
     611             :  *
     612             :  *
     613             :  *-------------------------------------------------------------------*/
     614             : 
     615     3386018 : void ivas_sba_dec_digest_tc(
     616             :     Decoder_Struct *st_ivas,           /* i/o: IVAS decoder handle          */
     617             :     const int16_t nCldfbSlots,         /* i  : number of CLDFB slots        */
     618             :     const int16_t nSamplesForRendering /* i  : number of samples provided   */
     619             : )
     620             : {
     621             :     int16_t ch_idx, nchan_transport;
     622             : 
     623             :     /* set the md map */
     624     3386018 :     if ( st_ivas->hDirAC || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT )
     625             :     {
     626     3105649 :         ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots );
     627             :     }
     628             : 
     629     3386018 :     if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
     630             :     {
     631     2408249 :         ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering );
     632             :     }
     633             : 
     634     3386018 :     if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr )
     635             :     {
     636             :         int16_t nSamplesLeftForTD, default_frame;
     637             :         float *decorr_signal[BINAURAL_CHANNELS];
     638             :         float *p_tc[2 * BINAURAL_CHANNELS];
     639             : 
     640      371695 :         default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
     641      371695 :         nSamplesLeftForTD = nSamplesForRendering;
     642             : 
     643     1115085 :         for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
     644             :         {
     645      743390 :             decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx + BINAURAL_CHANNELS];
     646      743390 :             p_tc[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx];
     647             :         }
     648             : 
     649      743539 :         while ( nSamplesLeftForTD )
     650             :         {
     651      371844 :             int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame );
     652             : 
     653      371844 :             if ( st_ivas->hDiracDecBin[0]->hTdDecorr )
     654             :             {
     655      371844 :                 ivas_td_decorr_process( st_ivas->hDiracDecBin[0]->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr );
     656             :             }
     657             : 
     658     1115532 :             for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
     659             :             {
     660      743688 :                 decorr_signal[ch_idx] += nSamplesToDecorr;
     661      743688 :                 p_tc[ch_idx] += nSamplesToDecorr;
     662             :             }
     663      371844 :             nSamplesLeftForTD -= nSamplesToDecorr;
     664             :         }
     665             :     }
     666             : 
     667             :     /* if we have a late CNG generation, do it here */
     668     3386018 :     nchan_transport = st_ivas->nchan_transport;
     669     3386018 :     if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || ( st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) )
     670             :     {
     671      135303 :         nchan_transport = 1; /* Only one channel transported */
     672             :     }
     673             : 
     674     3386018 :     if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) ||
     675     3238868 :          ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) )
     676             :     {
     677      302259 :         Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0];
     678      302259 :         generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna );
     679             :     }
     680             : 
     681     3386018 :     return;
     682             : }
     683             : 
     684             : 
     685             : /*-------------------------------------------------------------------*
     686             :  * ivas_sba_dec_render()
     687             :  *
     688             :  *
     689             :  *-------------------------------------------------------------------*/
     690             : 
     691     2369837 : ivas_error ivas_sba_dec_render(
     692             :     Decoder_Struct *st_ivas,         /* i/o: IVAS decoder handle                       */
     693             :     const uint16_t nSamplesAsked,    /* i  : number of CLDFB slots requested           */
     694             :     uint16_t *nSamplesRendered,      /* o  : number of CLDFB slots rendered            */
     695             :     uint16_t *nSamplesAvailableNext, /* o  : number of CLDFB slots still to render     */
     696             :     float *output_f[]                /* o  : rendered time signal                      */
     697             : )
     698             : {
     699             :     int16_t slots_to_render, first_sf, last_sf, subframe_idx;
     700             :     uint16_t slot_size, ch;
     701             :     uint16_t nchan_internal, nchan_out;
     702             :     SPAR_DEC_HANDLE hSpar;
     703             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
     704             :     float *output_f_local[MAX_OUTPUT_CHANNELS];
     705             :     ivas_error error;
     706             : 
     707     2369837 :     hSpar = st_ivas->hSpar;
     708     2369837 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
     709     2369837 :     nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
     710     2369837 :     nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
     711             : 
     712     2369837 :     if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     713             :     {
     714      752587 :         nchan_out = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out );
     715             : 
     716      752587 :         if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
     717             :         {
     718       51014 :             nchan_out = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out - st_ivas->nchan_ism );
     719             :         }
     720      701573 :         else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
     721             :         {
     722       90874 :             nchan_out = BINAURAL_CHANNELS;
     723             :         }
     724             :     }
     725             : 
     726     2369837 :     nchan_out = min( nchan_out, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) );
     727             : 
     728             : #ifdef DEBUGGING
     729             :     assert( hSpar );
     730             : #endif
     731    20903179 :     for ( ch = 0; ch < nchan_out; ch++ )
     732             :     {
     733    18533342 :         output_f_local[ch] = output_f[ch];
     734             :     }
     735             : 
     736     2369837 :     slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
     737             : 
     738             :     /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
     739     2369837 :     slots_to_render = min( hSpar->num_slots - hSpar->slots_rendered, nSamplesAsked / slot_size );
     740     2369837 :     *nSamplesRendered = slots_to_render * slot_size;
     741     2369837 :     first_sf = hSpar->subframes_rendered;
     742     2369837 :     last_sf = first_sf;
     743             : 
     744    10113100 :     while ( slots_to_render > 0 )
     745             :     {
     746     7743263 :         slots_to_render -= hSpar->subframe_nbslots[last_sf];
     747     7743263 :         last_sf++;
     748             :     }
     749             : #ifdef DEBUGGING
     750             :     assert( slots_to_render == 0 );
     751             : #endif
     752             : 
     753    10113100 :     for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
     754             :     {
     755     7743263 :         int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx];
     756             : 
     757     7743263 :         ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal );
     758             : 
     759     7743263 :         if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
     760             :         {
     761     2697629 :             float gain = st_ivas->hSbaIsmData->gain_bed;
     762     2697629 :             if ( gain != 1.0f && gain >= 0.0f )
     763             :             {
     764      140268 :                 for ( ch = 0; ch < nchan_out; ch++ )
     765             :                 {
     766             :                     int16_t i;
     767    23591784 :                     for ( i = 0; i < n_samples_sf; i++ )
     768             :                     {
     769    23482800 :                         output_f_local[ch][i] *= gain;
     770             :                     }
     771             :                 }
     772             :             }
     773             :         }
     774             : 
     775    70660768 :         for ( ch = 0; ch < nchan_out; ch++ )
     776             :         {
     777    62917505 :             output_f_local[ch] += n_samples_sf;
     778             :         }
     779             : 
     780             :         /* update combined orientation access index */
     781     7743263 :         ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf );
     782             :     }
     783             : 
     784     2369837 :     if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
     785             :     {
     786      857190 :         if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK )
     787             :         {
     788           0 :             return error;
     789             :         }
     790             :     }
     791             : 
     792     2369837 :     if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots )
     793             :     {
     794     1650352 :         if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
     795             :         {
     796     1387648 :             hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % hSpatParamRendCom->dirac_md_buffer_length;
     797             :         }
     798             :         else
     799             :         {
     800      262704 :             hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length;
     801             :         }
     802             :     }
     803             : 
     804     2369837 :     *nSamplesAvailableNext = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size;
     805             : 
     806     2369837 :     return IVAS_ERR_OK;
     807             : }

Generated by: LCOV version 1.14