LCOV - code coverage report
Current view: top level - lib_dec - ivas_ism_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 175 211 82.9 %
Date: 2025-05-03 01:55:50 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        1013 : 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        1013 :     error = IVAS_ERR_OK;
      70        1013 :     move32();
      71        1013 :     nCPE_old = st_ivas->nCPE;
      72        1013 :     move16();
      73        1013 :     nSCE_old = st_ivas->nSCE;
      74        1013 :     move16();
      75             : 
      76             :     /* temporarily set the ism mode back to the old one, otherwise this can give wrong results*/
      77        1013 :     ism_mode = st_ivas->ism_mode;
      78        1013 :     move16();
      79        1013 :     st_ivas->ism_mode = last_ism_mode;
      80        1013 :     move16();
      81        1013 :     ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
      82        1013 :     st_ivas->ism_mode = ism_mode;
      83        1013 :     move16();
      84        1013 :     nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
      85             : 
      86        1013 :     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        1013 :     st_ivas->nSCE = st_ivas->nchan_transport;
      92        1013 :     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        1013 :     tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_e );
     102        1013 :     tmp = shr( tmp, sub( 15, tmp_e ) );
     103        1013 :     tmp_32 = L_deposit_l( tmp );
     104        1013 :     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        1013 :     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        1013 :     intern_config_old = st_ivas->intern_config;
     119        1013 :     move32();
     120        1013 :     hIntSetupOld = st_ivas->hIntSetup;
     121        1013 :     move32();
     122        1013 :     tc_granularity_new = 1;
     123        1013 :     move16();
     124        1013 :     renderer_type_old = st_ivas->renderer_type;
     125        1013 :     move32();
     126             : 
     127             :     /*-----------------------------------------------------------------*
     128             :      * Initialize the needed renderer struct and destroy the unnecessary renderer struct
     129             :      *-----------------------------------------------------------------*/
     130             : 
     131             :     /* select the renderer */
     132        1013 :     ivas_renderer_select( st_ivas );
     133             : 
     134        1013 :     ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
     135             : 
     136        1013 :     test();
     137        1013 :     IF( ( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) )
     138             :     {
     139          78 :         ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config );
     140             :     }
     141             : 
     142             :     {
     143        1013 :         test();
     144        1013 :         test();
     145        1013 :         test();
     146             :         /* transfer subframe info from DirAC or ParamMC to central tc buffer */
     147        1013 :         IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) )
     148             :         {
     149         207 :             st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
     150         207 :             move16();
     151         207 :             st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
     152         207 :             move16();
     153         207 :             st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
     154         207 :             move16();
     155         207 :             st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
     156         207 :             move16();
     157         207 :             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        1013 :         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        1013 :         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         921 :         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        1013 :     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        1013 :     test();
     193        1013 :     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 ) )
     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->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     214             :                 {
     215           0 :                     IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, 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->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
     239             :             {
     240           0 :                 return error;
     241             :             }
     242             : 
     243          92 :             st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
     244          92 :             move32();
     245             :         }
     246             :     }
     247             : 
     248             :     /* switching from Discrete ISM to ParamISM */
     249        1013 :     test();
     250        1013 :     IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_32( last_ism_mode, ISM_MODE_DISC ) )
     251             :     {
     252             :         /* Allocate and initialize the ParamISM struct */
     253         154 :         IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
     254             :         {
     255           0 :             return error;
     256             :         }
     257             : 
     258         154 :         test();
     259         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 ) )
     260             :         {
     261             :             /* open the parametric binaural renderer */
     262           0 :             IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     263             :             {
     264           0 :                 return error;
     265             :             }
     266             : 
     267           0 :             IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     268             :             {
     269           0 :                 return error;
     270             :             }
     271             : 
     272             :             /* Close the TD Binaural renderer */
     273           0 :             IF( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
     274             :             {
     275           0 :                 ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
     276           0 :                 st_ivas->hHrtfTD = NULL;
     277             : 
     278           0 :                 IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     279             :                 {
     280           0 :                     ivas_reverb_close( &st_ivas->hReverb );
     281             :                 }
     282             :             }
     283             :         }
     284             :         ELSE
     285             :         {
     286             :             /* Close the ISM renderer */
     287         154 :             ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
     288             :         }
     289             : 
     290         154 :         IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
     291             :         {
     292             :             /* open the parametric binaural renderer */
     293          92 :             IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     294             :             {
     295           0 :                 return error;
     296             :             }
     297             : 
     298          92 :             IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
     299             :             {
     300           0 :                 return error;
     301             :             }
     302             : 
     303             :             /* close the crend binaural renderer */
     304          92 :             ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) );
     305             :         }
     306             :     }
     307             : 
     308             :     /*-----------------------------------------------------------------*
     309             :      * CLDFB instances
     310             :      *-----------------------------------------------------------------*/
     311             : 
     312        1013 :     IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
     313             :     {
     314           0 :         return error;
     315             :     }
     316             : 
     317             :     /*-----------------------------------------------------------------*
     318             :      * floating-point output audio buffers
     319             :      *-----------------------------------------------------------------*/
     320             : 
     321             :     {
     322        1013 :         nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
     323             : 
     324        1013 :         IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
     325             :         {
     326           0 :             return error;
     327             :         }
     328             :     }
     329             : 
     330             :     /*-----------------------------------------------------------------*
     331             :      * JBM TC buffers
     332             :      *-----------------------------------------------------------------*/
     333             :     {
     334             :         Word16 tc_nchan_full_new;
     335             :         DECODER_TC_BUFFER_HANDLE hTcBuffer;
     336             : 
     337        1013 :         hTcBuffer = st_ivas->hTcBuffer;
     338        1013 :         tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
     339        1013 :         tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
     340        1013 :         tc_nchan_allocate_new = tc_nchan_tc_new;
     341        1013 :         move16();
     342        1013 :         tc_nchan_full_new = tc_nchan_tc_new;
     343        1013 :         move16();
     344             : 
     345        1013 :         test();
     346        1013 :         test();
     347        1013 :         IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
     348             :         {
     349         180 :             tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS;
     350         180 :             move16();
     351         180 :             tc_nchan_full_new = tc_nchan_allocate_new;
     352         180 :             move16();
     353             :         }
     354             : 
     355        1013 :         test();
     356        1013 :         test();
     357        1013 :         test();
     358        1013 :         test();
     359        1013 :         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 ) ) )
     360             :         {
     361          71 :             tc_nchan_full_new = 0;
     362          71 :             move16();
     363             :         }
     364             : 
     365             :         /* reconfigure buffer */
     366        1013 :         test();
     367        1013 :         test();
     368        1013 :         test();
     369        1013 :         IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
     370             :             NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) )
     371             :         {
     372         312 :             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 ) )
     373             :             {
     374           0 :                 return error;
     375             :             }
     376             :         }
     377             : 
     378             :         /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
     379        1013 :         IF( st_ivas->hSpatParamRendCom != NULL )
     380             :         {
     381         251 :             st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
     382         251 :             move16();
     383         251 :             st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
     384         251 :             move16();
     385         251 :             st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
     386         251 :             move16();
     387         251 :             st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
     388         251 :             move16();
     389             : 
     390         251 :             Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
     391             :         }
     392             :     }
     393             : 
     394        1013 :     return error;
     395             : }
     396             : 
     397             : /*-------------------------------------------------------------------------
     398             :  * ivas_ism_dec_config()
     399             :  *
     400             :  * - select ISM format mode
     401             :  * - reconfigure the ISM format decoder
     402             :  *-------------------------------------------------------------------------*/
     403             : 
     404       91501 : ivas_error ivas_ism_dec_config_fx(
     405             :     Decoder_Struct *st_ivas,      /* i/o: IVAS decoder structure              */
     406             :     const ISM_MODE last_ism_mode, /* i/o: last ISM mode                       */
     407             :     UWord16 *nSamplesRendered,    /* o  : number of samples flushed when the renderer granularity changes */
     408             :     Word16 *data                  /* o  : output synthesis signal           Q0*/
     409             : )
     410             : {
     411             :     Word32 ivas_total_brate;
     412             :     ivas_error error;
     413             :     Word16 nchan_transport_old;
     414             : 
     415       91501 :     error = IVAS_ERR_OK;
     416       91501 :     move32();
     417       91501 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
     418       91501 :     move32();
     419             :     /* Assumes that num of input objects are constant */
     420       91501 :     nchan_transport_old = st_ivas->nchan_ism;
     421       91501 :     move16();
     422             : 
     423       91501 :     if ( EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
     424             :     {
     425       15745 :         nchan_transport_old = MAX_PARAM_ISM_WAVE;
     426       15745 :         move16();
     427             :     }
     428             : 
     429       91501 :     test();
     430       91501 :     test();
     431       91501 :     test();
     432       91501 :     IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && ( ivas_total_brate != FRAME_NO_DATA ) )
     433             :     {
     434             :         /* select ISM format mode */
     435       90951 :         st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_ism, ivas_total_brate );
     436       90951 :         move32();
     437       90951 :         st_ivas->nchan_transport = st_ivas->nchan_ism;
     438       90951 :         move16();
     439             : 
     440       90951 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     441             :         {
     442       15649 :             st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
     443       15649 :             move16();
     444       15649 :             if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     445             :             {
     446         513 :                 st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
     447         513 :                 move16();
     448             :             }
     449             :         }
     450             : 
     451       90951 :         IF( st_ivas->ini_active_frame != 0 )
     452             :         {
     453             :             /* ISM bit-rate switching */
     454             :             {
     455       90884 :                 test();
     456       90884 :                 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 ) ) )
     457             :                 {
     458        1007 :                     IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered,
     459             :                                                                             data ) ),
     460             :                                IVAS_ERR_OK ) )
     461             :                     {
     462           0 :                         return error;
     463             :                     }
     464             :                 }
     465             :             }
     466             :         }
     467             :     }
     468         550 :     ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
     469             :     {
     470         550 :         st_ivas->nchan_transport = st_ivas->nchan_ism;
     471         550 :         move16();
     472         550 :         IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
     473             :         {
     474         107 :             st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
     475         107 :             move16();
     476         107 :             if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     477             :             {
     478           7 :                 st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
     479           7 :                 move16();
     480             :             }
     481             :         }
     482             : 
     483             :         /* ISM mode switching */
     484         550 :         IF( NE_32( st_ivas->ism_mode, last_ism_mode ) )
     485             :         {
     486           6 :             IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered,
     487             :                                                                     data ) ),
     488             :                        IVAS_ERR_OK ) )
     489             :             {
     490           0 :                 return error;
     491             :             }
     492             :         }
     493             :     }
     494             : 
     495       91501 :     SWITCH( st_ivas->nchan_ism )
     496             :     {
     497       18984 :         case 1:
     498       18984 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM1;
     499       18984 :             move32();
     500       18984 :             BREAK;
     501       16097 :         case 2:
     502       16097 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM2;
     503       16097 :             move32();
     504       16097 :             BREAK;
     505       16285 :         case 3:
     506       16285 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM3;
     507       16285 :             move32();
     508       16285 :             BREAK;
     509       40135 :         case 4:
     510       40135 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM4;
     511       40135 :             move32();
     512       40135 :             BREAK;
     513           0 :         default:
     514           0 :             st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
     515           0 :             move32();
     516           0 :             BREAK;
     517             :     }
     518       91501 :     return error;
     519             : }

Generated by: LCOV version 1.14