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

Generated by: LCOV version 1.14