LCOV - code coverage report
Current view: top level - lib_dec - ivas_ism_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ d40ed931793b6a50d91fe879dc4ec795971aff53 Lines: 166 200 83.0 %
Date: 2025-09-18 03:57:22 Functions: 2 2 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 <stdint.h>
      34             : #include "options.h"
      35             : #include "prot_fx.h"
      36             : #include "ivas_prot_fx.h"
      37             : #include "ivas_prot_rend_fx.h"
      38             : #include "wmc_auto.h"
      39             : #include "ivas_prot_fx.h"
      40             : 
      41             : 
      42             : /*-------------------------------------------------------------------------*
      43             :  * ivas_ism_bitrate_switching_dec()
      44             :  *
      45             :  *
      46             :  *-------------------------------------------------------------------------*/
      47             : 
      48         994 : static ivas_error ivas_ism_bitrate_switching_dec_fx(
      49             :     Decoder_Struct *st_ivas,          /* i/o: IVAS decoder structure               */
      50             :     const Word16 nchan_transport_old, /* i  : last number of transport channels    */
      51             :     const ISM_MODE last_ism_mode,     /* i  : last ISM mode                        */
      52             :     UWord16 *nSamplesRendered,        /* o  : number of samples rendered           */
      53             :     Word16 *data                      /* o  : output synthesis signal            Q0*/
      54             : )
      55             : {
      56             :     ivas_error error;
      57             :     Word32 element_brate_tmp[MAX_NUM_OBJECTS];
      58             :     Word16 nSCE_old, nCPE_old;
      59             :     Word16 numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode;
      60             :     TC_BUFFER_MODE tc_buffer_mode_new;
      61             :     Word16 tc_nchan_tc_new;
      62             :     Word16 tc_nchan_allocate_new;
      63             :     Word16 tc_granularity_new;
      64             :     Word16 nchan_out_buff, nchan_out_buff_old;
      65             :     AUDIO_CONFIG intern_config_old;
      66             :     IVAS_OUTPUT_SETUP hIntSetupOld;
      67             :     RENDERER_TYPE renderer_type_old;
      68             : 
      69         994 :     error = IVAS_ERR_OK;
      70         994 :     move32();
      71         994 :     nCPE_old = st_ivas->nCPE;
      72         994 :     move16();
      73         994 :     nSCE_old = st_ivas->nSCE;
      74         994 :     move16();
      75             : 
      76             :     /* temporarily set the ism mode back to the old one, otherwise this can give wrong results*/
      77         994 :     ism_mode = st_ivas->ism_mode;
      78         994 :     move16();
      79         994 :     st_ivas->ism_mode = last_ism_mode;
      80         994 :     move16();
      81         994 :     ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
      82         994 :     st_ivas->ism_mode = ism_mode;
      83         994 :     move16();
      84         994 :     nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
      85             : 
      86         994 :     IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
      87             :     {
      88           0 :         return error;
      89             :     }
      90             : 
      91         994 :     st_ivas->nSCE = st_ivas->nchan_transport;
      92         994 :     move16();
      93             : 
      94             :     /*-----------------------------------------------------------------*
      95             :      * Allocate, initialize, and configure SCE/CPE/MCT handles
      96             :      *-----------------------------------------------------------------*/
      97             : 
      98             :     /* st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport */
      99             :     Word16 tmp, tmp_e;
     100             :     Word32 tmp_32;
     101         994 :     tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_e );
     102         994 :     tmp = shr( tmp, sub( 15, tmp_e ) );
     103         994 :     tmp_32 = L_deposit_l( tmp );
     104         994 :     IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, tmp_32, L_shl( tmp_32, 1 ) ) ), IVAS_ERR_OK ) )
     105             :     {
     106           0 :         return error;
     107             :     }
     108             : 
     109             :     /*-----------------------------------------------------------------*
     110             :      * HP20 memories
     111             :      *-----------------------------------------------------------------*/
     112         994 :     IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_transport_old ) ), IVAS_ERR_OK ) )
     113             :     {
     114           0 :         return error;
     115             :     }
     116             : 
     117             :     /* save old IntSetup, might be needed for JBM flushing...*/
     118         994 :     intern_config_old = st_ivas->intern_config;
     119         994 :     move32();
     120         994 :     hIntSetupOld = st_ivas->hIntSetup;
     121         994 :     move32();
     122         994 :     tc_granularity_new = 1;
     123         994 :     move16();
     124         994 :     renderer_type_old = st_ivas->renderer_type;
     125         994 :     move32();
     126             : 
     127             :     /*-----------------------------------------------------------------*
     128             :      * Initialize the needed renderer struct and destroy the unnecessary renderer struct
     129             :      *-----------------------------------------------------------------*/
     130             : 
     131             :     /* select the renderer */
     132         994 :     ivas_renderer_select( st_ivas );
     133             : 
     134         994 :     ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
     135             : 
     136         994 :     test();
     137         994 :     IF( ( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) )
     138             :     {
     139          75 :         ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config );
     140             :     }
     141             : 
     142             :     {
     143         994 :         test();
     144         994 :         test();
     145             :         /* transfer subframe info from DirAC or ParamMC to central tc buffer */
     146             :         /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */
     147         994 :         IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
     148             :         {
     149         241 :             st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
     150         241 :             move16();
     151         241 :             st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
     152         241 :             move16();
     153         241 :             st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
     154         241 :             move16();
     155         241 :             st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
     156         241 :             move16();
     157         241 :             Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     158             :         }
     159             : 
     160             :         /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
     161             :                 render what still fits in the new granularity */
     162         994 :         tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
     163             : 
     164         994 :         IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
     165             :         {
     166          92 :             IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
     167             :             {
     168           0 :                 return error;
     169             :             }
     170             :         }
     171             :         /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
     172         902 :         ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
     173             :         {
     174          92 :             IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) )
     175             :             {
     176           0 :                 return error;
     177             :             }
     178             :         }
     179             :     }
     180             : 
     181         994 :     IF( NE_16( st_ivas->ism_mode, last_ism_mode ) )
     182             :     {
     183             :         /* EFAP handle */
     184         311 :         efap_free_data_fx( &st_ivas->hEFAPdata );
     185             :     }
     186             : 
     187             :     /*-----------------------------------------------------------------*
     188             :      * Switching between ParamISM and DiscISM
     189             :      *-----------------------------------------------------------------*/
     190             : 
     191             :     /* switching from ParamISM to DiscISM */
     192         994 :     test();
     193         994 :     IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
     194             :     {
     195             :         /* Deallocate the ParamISM struct */
     196         157 :         ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
     197             : 
     198         157 :         test();
     199         157 :         IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
     200             :         {
     201             :             /* close the parametric binaural renderer */
     202           0 :             ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
     203             :             /* Open the TD Binaural renderer */
     204           0 :             test();
     205           0 :             IF( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL )
     206             :             {
     207             :                 Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
     208             :                 Word16 num_src;
     209           0 :                 IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
     210             :                 {
     211           0 :                     return error;
     212             :                 }
     213           0 :                 IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     214             :                 {
     215           0 :                     IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
     216             :                     {
     217           0 :                         return error;
     218             :                     }
     219             :                 }
     220             :             }
     221             :         }
     222             :         ELSE
     223             :         {
     224             :             /* close the ISM renderer and reinitialize */
     225         157 :             ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
     226         157 :             IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
     227             :             {
     228           0 :                 return error;
     229             :             }
     230             :         }
     231             : 
     232         157 :         IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
     233             :         {
     234             :             /* close the parametric binaural renderer */
     235          92 :             ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
     236             : 
     237             :             /* Open Crend Binaural renderer */
     238          92 :             IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) )
     239             : 
     240           0 :             st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
     241          92 :             move32();
     242             :         }
     243             :     }
     244             : 
     245             :     /* switching from Discrete ISM to ParamISM */
     246         994 :     test();
     247         994 :     IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_32( last_ism_mode, ISM_MODE_DISC ) )
     248             :     {
     249             :         /* Allocate and initialize the ParamISM struct */
     250         154 :         IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
     251             :         {
     252           0 :             return error;
     253             :         }
     254             : 
     255         154 :         test();
     256         154 :         IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
     257             :         {
     258             :             /* open the parametric binaural renderer */
     259           0 :             IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     260             :             {
     261           0 :                 return error;
     262             :             }
     263             : 
     264           0 :             IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
     265             :             {
     266           0 :                 return error;
     267             :             }
     268             : 
     269             :             /* Close the TD Binaural renderer */
     270           0 :             ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
     271             : 
     272           0 :             IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     273             :             {
     274           0 :                 ivas_reverb_close( &st_ivas->hReverb );
     275             :             }
     276             :         }
     277             :         ELSE
     278             :         {
     279             :             /* Close the ISM renderer */
     280         154 :             ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
     281             :         }
     282             : 
     283         154 :         IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
     284             :         {
     285             :             /* open the parametric binaural renderer */
     286          92 :             IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     287             :             {
     288           0 :                 return error;
     289             :             }
     290             : 
     291          92 :             IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
     292             :             {
     293           0 :                 return error;
     294             :             }
     295             : 
     296             :             /* close the crend binaural renderer */
     297          92 :             ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
     298             :         }
     299             :     }
     300             : 
     301             :     /*-----------------------------------------------------------------*
     302             :      * CLDFB instances
     303             :      *-----------------------------------------------------------------*/
     304             : 
     305         994 :     IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
     306             :     {
     307           0 :         return error;
     308             :     }
     309             : 
     310             :     /*-----------------------------------------------------------------*
     311             :      * floating-point output audio buffers
     312             :      *-----------------------------------------------------------------*/
     313             : 
     314             :     {
     315         994 :         nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
     316             : 
     317         994 :         IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
     318             :         {
     319           0 :             return error;
     320             :         }
     321             :     }
     322             : 
     323             :     /*-----------------------------------------------------------------*
     324             :      * JBM TC buffers
     325             :      *-----------------------------------------------------------------*/
     326             :     {
     327             :         Word16 tc_nchan_full_new;
     328             :         DECODER_TC_BUFFER_HANDLE hTcBuffer;
     329             : 
     330         994 :         hTcBuffer = st_ivas->hTcBuffer;
     331         994 :         tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
     332         994 :         tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
     333         994 :         tc_nchan_allocate_new = tc_nchan_tc_new;
     334         994 :         move16();
     335         994 :         tc_nchan_full_new = tc_nchan_tc_new;
     336         994 :         move16();
     337             : 
     338         994 :         test();
     339         994 :         test();
     340         994 :         test();
     341         994 :         test();
     342         994 :         if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
     343             :         {
     344          71 :             tc_nchan_full_new = 0;
     345          71 :             move16();
     346             :         }
     347             : 
     348             :         /* reconfigure buffer */
     349         994 :         test();
     350         994 :         test();
     351         994 :         test();
     352         994 :         IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
     353             :             NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) )
     354             :         {
     355         311 :             IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
     356             :             {
     357           0 :                 return error;
     358             :             }
     359             :         }
     360             : 
     361             :         /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
     362         994 :         IF( st_ivas->hSpatParamRendCom != NULL )
     363             :         {
     364         238 :             st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
     365         238 :             move16();
     366         238 :             st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
     367         238 :             move16();
     368         238 :             st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
     369         238 :             move16();
     370         238 :             st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
     371         238 :             move16();
     372             : 
     373         238 :             Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     374             :         }
     375             :     }
     376             : 
     377         994 :     return error;
     378             : }
     379             : 
     380             : /*-------------------------------------------------------------------------
     381             :  * ivas_ism_dec_config()
     382             :  *
     383             :  * - select ISM format mode
     384             :  * - reconfigure the ISM format decoder
     385             :  *-------------------------------------------------------------------------*/
     386             : 
     387       92520 : ivas_error ivas_ism_dec_config_fx(
     388             :     Decoder_Struct *st_ivas,      /* i/o: IVAS decoder structure              */
     389             :     const ISM_MODE last_ism_mode, /* i/o: last ISM mode                       */
     390             :     UWord16 *nSamplesRendered,    /* o  : number of samples flushed when the renderer granularity changes */
     391             :     Word16 *data                  /* o  : output synthesis signal           Q0*/
     392             : )
     393             : {
     394             :     Word32 ivas_total_brate;
     395             :     ivas_error error;
     396             :     Word16 nchan_transport_old;
     397             : 
     398       92520 :     error = IVAS_ERR_OK;
     399       92520 :     move32();
     400       92520 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
     401       92520 :     move32();
     402             :     /* Assumes that num of input objects are constant */
     403       92520 :     nchan_transport_old = st_ivas->nchan_ism;
     404       92520 :     move16();
     405             : 
     406       92520 :     if ( EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
     407             :     {
     408       15768 :         nchan_transport_old = MAX_PARAM_ISM_WAVE;
     409       15768 :         move16();
     410             :     }
     411             : 
     412       92520 :     test();
     413       92520 :     test();
     414       92520 :     test();
     415       92520 :     IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && ( ivas_total_brate != FRAME_NO_DATA ) )
     416             :     {
     417             :         /* select ISM format mode */
     418       91989 :         st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_ism, ivas_total_brate );
     419       91989 :         move32();
     420       91989 :         st_ivas->nchan_transport = st_ivas->nchan_ism;
     421       91989 :         move16();
     422             : 
     423       91989 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     424             :         {
     425       15685 :             st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
     426       15685 :             move16();
     427       15685 :             if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     428             :             {
     429         513 :                 st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
     430         513 :                 move16();
     431             :             }
     432             :         }
     433             : 
     434       91989 :         IF( st_ivas->ini_active_frame != 0 )
     435             :         {
     436             :             /* ISM bit-rate switching */
     437       91921 :             test();
     438       91921 :             IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) )
     439             :             {
     440         988 :                 IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
     441             :                 {
     442           0 :                     return error;
     443             :                 }
     444             :             }
     445             :         }
     446             :     }
     447         531 :     ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
     448             :     {
     449         531 :         st_ivas->nchan_transport = st_ivas->nchan_ism;
     450         531 :         move16();
     451         531 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     452             :         {
     453          94 :             st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
     454          94 :             move16();
     455          94 :             if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     456             :             {
     457           7 :                 st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
     458           7 :                 move16();
     459             :             }
     460             :         }
     461             : 
     462             :         /* ISM mode switching */
     463         531 :         IF( NE_32( st_ivas->ism_mode, last_ism_mode ) )
     464             :         {
     465           6 :             IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
     466             :             {
     467           0 :                 return error;
     468             :             }
     469             :         }
     470             :     }
     471             : 
     472       92520 :     SWITCH( st_ivas->nchan_ism )
     473             :     {
     474       18984 :         case 1:
     475       18984 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM1;
     476       18984 :             move32();
     477       18984 :             BREAK;
     478       16093 :         case 2:
     479       16093 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM2;
     480       16093 :             move32();
     481       16093 :             BREAK;
     482       16285 :         case 3:
     483       16285 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM3;
     484       16285 :             move32();
     485       16285 :             BREAK;
     486       41158 :         case 4:
     487       41158 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM4;
     488       41158 :             move32();
     489       41158 :             BREAK;
     490           0 :         default:
     491           0 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
     492           0 :             move32();
     493           0 :             BREAK;
     494             :     }
     495       92520 :     return error;
     496             : }

Generated by: LCOV version 1.14