LCOV - code coverage report
Current view: top level - lib_dec - ivas_ism_param_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 633e3f2e309758d10805ef21e0436356fe719b7a Lines: 811 867 93.5 %
Date: 2025-08-23 01:22:27 Functions: 17 17 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 <assert.h>
      35             : #include <math.h>
      36             : #include "options.h"
      37             : #include "ivas_prot_rend_fx.h"
      38             : #include "prot_fx.h"
      39             : #include "rom_com.h"
      40             : #include "ivas_rom_com.h"
      41             : #include "ivas_rom_dec.h"
      42             : #include "wmc_auto.h"
      43             : #include "ivas_prot_fx.h"
      44             : #include "debug.h"
      45             : #include "ivas_rom_com_fx.h"
      46             : 
      47             : /*-----------------------------------------------------------------------*
      48             :  * Local function definitions
      49             :  *-----------------------------------------------------------------------*/
      50             : 
      51       12884 : static void ivas_param_ism_dec_dequant_DOA_fx(
      52             :     PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle         */
      53             :     const Word16 nchan_ism             /* i  : number of ISM channels       */
      54             : )
      55             : {
      56             :     Word16 i;
      57             :     PARAM_ISM_CONFIG_HANDLE hParamIsm;
      58             : 
      59       12884 :     hParamIsm = hParamIsmDec->hParamIsm;
      60             : 
      61       12884 :     assert( nchan_ism <= MAX_NUM_OBJECTS );
      62             : 
      63             :     /* Get the azimuth and elevation values */
      64       60669 :     FOR( i = 0; i < nchan_ism; i++ )
      65             :     {
      66       47785 :         hParamIsmDec->azimuth_values_fx[i] = ism_dequant_meta_fx( hParamIsm->azi_index[i], ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS ); // Q22
      67       47785 :         move16();
      68       47785 :         hParamIsmDec->elevation_values_fx[i] = ism_dequant_meta_fx( hParamIsm->ele_index[i], ism_elevation_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_ELEVATION_NBITS ); // Q22
      69       47785 :         move16();
      70             :     }
      71             : 
      72       12884 :     return;
      73             : }
      74             : 
      75       12884 : static void ivas_param_ism_dec_dequant_powrat_fx(
      76             :     PARAM_ISM_DEC_HANDLE hParamIsmDec /* i/o: decoder ParamISM handle         */
      77             : )
      78             : {
      79             :     Word16 band_idx, slot_idx;
      80             :     PARAM_ISM_CONFIG_HANDLE hParamIsm;
      81             : 
      82       12884 :     hParamIsm = hParamIsmDec->hParamIsm;
      83             :     /* Get the power ratio values */
      84      154608 :     FOR( band_idx = 0; band_idx < hParamIsm->nbands; band_idx++ )
      85             :     {
      86      283448 :         FOR( slot_idx = 0; slot_idx < hParamIsm->nblocks[band_idx]; slot_idx++ )
      87             :         {
      88      141724 :             hParamIsmDec->power_ratios_fx[band_idx][slot_idx][0] = add( shr( imult1616( hParamIsm->power_ratios_idx[band_idx][slot_idx], 4681 /* ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) in Q15 */ ), 1 ), 16384 /*.5f in Q15 */ ); /* Q15 */
      89      141724 :             move16();
      90      141724 :             hParamIsmDec->power_ratios_fx[band_idx][slot_idx][1] = sub( 32767, hParamIsmDec->power_ratios_fx[band_idx][slot_idx][0] ); // Q15 , 32767= (1.0f in Q15) -1
      91      141724 :             move16();
      92             :         }
      93             :     }
      94       12884 :     return;
      95             : }
      96             : 
      97             : 
      98         166 : static void ivas_ism_get_interpolator_fx(
      99             :     const Word16 subframe_nbslots,
     100             :     Word16 *interpolator /*Q15*/
     101             : )
     102             : {
     103             :     Word16 interp_idx, q_tmp, tmp;
     104             : 
     105        4038 :     FOR( interp_idx = 0; interp_idx < subframe_nbslots; interp_idx++ )
     106             :     {
     107        3872 :         tmp = BASOP_Util_Divide1616_Scale( add( interp_idx, 1 ), subframe_nbslots, &q_tmp ); /*Q = 15 - q_tmp*/
     108        3872 :         interpolator[interp_idx] = shl_sat( tmp, q_tmp );                                    /* Q15 */
     109        3872 :         move16();
     110             :     }
     111             : 
     112         166 :     return;
     113             : }
     114             : 
     115             : 
     116          21 : static void ivas_ism_get_proto_matrix_fx(
     117             :     IVAS_OUTPUT_SETUP hOutSetup,
     118             :     const Word16 nchan_transport,
     119             :     Word16 *proto_matrix /*Q15*/
     120             : )
     121             : {
     122             :     Word16 idx;
     123             : 
     124             :     /* compute proto_matrix */
     125          21 :     SWITCH( nchan_transport )
     126             :     {
     127          21 :         case 2:
     128             :         {
     129          21 :             IF( hOutSetup.nchan_out_woLFE )
     130             :             {
     131         248 :                 FOR( idx = 0; idx < hOutSetup.nchan_out_woLFE; idx++ )
     132             :                 {
     133         227 :                     IF( hOutSetup.ls_azimuth_fx[idx] > 0 )
     134             :                     {
     135         103 :                         proto_matrix[idx] = 32767; /* 1.0f in Q15 */
     136         103 :                         move16();
     137         103 :                         proto_matrix[idx + hOutSetup.nchan_out_woLFE] = 0;
     138         103 :                         move16();
     139             :                     }
     140         124 :                     ELSE IF( hOutSetup.ls_azimuth_fx[idx] < 0 )
     141             :                     {
     142         103 :                         proto_matrix[idx] = 0;
     143         103 :                         move16();
     144         103 :                         proto_matrix[idx + hOutSetup.nchan_out_woLFE] = 32767; /* 1.0f in Q15 */
     145         103 :                         move16();
     146             :                     }
     147             :                     ELSE
     148             :                     {
     149          21 :                         proto_matrix[idx] = ONE_IN_Q14; /* 0.5 -> Q15*/
     150          21 :                         move16();
     151          21 :                         proto_matrix[idx + hOutSetup.nchan_out_woLFE] = ONE_IN_Q14; /* 0.5 -> Q15*/
     152          21 :                         move16();
     153             :                     }
     154             :                 }
     155             :             }
     156             :             ELSE
     157             :             {
     158           0 :                 assert( 0 && "Error: number of output channels not supported" );
     159             :             }
     160          21 :             BREAK;
     161             :         }
     162             : 
     163           0 :         default:
     164           0 :             assert( 0 && "Error: number of transport channels not supported" );
     165             :     }
     166             : 
     167          21 :     return;
     168             : }
     169             : 
     170      168096 : static void ivas_param_ism_collect_slot_fx(
     171             :     PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */
     172             :     Word32 *Cldfb_RealBuffer_in_fx,    /*Q(31-exp_real)*/
     173             :     Word16 exp_real,
     174             :     Word32 *Cldfb_ImagBuffer_in_fx, /*Q(31-exp_imag)*/
     175             :     Word16 exp_imag,
     176             :     const Word16 ch,
     177             :     Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-exp_cx_diag)*/
     178             :     Word16 exp_cx_diag[][PARAM_ISM_MAX_DMX] )
     179             : {
     180             :     Word16 band_idx, bin_idx;
     181             :     Word16 brange[2];
     182             :     Word32 tmp_fx;
     183             :     Word16 exp_tmp;
     184             : 
     185             :     /* loop over parameter bands to collect transport channel energies */
     186             : 
     187     2017152 :     FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
     188             :     {
     189     1849056 :         brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
     190     1849056 :         move16();
     191     1849056 :         brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
     192     1849056 :         move16();
     193    11934816 :         FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
     194             :         {
     195    10085760 :             tmp_fx = 0;
     196    10085760 :             move32();
     197    10085760 :             exp_tmp = 0;
     198    10085760 :             move16();
     199    10085760 :             Word32 var1 = Mpy_32_32( Cldfb_RealBuffer_in_fx[bin_idx], Cldfb_RealBuffer_in_fx[bin_idx] ); // Q(31-2 * exp_real)
     200    10085760 :             Word32 var2 = Mpy_32_32( Cldfb_ImagBuffer_in_fx[bin_idx], Cldfb_ImagBuffer_in_fx[bin_idx] ); // Q(31-2 * exp_imag)
     201    10085760 :             tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var1, add( exp_real, exp_real ), &exp_tmp );
     202    10085760 :             tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var2, add( exp_imag, exp_imag ), &exp_tmp );
     203             : 
     204             :             Word16 exp_cx_diag_new;
     205    10085760 :             move16();
     206    10085760 :             move16();
     207    10085760 :             cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new );
     208    10085760 :             move32();
     209    10085760 :             exp_cx_diag[bin_idx][ch] = exp_cx_diag_new;
     210    10085760 :             move16();
     211             :         }
     212             :     }
     213      168096 :     return;
     214             : }
     215             : 
     216        5253 : static void ivas_param_ism_compute_mixing_matrix_fx(
     217             :     const Word16 nchan_ism,                                         /* i  : number of ISM channels       */
     218             :     PARAM_ISM_DEC_HANDLE hParamIsmDec,                              /* i/o: decoder ParamISM handle */
     219             :     ISM_DTX_DATA_DEC hISMDTX,                                       /* i  : ISM DTX handle                */
     220             :     Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], // Q30
     221             :     const Word16 nchan_transport,
     222             :     const Word16 nchan_out_woLFE,
     223             :     Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-cx_diag_e)*/
     224             :     Word16 cx_diag_e[][PARAM_ISM_MAX_DMX],
     225             :     Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_e)*/
     226             :     Word16 mixing_matrix_e[CLDFB_NO_CHANNELS_MAX] )
     227             : {
     228             :     Word16 band_idx, bin_idx;
     229             :     Word16 i, w, obj_indx;
     230             :     Word16 brange[2];
     231             :     Word32 direct_power_fx[MAX_NUM_OBJECTS];
     232             :     Word32 cy_diag_fx[PARAM_ISM_MAX_CHAN];
     233             :     Word32 cy_diag_tmp_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN];
     234             :     Word32 *dir_res_ptr_fx;
     235             :     Word16 *proto_matrix_fx;
     236             :     Word32 response_matrix_fx[PARAM_ISM_MAX_CHAN * MAX_NUM_OBJECTS];
     237             :     Word16 num_wave;
     238             :     Word16 dir_res_ptr_e, cy_diag_e, cy_diag_e_arr[PARAM_ISM_MAX_CHAN], cy_diag_tmp_e[MAX_NUM_OBJECTS], response_matrix_e, direct_power_e, temp_e[PARAM_ISM_MAX_CHAN];
     239             : 
     240        5253 :     proto_matrix_fx = hParamIsmDec->hParamIsmRendering->proto_matrix_fx;
     241             : 
     242        5253 :     assert( ( nchan_ism == 3 ) || ( nchan_ism == 4 ) );
     243        5253 :     assert( nchan_transport == 2 );
     244             : 
     245        5253 :     test();
     246        5253 :     IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
     247             :     {
     248          60 :         num_wave = nchan_ism;
     249          60 :         move16();
     250             :     }
     251             :     ELSE
     252             :     {
     253        5193 :         num_wave = MAX_PARAM_ISM_WAVE;
     254        5193 :         move16();
     255             :     }
     256        5253 :     set32_fx( response_matrix_fx, 0, PARAM_ISM_MAX_CHAN * MAX_NUM_OBJECTS );
     257        5253 :     response_matrix_e = 0;
     258        5253 :     move16();
     259             : 
     260             :     /* loop over parameter bands to compute the mixing matrix */
     261       63036 :     FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
     262             :     {
     263       57783 :         brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
     264       57783 :         move16();
     265       57783 :         brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
     266       57783 :         move16();
     267             : 
     268             :         /* Compute covaraince matrix from direct response*/
     269      174669 :         FOR( w = 0; w < num_wave; w++ )
     270             :         {
     271      116886 :             set32_fx( cy_diag_tmp_fx[w], 0, nchan_out_woLFE );
     272      116886 :             test();
     273      116886 :             IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
     274             :             {
     275        2640 :                 dir_res_ptr_fx = direct_response_fx[w];
     276             :             }
     277             :             ELSE
     278             :             {
     279      114246 :                 obj_indx = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][w];
     280      114246 :                 move16();
     281      114246 :                 dir_res_ptr_fx = direct_response_fx[obj_indx];
     282             :             }
     283      116886 :             Copy32( dir_res_ptr_fx, response_matrix_fx + w * nchan_out_woLFE, nchan_out_woLFE ); // Q30
     284      116886 :             dir_res_ptr_e = 1;
     285      116886 :             move16();
     286      116886 :             response_matrix_e = 1;
     287      116886 :             move16();
     288             :             /* we only need the diagonal of Cy*/
     289      116886 :             matrix_product_diag_fx( dir_res_ptr_fx, dir_res_ptr_e, nchan_out_woLFE, 1, 0, dir_res_ptr_fx, dir_res_ptr_e, 1, nchan_out_woLFE, 0, cy_diag_tmp_fx[w], &cy_diag_tmp_e[w] );
     290             :         }
     291             : 
     292      372963 :         FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
     293             :         {
     294             : 
     295      315180 :             set32_fx( cy_diag_fx, 0, nchan_out_woLFE );
     296      315180 :             set16_fx( cy_diag_e_arr, 0, nchan_out_woLFE );
     297             : 
     298             :             /* equal cx diag exponents, compute ref power from cx_diag*/
     299             :             Word16 max_exp_cx_diag;
     300             :             Word32 cx_diag_eq_exp_fx[PARAM_ISM_MAX_DMX];
     301             :             Word32 ref_power_fx;
     302             :             Word16 ref_power_e, ref_power_e_new;
     303      315180 :             ref_power_fx = cx_diag_fx[bin_idx][0];
     304      315180 :             ref_power_e = cx_diag_e[bin_idx][0];
     305             : 
     306      630360 :             FOR( i = 1; i < PARAM_ISM_MAX_DMX; i++ )
     307             :             {
     308      315180 :                 ref_power_fx = BASOP_Util_Add_Mant32Exp( ref_power_fx, ref_power_e, cx_diag_fx[bin_idx][i], cx_diag_e[bin_idx][i], &ref_power_e_new );
     309      315180 :                 ref_power_e = ref_power_e_new;
     310             :             }
     311      315180 :             max_exp_cx_diag = ref_power_e;
     312      945540 :             FOR( i = 0; i < PARAM_ISM_MAX_DMX; i++ )
     313             :             {
     314      630360 :                 cx_diag_eq_exp_fx[i] = L_shr_r( cx_diag_fx[bin_idx][i], sub( max_exp_cx_diag, cx_diag_e[bin_idx][i] ) ); // Q(31-max_exp_cx_diag)
     315             :             }
     316             : 
     317             : 
     318      952740 :             FOR( w = 0; w < num_wave; w++ )
     319             :             {
     320      637560 :                 test();
     321      637560 :                 IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
     322             :                 {
     323             :                     // direct_power[w] = ( 1.0f / nchan_ism ) * ref_power[bin_idx];
     324       14400 :                     SWITCH( nchan_ism )
     325             :                     {
     326           0 :                         case 2:
     327           0 :                             direct_power_fx[w] = L_shr_r( ref_power_fx, 1 );
     328           0 :                             move32();
     329           0 :                             BREAK;
     330           0 :                         case 3:
     331           0 :                             direct_power_fx[w] = Mpy_32_16_1( ref_power_fx, 10923 ); // 10923 = 1/3f in Q15
     332           0 :                             move32();
     333           0 :                             BREAK;
     334       14400 :                         case 4:
     335       14400 :                             direct_power_fx[w] = L_shr_r( ref_power_fx, 2 );
     336       14400 :                             move32();
     337       14400 :                             BREAK;
     338             :                     }
     339       14400 :                 }
     340             :                 ELSE
     341             :                 {
     342      623160 :                     direct_power_fx[w] = Mpy_32_16_1( ref_power_fx, hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx])
     343      623160 :                     move32();
     344             :                 }
     345             :                 // direct_power_e = ref_power_e[bin_idx];
     346      637560 :                 direct_power_e = ref_power_e;
     347      637560 :                 move16();
     348      637560 :                 IF( direct_power_fx[w] != 0 )
     349             :                 {
     350     5440513 :                     FOR( i = 0; i < nchan_out_woLFE; i++ )
     351             :                     {
     352     4904294 :                         cy_diag_fx[i] = BASOP_Util_Add_Mant32Exp( cy_diag_fx[i], cy_diag_e_arr[i], Mpy_32_32( direct_power_fx[w], cy_diag_tmp_fx[w][i] ), add( direct_power_e, cy_diag_tmp_e[w] ), &cy_diag_e_arr[i] );
     353     4904294 :                         move32();
     354             :                     }
     355             :                 }
     356      637560 :                 temp_e[w] = direct_power_e;
     357      637560 :                 move16();
     358      637560 :                 direct_power_fx[w] = Sqrt32( direct_power_fx[w], &temp_e[w] );
     359      637560 :                 move32();
     360             :             }
     361      315180 :             cy_diag_e = cy_diag_e_arr[0];
     362      315180 :             move16();
     363     2878920 :             FOR( i = 1; i < nchan_out_woLFE; i++ )
     364             :             {
     365     2563740 :                 cy_diag_e = s_max( cy_diag_e, cy_diag_e_arr[i] );
     366             :             }
     367     3194100 :             FOR( i = 0; i < nchan_out_woLFE; i++ )
     368             :             {
     369     2878920 :                 cy_diag_fx[i] = L_shr_r( cy_diag_fx[i], sub( cy_diag_e, cy_diag_e_arr[i] ) ); // cy_diag_e
     370     2878920 :                 move32();
     371             :             }
     372             : 
     373      315180 :             direct_power_e = temp_e[0];
     374      315180 :             move16();
     375      637560 :             FOR( w = 1; w < num_wave; w++ )
     376             :             {
     377      322380 :                 direct_power_e = s_max( direct_power_e, temp_e[w] );
     378             :             }
     379      952740 :             FOR( w = 0; w < num_wave; w++ )
     380             :             {
     381      637560 :                 direct_power_fx[w] = L_shr_r( direct_power_fx[w], sub( direct_power_e, temp_e[w] ) ); // diract_power_e
     382      637560 :                 move32();
     383             :             }
     384             : 
     385             :             /* Compute mixing matrix */
     386      315180 :             computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_eq_exp_fx, max_exp_cx_diag, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1,
     387      315180 :                                          PARAM_MC_REG_SX_FX, PARAM_MC_REG_GHAT_FX, mixing_matrix_fx[bin_idx], &mixing_matrix_e[bin_idx] );
     388             :         }
     389             :     }
     390             : 
     391        5253 :     return;
     392             : }
     393             : 
     394       84048 : static void ivas_param_ism_render_slot_fx(
     395             :     PARAM_ISM_DEC_HANDLE hParamIsmDec,
     396             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom,
     397             :     Word32 *Cldfb_RealBuffer_in_fx[PARAM_ISM_MAX_DMX],                                                  /*Q11 (31-Cldfb_RealBuffer_tc_exp)*/
     398             :     Word32 *Cldfb_ImagBuffer_in_fx[PARAM_ISM_MAX_DMX],                                                  /*Q11 (31-Cldfb_ImagBuffer_tc_exp)*/
     399             :     Word32 Cldfb_RealBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q(31-exp_real)*/
     400             :     Word32 Cldfb_ImagBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q(31-exp_imag)*/
     401             :     Word16 *exp_real,
     402             :     Word16 *exp_imag,
     403             :     Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-exp_mixing_matrix_lin_fx)*/
     404             :     const Word16 interpolator_idx,
     405             :     const Word16 out_slot_idx,
     406             :     const Word16 num_ch_LS,
     407             :     const Word16 nchan_transport )
     408             : {
     409             :     Word16 outchIdx, inchIdx, bin_idx;
     410             :     Word32 tmp_1_fx, mixing_matrix_smooth_fx;
     411             : 
     412       84048 :     tmp_1_fx = L_deposit_h( hParamIsmDec->hParamIsmRendering->interpolator_fx[interpolator_idx] ); /* Q31 */
     413             : 
     414       84048 :     Word16 res_exp = 0;
     415       84048 :     move16();
     416       84048 :     Word16 real_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp;
     417       84048 :     move16();
     418       84048 :     Word16 imag_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp;
     419       84048 :     move16();
     420             :     Word16 i, j, k;
     421             : 
     422             :     /*exponent buffers to handle variable exp*/
     423             :     Word16 exp_buf_real[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
     424             :     Word16 exp_buf_imag[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
     425     1428816 :     FOR( i = 0; i < PARAM_ISM_MAX_CHAN; i++ )
     426             :     {
     427     6723840 :         FOR( j = 0; j < JBM_CLDFB_SLOTS_IN_SUBFRAME; j++ )
     428             :         {
     429   328123392 :             FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ )
     430             :             {
     431   322744320 :                 exp_buf_real[i][j][k] = 0;
     432   322744320 :                 move16();
     433   322744320 :                 exp_buf_imag[i][j][k] = 0;
     434   322744320 :                 move16();
     435             :             }
     436             :         }
     437             :     }
     438     5126928 :     FOR( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
     439             :     {
     440             :         /* smooth the mixing matrix */
     441    51105600 :         FOR( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ )
     442             :         {
     443   138188160 :             FOR( inchIdx = 0; inchIdx < nchan_transport; inchIdx++ )
     444             :             {
     445    92125440 :                 Word32 tmp_2 = Mpy_32_32( tmp_1_fx, mixing_matrix_fx[bin_idx][outchIdx + inchIdx * num_ch_LS] );                                                                // hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin
     446    92125440 :                 Word32 tmp_3 = Mpy_32_32( L_sub( ONE_IN_Q31, tmp_1_fx ), hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_old_fx[bin_idx][outchIdx + inchIdx * num_ch_LS] ); // 1 + hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_old
     447    92125440 :                 mixing_matrix_smooth_fx = BASOP_Util_Add_Mant32Exp( tmp_2, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx[bin_idx], tmp_3, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_old_fx[bin_idx], &res_exp );
     448             : 
     449    92125440 :                 Word32 tmp_4 = Mpy_32_32( mixing_matrix_smooth_fx, Cldfb_RealBuffer_in_fx[inchIdx][bin_idx] ); // Q(31-(res_exp + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp))
     450    92125440 :                 Word32 tmp_5 = Mpy_32_32( mixing_matrix_smooth_fx, Cldfb_ImagBuffer_in_fx[inchIdx][bin_idx] ); // Q(31-(res_exp + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp))
     451             : 
     452   184250880 :                 Cldfb_RealBuffer_fx[outchIdx][out_slot_idx][bin_idx] = BASOP_Util_Add_Mant32Exp( Cldfb_RealBuffer_fx[outchIdx][out_slot_idx][bin_idx], real_buf_exp,
     453    92125440 :                                                                                                  tmp_4, res_exp + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp, &real_buf_exp );
     454    92125440 :                 move32();
     455   184250880 :                 Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx] = BASOP_Util_Add_Mant32Exp( Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx], imag_buf_exp,
     456    92125440 :                                                                                                  tmp_5, res_exp + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp, &imag_buf_exp );
     457    92125440 :                 move32();
     458    92125440 :                 exp_buf_real[outchIdx][out_slot_idx][bin_idx] = real_buf_exp;
     459    92125440 :                 move16();
     460    92125440 :                 exp_buf_imag[outchIdx][out_slot_idx][bin_idx] = imag_buf_exp;
     461    92125440 :                 move16();
     462             :             }
     463             :         }
     464             :     }
     465             : 
     466             :     /*Make same exponent for whole buffer*/
     467       84048 :     Word16 max_exp_real = MIN_16;
     468       84048 :     move16();
     469       84048 :     Word16 max_exp_imag = MIN_16;
     470       84048 :     move16();
     471     5126928 :     FOR( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
     472             :     {
     473    51105600 :         FOR( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ )
     474             :         {
     475    46062720 :             max_exp_real = s_max( max_exp_real, exp_buf_real[outchIdx][out_slot_idx][bin_idx] );
     476    46062720 :             max_exp_imag = s_max( max_exp_imag, exp_buf_imag[outchIdx][out_slot_idx][bin_idx] );
     477             :         }
     478             :     }
     479             : 
     480     5126928 :     FOR( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
     481             :     {
     482    51105600 :         FOR( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ )
     483             :         {
     484    46062720 :             Cldfb_RealBuffer_fx[outchIdx][out_slot_idx][bin_idx] = L_shr( Cldfb_RealBuffer_fx[outchIdx][out_slot_idx][bin_idx], sub( max_exp_real, exp_buf_real[outchIdx][out_slot_idx][bin_idx] ) ); // Q(31-(max_exp_real))
     485    46062720 :             move32();
     486    46062720 :             Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx] = L_shr( Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx], sub( max_exp_imag, exp_buf_imag[outchIdx][out_slot_idx][bin_idx] ) ); // Q(31-(max_exp_imag))
     487    46062720 :             move32();
     488             :         }
     489             :     }
     490             : 
     491       84048 :     *exp_real = max_exp_real;
     492       84048 :     move16();
     493       84048 :     *exp_imag = max_exp_imag;
     494       84048 :     move16();
     495             : 
     496       84048 :     return;
     497             : }
     498             : 
     499             : 
     500         166 : static ivas_error ivas_param_ism_rendering_init_fx(
     501             :     PARAM_ISM_RENDERING_HANDLE hParamIsmRendering,
     502             :     IVAS_OUTPUT_SETUP hOutSetup,
     503             :     const Word16 nchan_transport,
     504             :     const Word16 subframe_nbslots,
     505             :     AUDIO_CONFIG output_config )
     506             : {
     507             :     Word16 bin_idx;
     508             : 
     509             :     /* initialization of mixing matrix buffer for smoothing */
     510       10126 :     FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ )
     511             :     {
     512        9960 :         set32_fx( hParamIsmRendering->mixing_matrix_lin_old_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX );
     513             :     }
     514         166 :     set16_fx( hParamIsmRendering->exp_mixing_matrix_lin_old_fx, 0, CLDFB_NO_CHANNELS_MAX );
     515             : 
     516             :     /* memory allocation for proto matrix and interpolator */
     517         166 :     IF( ( hParamIsmRendering->proto_matrix_fx = (Word16 *) malloc( hOutSetup.nchan_out_woLFE * nchan_transport * sizeof( Word16 ) ) ) == NULL )
     518             :     {
     519           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for proto matrix\n" ) );
     520             :     }
     521             : 
     522             : 
     523         166 :     IF( ( hParamIsmRendering->interpolator_fx = (Word16 *) malloc( subframe_nbslots * sizeof( Word16 ) ) ) == NULL )
     524             :     {
     525           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) );
     526             :     }
     527         166 :     test();
     528         166 :     test();
     529         166 :     test();
     530         166 :     IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
     531             :     {
     532             :         /* computation of proto matrix */
     533          21 :         ivas_ism_get_proto_matrix_fx( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix_fx );
     534             :     }
     535             : 
     536             :     /* computation of interpolator*/
     537         166 :     ivas_ism_get_interpolator_fx( subframe_nbslots, hParamIsmRendering->interpolator_fx );
     538             : 
     539         166 :     return IVAS_ERR_OK;
     540             : }
     541             : 
     542        5253 : static void ivas_param_ism_update_mixing_matrix_fx(
     543             :     PARAM_ISM_DEC_HANDLE hParamIsmDec,
     544             :     Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_exp)*/
     545             :     Word16 mixing_matrix_exp[CLDFB_NO_CHANNELS_MAX],
     546             :     const Word16 nchan_in,
     547             :     const Word16 nchan_out )
     548             : {
     549             :     Word16 inchIdx, outchIdx, bin_idx, band_idx;
     550             :     Word16 brange[2];
     551             : 
     552       63036 :     FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
     553             :     {
     554       57783 :         brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
     555       57783 :         move16();
     556       57783 :         brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
     557       57783 :         move16();
     558             : 
     559      372963 :         FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
     560             :         {
     561      945540 :             FOR( inchIdx = 0; inchIdx < nchan_in; inchIdx++ )
     562             :             {
     563     6388200 :                 FOR( outchIdx = 0; outchIdx < nchan_out; outchIdx++ )
     564             :                 {
     565     5757840 :                     hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_old_fx[bin_idx][outchIdx + inchIdx * nchan_out] = mixing_matrix_fx[bin_idx][outchIdx + inchIdx * nchan_out];
     566     5757840 :                     move32();
     567             :                 }
     568             :             }
     569             :         }
     570             :     }
     571             : 
     572        5253 :     Copy( mixing_matrix_exp, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_old_fx, CLDFB_NO_CHANNELS_MAX );
     573             : 
     574        5253 :     return;
     575             : }
     576             : 
     577             : 
     578             : /*-------------------------------------------------------------------------*
     579             :  * ivas_param_ism_dec_open()
     580             :  *
     581             :  * Open Param ISM handle
     582             :  *-------------------------------------------------------------------------*/
     583         168 : ivas_error ivas_param_ism_dec_open_fx(
     584             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     585             : )
     586             : {
     587             :     Word16 i;
     588             :     PARAM_ISM_DEC_HANDLE hParamIsmDec;
     589             :     IVAS_OUTPUT_SETUP hOutSetup;
     590             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
     591             :     AUDIO_CONFIG output_config;
     592             :     Word32 output_Fs;
     593             :     ivas_error error;
     594             : 
     595         168 :     error = IVAS_ERR_OK;
     596         168 :     move32();
     597         168 :     push_wmops( "ivas_param_ism_dec_open" );
     598             : 
     599             :     /*-----------------------------------------------------------------*
     600             :      * prepare library opening
     601             :      *-----------------------------------------------------------------*/
     602             : 
     603         168 :     IF( ( hParamIsmDec = (PARAM_ISM_DEC_HANDLE) malloc( sizeof( PARAM_ISM_DEC_DATA ) ) ) == NULL )
     604             :     {
     605           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM\n" ) );
     606             :     }
     607             : 
     608         168 :     IF( ( hSpatParamRendCom = (SPAT_PARAM_REND_COMMON_DATA_HANDLE) malloc( sizeof( SPAT_PARAM_REND_COMMON_DATA ) ) ) == NULL )
     609             :     {
     610           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) );
     611             :     }
     612             : 
     613             :     /* Assign memory to Param Object handle */
     614         168 :     IF( ( hParamIsmDec->hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL )
     615             :     {
     616           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM\n" ) );
     617             :     }
     618             : 
     619         168 :     IF( ( hParamIsmDec->hParamIsmRendering = (PARAM_ISM_RENDERING_HANDLE) malloc( sizeof( PARAM_ISM_RENDERING_DATA ) ) ) == NULL )
     620             :     {
     621           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM Rendering handle\n" ) );
     622             :     }
     623             : 
     624         168 :     output_Fs = st_ivas->hDecoderConfig->output_Fs;
     625         168 :     move32();
     626         168 :     output_config = st_ivas->hDecoderConfig->output_config;
     627         168 :     move32();
     628         168 :     ivas_param_ism_config_fx( hParamIsmDec->hParamIsm, st_ivas->nchan_ism ); // assuming Q14 for gains;
     629             : 
     630             :     /*-----------------------------------------------------------------*
     631             :      * set input parameters
     632             :      *-----------------------------------------------------------------*/
     633             : 
     634             :     /* hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); */
     635         168 :     hSpatParamRendCom->slot_size = extract_l( L_shr( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ), 4 ) );
     636         168 :     move16();
     637         168 :     set16_fx( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
     638         168 :     set16_fx( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS );
     639         168 :     hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS;
     640         168 :     move16();
     641         168 :     hSpatParamRendCom->subframes_rendered = 0;
     642         168 :     move16();
     643         168 :     hSpatParamRendCom->slots_rendered = 0;
     644         168 :     move16();
     645         168 :     hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
     646         168 :     move16();
     647             :     /* hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); */
     648         168 :     hSpatParamRendCom->num_freq_bands = extract_l( Mpy_32_32( output_Fs, 2684355 /* INV_CLDFB_BANDWIDTH in Q31 */ ) );
     649         168 :     move16();
     650             : 
     651         168 :     hParamIsmDec->hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
     652         168 :     move16();
     653             : 
     654        2184 :     FOR( i = 0; i < ( hParamIsmDec->hParamIsm->nbands + 1 ); i++ )
     655             :     {
     656        2016 :         hParamIsmDec->hParamIsm->band_grouping[i] = Param_ISM_band_grouping[i];
     657        2016 :         move16();
     658             : 
     659        2016 :         IF( GT_16( hParamIsmDec->hParamIsm->band_grouping[i], hSpatParamRendCom->num_freq_bands ) )
     660             :         {
     661          75 :             hParamIsmDec->hParamIsm->band_grouping[i] = hSpatParamRendCom->num_freq_bands;
     662          75 :             move16();
     663             :         }
     664             :     }
     665             : 
     666             :     /*-----------------------------------------------------------------*
     667             :      * output setup
     668             :      *-----------------------------------------------------------------*/
     669             : 
     670             :     /* hIntSetup and hOutSetup differs only for Binaural rendering */
     671         168 :     IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
     672             :     {
     673             :         /* nchan_out is essential for memory initialization for CLDFB Synthesis */
     674          47 :         st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->nchan_ism;
     675          47 :         move16();
     676          47 :         st_ivas->hIntSetup.is_loudspeaker_setup = 1;
     677          47 :         move16();
     678             :     }
     679             : 
     680         168 :     hOutSetup = st_ivas->hIntSetup;
     681             : 
     682         168 :     test();
     683         168 :     IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
     684             :     {
     685             :         /* Initialize Param ISM Rendering handle */
     686         166 :         IF( st_ivas->hDecoderConfig->Opt_tsm )
     687             :         {
     688          76 :             IF( NE_32( ( error = ivas_param_ism_rendering_init_fx( hParamIsmDec->hParamIsmRendering, hOutSetup, st_ivas->nchan_transport, MAX_JBM_CLDFB_TIMESLOTS, output_config ) ), IVAS_ERR_OK ) )
     689             :             {
     690           0 :                 return error;
     691             :             }
     692             :         }
     693             :         ELSE
     694             :         {
     695          90 :             IF( NE_32( ( error = ivas_param_ism_rendering_init_fx( hParamIsmDec->hParamIsmRendering, hOutSetup, st_ivas->nchan_transport, CLDFB_NO_COL_MAX, output_config ) ), IVAS_ERR_OK ) )
     696             :             {
     697           0 :                 return error;
     698             :             }
     699             :         }
     700             :     }
     701             : 
     702         168 :     test();
     703         168 :     test();
     704         168 :     test();
     705         168 :     test();
     706         168 :     test();
     707         168 :     IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ||
     708             :            EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
     709             :     {
     710             :         /* Initialize efap handle */
     711          21 :         IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
     712             :         {
     713           0 :             return error;
     714             :         }
     715             :     }
     716             : 
     717             :     /* Azi and Ele values are transmitted once per frame per object */
     718             : 
     719         168 :     set32_fx( hParamIsmDec->azimuth_values_fx, 0, MAX_NUM_OBJECTS );
     720         168 :     set32_fx( hParamIsmDec->elevation_values_fx, 0, MAX_NUM_OBJECTS );
     721             : 
     722         168 :     hSpatParamRendCom->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES;
     723         168 :     move16();
     724         168 :     hSpatParamRendCom->dirac_bs_md_write_idx = 0;
     725         168 :     move16();
     726         168 :     hSpatParamRendCom->dirac_read_idx = 0;
     727         168 :     move16();
     728             : 
     729         168 :     test();
     730         168 :     test();
     731         168 :     IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
     732             :     {
     733          98 :         IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ), IVAS_ERR_OK ) )
     734             :         {
     735           0 :             return error;
     736             :         }
     737             : 
     738          98 :         IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ), IVAS_ERR_OK ) )
     739             :         {
     740           0 :             return error;
     741             :         }
     742             :     }
     743             : 
     744         168 :     st_ivas->hISMDTX.dtx_flag = 0;
     745         168 :     move16();
     746             : 
     747         168 :     st_ivas->hParamIsmDec = hParamIsmDec;
     748         168 :     st_ivas->hSpatParamRendCom = hSpatParamRendCom;
     749             : 
     750             : 
     751         168 :     test();
     752         168 :     IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) )
     753         166 :     {
     754         166 :         Word16 nchan_transport = st_ivas->nchan_transport;
     755         166 :         move16();
     756         166 :         Word16 nchan_full = 0;
     757         166 :         move16();
     758             : 
     759         166 :         test();
     760         166 :         IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
     761             :         {
     762          98 :             nchan_full = nchan_transport;
     763          98 :             move16();
     764          98 :             hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL;
     765          98 :             hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL;
     766             :         }
     767             :         ELSE
     768             :         {
     769             :             Word16 n_slots_to_alloc;
     770          68 :             IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) )
     771             :             {
     772           1 :                 n_slots_to_alloc = MAX_JBM_CLDFB_TIMESLOTS;
     773           1 :                 move16();
     774             :             }
     775             :             ELSE
     776             :             {
     777          67 :                 n_slots_to_alloc = CLDFB_SLOTS_PER_SUBFRAME * MAX_PARAM_SPATIAL_SUBFRAMES;
     778          67 :                 move16();
     779             :             }
     780             : 
     781          68 :             IF( ( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL )
     782             :             {
     783           0 :                 return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) );
     784             :             }
     785          68 :             set32_fx( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx, 0, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands );
     786             : 
     787          68 :             IF( ( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL )
     788             :             {
     789           0 :                 return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) );
     790             :             }
     791          68 :             set32_fx( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx, 0, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands );
     792             :         }
     793             : 
     794         166 :         IF( st_ivas->hTcBuffer == NULL )
     795             :         {
     796          12 :             IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
     797             : 
     798             :             {
     799           0 :                 return error;
     800             :             }
     801             :         }
     802             :     }
     803             :     ELSE
     804             :     {
     805           2 :         hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL;
     806           2 :         hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL;
     807           2 :         IF( st_ivas->hTcBuffer == NULL )
     808             :         {
     809           2 :             Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out;
     810           2 :             move16(); // NS2SA
     811           2 :             IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
     812             :             {
     813           0 :                 return error;
     814             :             }
     815             :         }
     816             :     }
     817             : 
     818         168 :     pop_wmops();
     819         168 :     return error;
     820             : }
     821             : 
     822             : /*-------------------------------------------------------------------------*
     823             :  * ivas_param_ism_dec_close()
     824             :  *
     825             :  * Close Param ISM handle
     826             :  *-------------------------------------------------------------------------*/
     827             : 
     828         225 : void ivas_param_ism_dec_close_fx(
     829             :     PARAM_ISM_DEC_HANDLE *hParamIsmDec_out,                    /* i/o: decoder DirAC handle         */
     830             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */
     831             :     AUDIO_CONFIG output_config                                 /* i  : output audio configuration   */
     832             : )
     833             : {
     834         225 :     test();
     835         225 :     IF( hParamIsmDec_out != NULL && *hParamIsmDec_out != NULL )
     836             :     {
     837             :         PARAM_ISM_DEC_HANDLE hParamIsmDec;
     838         168 :         hParamIsmDec = *hParamIsmDec_out;
     839             : 
     840             :         /* Config & CLDFB */
     841         168 :         IF( hParamIsmDec->hParamIsm != NULL )
     842             :         {
     843         168 :             free( hParamIsmDec->hParamIsm );
     844         168 :             hParamIsmDec->hParamIsm = NULL;
     845             :         }
     846             : 
     847         168 :         test();
     848         168 :         IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
     849             :         {
     850             :             /* Param ISM Rendering */
     851         166 :             IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL )
     852             :             {
     853         166 :                 free( hParamIsmDec->hParamIsmRendering->interpolator_fx );
     854         166 :                 hParamIsmDec->hParamIsmRendering->interpolator_fx = NULL;
     855             :             }
     856         166 :             IF( hParamIsmDec->hParamIsmRendering->proto_matrix_fx != NULL )
     857             :             {
     858         166 :                 free( hParamIsmDec->hParamIsmRendering->proto_matrix_fx );
     859         166 :                 hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL;
     860             :             }
     861             :         }
     862         168 :         IF( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx != NULL )
     863             :         {
     864          68 :             free( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx );
     865          68 :             hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL;
     866             :         }
     867         168 :         IF( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx != NULL )
     868             :         {
     869          68 :             free( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx );
     870          68 :             hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL;
     871             :         }
     872         168 :         IF( hParamIsmDec->hParamIsmRendering != NULL )
     873             :         {
     874         168 :             free( hParamIsmDec->hParamIsmRendering );
     875         168 :             hParamIsmDec->hParamIsmRendering = NULL;
     876             :         }
     877             : 
     878         168 :         free( *hParamIsmDec_out );
     879         168 :         *hParamIsmDec_out = NULL;
     880             :     }
     881             : 
     882         225 :     test();
     883         225 :     IF( hSpatParamRendCom_out != NULL && *hSpatParamRendCom_out != NULL )
     884             :     {
     885         168 :         test();
     886         168 :         test();
     887         168 :         IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
     888             :         {
     889          98 :             ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 1 );
     890          98 :             ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 2 );
     891             :         }
     892             : 
     893         168 :         free( *hSpatParamRendCom_out );
     894         168 :         *hSpatParamRendCom_out = NULL;
     895             :     }
     896             : 
     897         225 :     return;
     898             : }
     899             : 
     900             : 
     901             : /*-------------------------------------------------------------------------*
     902             :  * ivas_ism_dec_digest_tc()
     903             :  *
     904             :  *
     905             :  *-------------------------------------------------------------------------*/
     906       76479 : void ivas_ism_dec_digest_tc_fx(
     907             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
     908             : )
     909             : {
     910       76479 :     ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
     911             : 
     912       76479 :     test();
     913       76479 :     test();
     914       76479 :     test();
     915       76479 :     test();
     916       76479 :     test();
     917       76479 :     test();
     918       76479 :     test();
     919       76479 :     test();
     920       76479 :     IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
     921             :         EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
     922             :         EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
     923             :         EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
     924             :         EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
     925             :         EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
     926             :         EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ||
     927             :         ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) )
     928             :     {
     929             :         int16_t i;
     930             :         Word32 azimuth_fx, elevation_fx;
     931             : 
     932             :         /* we have a full frame interpolator, adapt it */
     933             :         /* for BE testing */
     934             :         Word32 res_dec, res_frac;
     935       38326 :         iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
     936       38326 :         IF( EQ_32( extract_l( res_dec ), st_ivas->hTcBuffer->n_samples_available ) )
     937             :         {
     938       38324 :             Word16 interpolator_length = extract_l( res_dec );
     939             : 
     940       38324 :             test();
     941       38324 :             test();
     942             : #ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING
     943       38324 :             test();
     944       38324 :             test();
     945       38324 :             test();
     946             : #endif
     947             : #ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING
     948       38324 :             IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
     949             :                 EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
     950             :                 EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
     951             :                 ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) )
     952             : #else
     953             :             IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
     954             :                 EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
     955             :                 EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
     956             : #endif
     957             :             {
     958       17776 :                 st_ivas->hIsmRendererData->interpolator_fx[0] = 0;
     959       17776 :                 move16();
     960    15560960 :                 FOR( i = 1; i < interpolator_length; i++ )
     961             :                 {
     962    15543184 :                     Word16 tmp = div_s( 1, sub( interpolator_length, 1 ) );
     963    15543184 :                     st_ivas->hIsmRendererData->interpolator_fx[i] = add( st_ivas->hIsmRendererData->interpolator_fx[i - 1], tmp ); // Q15
     964    15543184 :                     move16();
     965             :                 }
     966             :             }
     967             :             ELSE
     968             :             {
     969    18417988 :                 FOR( i = 0; i < interpolator_length; i++ )
     970             :                 {
     971    18397440 :                     st_ivas->hIsmRendererData->interpolator_fx[i] = div_s( i, sub( interpolator_length, 1 ) ); // Q15
     972    18397440 :                     move16();
     973             :                 }
     974             :             }
     975             :         }
     976             :         ELSE
     977             :         {
     978           2 :             ivas_jbm_dec_get_adapted_linear_interpolator_fx( extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx );
     979           2 :             move16();
     980             :         }
     981             : #ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING
     982       38326 :         st_ivas->hIsmRendererData->interp_offset_fx = 0;
     983       38326 :         move16();
     984             : #endif
     985             : 
     986             :         /* also get the gains here */
     987      156416 :         FOR( i = 0; i < st_ivas->nchan_ism; i++ )
     988             :         {
     989      118090 :             Copy32( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmRendererData->prev_gains_fx[i], MAX_OUTPUT_CHANNELS );
     990             : 
     991      118090 :             IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_STEREO ) )
     992             :             {
     993             :                 Word16 gains_fx[2];
     994       16400 :                 ivas_ism_get_stereo_gains_fx( (Word16) L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ), (Word16) L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ), &gains_fx[0], &gains_fx[1] );
     995       16400 :                 st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 ); // Q31 -> Q30
     996       16400 :                 move32();
     997       16400 :                 st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30
     998       16400 :                 move32();
     999             :             }
    1000             :             ELSE
    1001             :             {
    1002             :                 // TODO tmu review when #215 is resolved
    1003      101690 :                 azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->azimuth_fx, 2097152 ), Q22 );     // Q0 ,2097152 = .5f in Q22
    1004      101690 :                 elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22
    1005             : 
    1006      101690 :                 test();
    1007      101690 :                 test();
    1008      101690 :                 test();
    1009      101690 :                 test();
    1010      101690 :                 test();
    1011             : #ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING
    1012      101690 :                 test();
    1013      101690 :                 test();
    1014      101690 :                 test();
    1015             : #endif
    1016             : #ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING
    1017      101690 :                 IF( ( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
    1018             :                       EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
    1019             :                       EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ||
    1020             :                       ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) &&
    1021             :                     st_ivas->hCombinedOrientationData == NULL )
    1022             : #else
    1023             :                 IF( ( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
    1024             :                       EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
    1025             :                       EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) &&
    1026             :                     st_ivas->hCombinedOrientationData == NULL )
    1027             : #endif
    1028             :                 {
    1029       55446 :                     if ( st_ivas->hIntSetup.is_planar_setup )
    1030             :                     {
    1031             :                         /* If no elevation support in output format, then rendering should be done with zero elevation */
    1032       11000 :                         elevation_fx = 0;
    1033       11000 :                         move32();
    1034             :                     }
    1035             : 
    1036       55446 :                     IF( st_ivas->hEFAPdata != NULL )
    1037             :                     {
    1038       55446 :                         azimuth_fx = L_shl( azimuth_fx, Q22 );     // Q22
    1039       55446 :                         elevation_fx = L_shl( elevation_fx, Q22 ); // Q22
    1040       55446 :                         efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP );
    1041             :                     }
    1042             :                 }
    1043       46244 :                 ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
    1044             :                          EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
    1045             :                          EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
    1046             :                 {
    1047             :                     /*get HOA gets for direction (ACN/SN3D)*/
    1048       46244 :                     Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 );   // Q0
    1049       46244 :                     Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0
    1050       46244 :                     ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 );
    1051             :                 }
    1052             :             }
    1053             :         }
    1054             :     }
    1055             : 
    1056       76479 :     return;
    1057             : }
    1058             : 
    1059             : /*-------------------------------------------------------------------------*
    1060             :  * ivas_param_ism_dec_digest_tc()
    1061             :  *
    1062             :  *
    1063             :  *-------------------------------------------------------------------------*/
    1064        5253 : void ivas_param_ism_dec_digest_tc_fx(
    1065             :     Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                                     */
    1066             :     const UWord16 nCldfbSlots,    /* i  : number of CLFBS slots in the transport channels         */
    1067             :     Word32 *transport_channels[], /* i  : synthesized core-coder transport channels/DirAC output  q_tc_in*/
    1068             :     Word16 q_tc_in )
    1069             : {
    1070        5253 :     Word16 exp_real_tmp = 0, exp_imag_tmp = 0;
    1071        5253 :     move16();
    1072        5253 :     move16();
    1073        5253 :     move16();
    1074        5253 :     move16();
    1075             :     Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    1076             :     Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    1077             : 
    1078        5253 :     Word16 q_tc = q_tc_in;
    1079        5253 :     move16();
    1080             :     Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
    1081             :     Word16 slot_idx, bin_idx;
    1082             :     Word32 ivas_total_brate;
    1083             :     Word16 output_frame;
    1084             :     /* Direct Response/EFAP Gains */
    1085             :     Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN];
    1086             :     PARAM_ISM_DEC_HANDLE hParamIsmDec;
    1087             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    1088             :     Word16 fade_len;
    1089             : 
    1090             :     /* Initialization */
    1091        5253 :     set32_fx( &direct_response_fx[0][0], 0, MAX_NUM_OBJECTS * PARAM_ISM_MAX_CHAN );
    1092        5253 :     hParamIsmDec = st_ivas->hParamIsmDec;
    1093        5253 :     assert( hParamIsmDec );
    1094        5253 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    1095        5253 :     assert( hSpatParamRendCom );
    1096        5253 :     output_frame = imult1616( nCldfbSlots, hSpatParamRendCom->num_freq_bands );
    1097        5253 :     fade_len = shr( output_frame, 1 );
    1098             : 
    1099        5253 :     nchan_transport = st_ivas->nchan_transport;
    1100        5253 :     move16();
    1101        5253 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    1102        5253 :     move32();
    1103             : 
    1104        5253 :     hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 25;
    1105        5253 :     move16();
    1106        5253 :     hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 25;
    1107        5253 :     move16();
    1108        5253 :     IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
    1109             :     {
    1110         543 :         nchan_out = st_ivas->nchan_ism;
    1111         543 :         move16();
    1112         543 :         nchan_out_woLFE = nchan_out;
    1113         543 :         move16();
    1114         543 :         st_ivas->hDecoderConfig->nchan_out = nchan_out;
    1115         543 :         move16();
    1116             :     }
    1117             :     ELSE
    1118             :     {
    1119        4710 :         nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
    1120        4710 :         nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
    1121        4710 :         move16();
    1122             :     }
    1123             : 
    1124        5253 :     push_wmops( "ivas_param_ism_dec" );
    1125             : 
    1126             :     /* general setup */
    1127        5253 :     ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );
    1128             : 
    1129        5253 :     ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots );
    1130             :     /* set buffers to zero */
    1131             : 
    1132        5253 :     set_zero_fx( &cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX );
    1133        5253 :     set16_zero_fx( &exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX );
    1134             : 
    1135             :     /* Frame-level Processing */
    1136             :     /* De-quantization */
    1137        5253 :     test();
    1138        5253 :     IF( !( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) )
    1139             :     {
    1140        5193 :         ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism );
    1141        5193 :         ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec );
    1142        5193 :         st_ivas->hISMDTX.dtx_flag = 0;
    1143        5193 :         move16();
    1144             :     }
    1145             :     ELSE
    1146             :     {
    1147          60 :         st_ivas->hISMDTX.dtx_flag = 1;
    1148          60 :         move16();
    1149             :     }
    1150             : 
    1151             :     /* obtain the direct response using EFAP */
    1152        5253 :     IF( !( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) )
    1153             :     {
    1154       22050 :         FOR( i = 0; i < st_ivas->nchan_ism; i++ )
    1155             :         {
    1156       17340 :             efap_determine_gains_fx( st_ivas->hEFAPdata, direct_response_fx[i], hParamIsmDec->azimuth_values_fx[i], hParamIsmDec->elevation_values_fx[i], EFAP_MODE_EFAP );
    1157             :         }
    1158             :     }
    1159             :     ELSE
    1160             :     {
    1161             :         Word16 j;
    1162             : 
    1163        2715 :         FOR( i = 0; i < st_ivas->nchan_ism; i++ )
    1164             :         {
    1165       10860 :             FOR( j = 0; j < nchan_out_woLFE; j++ )
    1166             :             {
    1167        8688 :                 IF( EQ_16( i, j ) )
    1168             :                 {
    1169        2172 :                     direct_response_fx[i][j] = ONE_IN_Q30;
    1170        2172 :                     move32();
    1171             :                 }
    1172             :                 ELSE
    1173             :                 {
    1174        6516 :                     direct_response_fx[i][j] = 0;
    1175        6516 :                     move32();
    1176             :                 }
    1177             :             }
    1178             :         }
    1179             : 
    1180        2715 :         FOR( j = 0; j < nchan_out_woLFE; j++ )
    1181             :         {
    1182        2172 :             IF( hParamIsmDec->azimuth_values_fx[j] > 0 )
    1183             :             {
    1184         875 :                 hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 32767; // (1.0f in Q15) - 1
    1185         875 :                 move16();
    1186         875 :                 hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 0;
    1187         875 :                 move16();
    1188             :             }
    1189             :             ELSE
    1190             :             {
    1191        1297 :                 IF( hParamIsmDec->azimuth_values_fx[j] < 0 )
    1192             :                 {
    1193         945 :                     hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 0;
    1194         945 :                     move16();
    1195         945 :                     hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 32767; // (1.0f in Q15) - 1
    1196         945 :                     move16();
    1197             :                 }
    1198             :                 ELSE /* == 0.0f */
    1199             :                 {
    1200         352 :                     hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = ONE_IN_Q14; // Q15
    1201         352 :                     move16();
    1202         352 :                     hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = ONE_IN_Q14; // Q15
    1203         352 :                     move16();
    1204             :                 }
    1205             :             }
    1206             :         }
    1207             :     }
    1208             : 
    1209        5253 :     IF( st_ivas->hDecoderConfig->Opt_tsm )
    1210             :     {
    1211             :         /*TODO : FhG to check*/
    1212        1506 :         ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, fade_len, transport_channels, &q_tc );
    1213        1506 :         IF( NE_16( q_tc, q_tc_in ) )
    1214             :         {
    1215        4518 :             FOR( i = 0; i < 2; i++ )
    1216             :             {
    1217        3012 :                 scale_sig32( transport_channels[i], output_frame, sub( q_tc_in, q_tc ) ); // q_tc_in
    1218             :             }
    1219        1506 :             q_tc = q_tc_in;
    1220        1506 :             move16();
    1221             :         }
    1222             :     }
    1223             : 
    1224       15759 :     FOR( ch = 0; ch < nchan_transport; ch++ )
    1225             :     {
    1226             :         /* CLDFB Analysis */
    1227      178602 :         FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
    1228             :         {
    1229      168096 :             IF( st_ivas->hDecoderConfig->Opt_tsm )
    1230             :             {
    1231             :                 Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX];
    1232             :                 Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX];
    1233       48192 :                 q_tc = q_tc_in;
    1234       48192 :                 move16();
    1235       48192 :                 cldfbAnalysis_ts_fx_fixed_q( &( transport_channels[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_tc );
    1236       48192 :                 Copy32( RealBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
    1237       48192 :                 Copy32( ImagBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
    1238       48192 :                 hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = sub( 31, q_tc );
    1239       48192 :                 move16();
    1240       48192 :                 hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_tc );
    1241       48192 :                 move16();
    1242             :             }
    1243             :             Word16 scale_factor_real, scale_factor_imag;
    1244             :             Word16 current_idx;
    1245      168096 :             exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp;
    1246      168096 :             move16();
    1247      168096 :             exp_imag_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp;
    1248      168096 :             move16();
    1249      168096 :             current_idx = add( imult1616( imult1616( slot_idx, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) );
    1250      168096 :             scale_factor_real = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands );
    1251      168096 :             scale_factor_imag = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands );
    1252      168096 :             scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_real ); // Q(31-(exp_real_tmp-scale_factor_real))
    1253      168096 :             scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_imag ); // Q(31-(exp_imag_tmp-scale_factor_imag))
    1254      168096 :             exp_real_tmp = sub( exp_real_tmp, scale_factor_real );
    1255      168096 :             exp_imag_tmp = sub( exp_imag_tmp, scale_factor_imag );
    1256      168096 :             ivas_param_ism_collect_slot_fx( hParamIsmDec,
    1257      168096 :                                             &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx],
    1258             :                                             exp_real_tmp,
    1259      168096 :                                             &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx],
    1260             :                                             exp_imag_tmp,
    1261             :                                             ch,
    1262             :                                             cx_diag_fx, exp_cx_diag );
    1263             : 
    1264      168096 :             exp_real_tmp = add( exp_real_tmp, scale_factor_real );
    1265      168096 :             exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag );
    1266      168096 :             scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_real ); // Q(31-(exp_real_tmp))
    1267      168096 :             scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_imag ); // Q(31-(exp_imag_tmp))
    1268             :         }
    1269             :     }
    1270             :     /* Obtain Mixing Matrix on a frame-level */
    1271      320433 :     FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ )
    1272             :     {
    1273      315180 :         set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX );
    1274             :     }
    1275             : 
    1276             :     /* Compute mixing matrix */
    1277        5253 :     ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag,
    1278        5253 :                                              hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx );
    1279             : 
    1280        5253 :     pop_wmops();
    1281             : 
    1282        5253 :     return;
    1283             : }
    1284             : 
    1285             : 
    1286             : /*-------------------------------------------------------------------------*
    1287             :  * ivas_ism_param_dec_tc_gain_ajust()
    1288             :  *
    1289             :  *
    1290             :  *-------------------------------------------------------------------------*/
    1291             : 
    1292        5253 : void ivas_ism_param_dec_tc_gain_ajust_fx(
    1293             :     Decoder_Struct *st_ivas,        /* i/o: IVAS decoder handle                                         */
    1294             :     const UWord16 nSamples,         /* i  : number of samples to be compensate                          */
    1295             :     const UWord16 nFadeLength,      /* i  : length of the crossfade in samples                          */
    1296             :     Word32 *transport_channels_f[], /* i  : synthesized core-coder transport channels/DirAC output  Q_tc*/
    1297             :     Word16 *Q_tc                    /* i/o : Q of input tc buffer                                       */
    1298             : )
    1299             : 
    1300             : {
    1301             :     Word16 i, tmp_e1, tmp_e2, tmp, tmp2, invFade;
    1302             :     Word32 L_tmp1, L_tmp2;
    1303             : 
    1304             :     Word16 gain_fx, last_gain_fx;
    1305             :     Word32 ene_tc_fx, ene_sum_fx;
    1306             : 
    1307             :     Word16 ene_tc_e, ene_sum_e;
    1308             : 
    1309        5253 :     ene_tc_fx = 0;
    1310        5253 :     move32();
    1311        5253 :     ene_tc_e = 0;
    1312        5253 :     move16();
    1313        5253 :     ene_sum_fx = 0;
    1314        5253 :     move32();
    1315        5253 :     ene_sum_e = 0;
    1316        5253 :     move16();
    1317             : 
    1318             : 
    1319        5253 :     last_gain_fx = st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx;
    1320        5253 :     move16();
    1321             : 
    1322             :     Word32 ch0, ch1;
    1323             :     Word16 ch0_e, ch1_e;
    1324        5253 :     ch0_e = 0;
    1325        5253 :     move16();
    1326        5253 :     ch1_e = 0;
    1327        5253 :     move16();
    1328             : 
    1329     5048133 :     FOR( i = 0; i < nSamples; i++ )
    1330             :     {
    1331     5042880 :         ch0_e = 0;
    1332     5042880 :         move16();
    1333     5042880 :         ch1_e = 0;
    1334     5042880 :         move16();
    1335     5042880 :         ch0 = transport_channels_f[0][i];
    1336     5042880 :         move16();
    1337     5042880 :         ch1 = transport_channels_f[1][i];
    1338     5042880 :         move16();
    1339     5042880 :         ch0 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, 0, 0, &ch0_e );
    1340     5042880 :         ch1 = BASOP_Util_Add_Mant32Exp( ch1, ch1_e, 0, 0, &ch1_e );
    1341             : 
    1342             : 
    1343     5042880 :         L_tmp1 = Mpy_32_32( ch0, ch0 ); /*L*L*/
    1344     5042880 :         tmp_e1 = add( ch0_e, ch0_e );
    1345     5042880 :         L_tmp2 = Mpy_32_32( ch1, ch1 ); /*R*R*/
    1346     5042880 :         tmp_e2 = add( ch1_e, ch1_e );
    1347             :         /*L*LL + R*R*/
    1348     5042880 :         ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp1, tmp_e1, &ene_tc_e );
    1349     5042880 :         ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp2, tmp_e2, &ene_tc_e );
    1350             : 
    1351             : 
    1352     5042880 :         L_tmp1 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, ch1, ch1_e, &tmp_e1 ); /*L + R*/
    1353     5042880 :         L_tmp1 = Mpy_32_32( L_tmp1, L_tmp1 );                                 // Q(31-(tmp_e1+tmp_e1           /*(L + R)*(L + R)*/
    1354     5042880 :         tmp_e1 = add( tmp_e1, tmp_e1 );
    1355             : 
    1356     5042880 :         ene_sum_fx = BASOP_Util_Add_Mant32Exp( ene_sum_fx, ene_sum_e, L_tmp1, tmp_e1, &ene_sum_e );
    1357             :     }
    1358             : 
    1359        5253 :     IF( ene_sum_fx != 0 )
    1360             :     {
    1361        5253 :         gain_fx = BASOP_Util_Divide3232_Scale( ene_tc_fx, ene_sum_fx, &tmp_e1 );
    1362             :     }
    1363             :     ELSE
    1364             :     {
    1365           0 :         IF( ene_tc_fx == 0 ) /*handling numerator equals to zero*/
    1366             :         {
    1367           0 :             gain_fx = 0;
    1368           0 :             move16();
    1369           0 :             tmp_e1 = 0;
    1370           0 :             move16();
    1371             :         }
    1372             :         ELSE /*handling denominator equals to zero*/
    1373             :         {
    1374           0 :             gain_fx = 32767; //(max value of Word16 in Q0)
    1375           0 :             move16();
    1376           0 :             tmp_e1 = 15;
    1377           0 :             move16();
    1378             :         }
    1379             :     }
    1380        5253 :     tmp_e1 = add( tmp_e1, sub( ene_tc_e, ene_sum_e ) ); /* tmp_e1 + (ene_tc_e - ene_sum_e)*/
    1381        5253 :     gain_fx = Sqrt16( gain_fx, &tmp_e1 );
    1382             : 
    1383        5253 :     tmp_e2 = st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e;
    1384        5253 :     move16();
    1385             : 
    1386        5253 :     IF( GT_16( tmp_e2, tmp_e1 ) )
    1387             :     {
    1388        4970 :         gain_fx = shr( gain_fx, sub( tmp_e2, tmp_e1 ) ); // Q(15-tmp_e2)
    1389        4970 :         tmp_e1 = tmp_e2;
    1390        4970 :         move16();
    1391             :     }
    1392             :     ELSE
    1393             :     {
    1394         283 :         last_gain_fx = shr( last_gain_fx, sub( tmp_e1, tmp_e2 ) ); // Q(15-tmp_e1)
    1395             :     }
    1396             : 
    1397        5253 :     IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 )
    1398             :     {
    1399             :         /* Smoothing */
    1400        5247 :         gain_fx = add( mult_r( 24574, gain_fx ), mult_r( 8192, last_gain_fx ) ); // 24574 =.75f in Q15 , 8192=.25f in Q15
    1401             :         /* 10ms ramp */
    1402             :         /* slope between two consecutive gains, 480 samples length */
    1403        5247 :         invFade = div_s( 1, nFadeLength ); // Q15
    1404        5247 :         tmp = 0;
    1405        5247 :         move16();
    1406     2523807 :         FOR( i = 0; i < ( nFadeLength ); i++ )
    1407             :         {
    1408             :             /* tmp2 = ( last_gain_fx + i * grad_fx )*/
    1409     2518560 :             tmp2 = add( mult_r( sub( 32767, tmp ), last_gain_fx ), mult_r( tmp, gain_fx ) ); // 32767= 1.0f in Q15,
    1410             : 
    1411     2518560 :             transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], tmp2 ); // Q(Q_tc-tmp_e1)
    1412     2518560 :             move32();
    1413     2518560 :             transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], tmp2 ); // Q(Q_tc-tmp_e1)
    1414     2518560 :             move32();
    1415             : 
    1416     2518560 :             tmp = add( tmp, invFade );
    1417             :         }
    1418     2523807 :         FOR( ; i < nSamples; i++ )
    1419             :         {
    1420     2518560 :             transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
    1421     2518560 :             move32();
    1422     2518560 :             transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
    1423     2518560 :             move32();
    1424             :         }
    1425             :     }
    1426             :     ELSE
    1427             :     {
    1428        5766 :         FOR( i = 0; i < nSamples; i++ )
    1429             :         {
    1430        5760 :             transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
    1431        5760 :             move32();
    1432        5760 :             transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
    1433        5760 :             move32();
    1434             :         }
    1435             :     }
    1436             : 
    1437        5253 :     st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx = gain_fx;
    1438        5253 :     move16();
    1439        5253 :     st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e = tmp_e1;
    1440        5253 :     move16();
    1441             : 
    1442        5253 :     *Q_tc = sub( *Q_tc, tmp_e1 );
    1443        5253 :     move16();
    1444        5253 :     return;
    1445             : }
    1446             : 
    1447             : /*-------------------------------------------------------------------------*
    1448             :  * ivas_ism_param_dec_render_sf()
    1449             :  *
    1450             :  *
    1451             :  *-------------------------------------------------------------------------*/
    1452       22317 : static void ivas_ism_param_dec_render_sf_fx(
    1453             :     Decoder_Struct *st_ivas,
    1454             :     IVAS_OUTPUT_SETUP hSetup,
    1455             :     const Word16 nchan_transport,
    1456             :     const Word16 nchan_out,
    1457             :     const Word16 nchan_out_woLFE,
    1458             :     Word32 *output_f_fx[], /*Q_output*/
    1459             :     Word16 Q_output[] )
    1460             : {
    1461             :     Word16 ch, slot_idx, i, index_slot;
    1462             :     /* CLDFB Output Buffers */
    1463             :     Word32 Cldfb_RealBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; // Q(31-real_exp)
    1464             :     Word32 Cldfb_ImagBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; // Q(31-imag_exp)
    1465             :     Word32 *Cldfb_RealBuffer_in_fx[PARAM_ISM_MAX_DMX];                                                  // Q11
    1466             :     Word32 *Cldfb_ImagBuffer_in_fx[PARAM_ISM_MAX_DMX];                                                  // Q11
    1467             :     PARAM_ISM_DEC_HANDLE hParamIsmDec;
    1468             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    1469             :     Word16 slot_idx_start;
    1470             :     Word16 idx_in;
    1471             :     Word16 idx_lfe;
    1472             :     Word16 subframe_idx;
    1473             :     Word16 samplesProcessed, no_col_cldfb, size_cldfb;
    1474       22317 :     hParamIsmDec = st_ivas->hParamIsmDec;
    1475       22317 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    1476       22317 :     slot_idx_start = hSpatParamRendCom->slots_rendered;
    1477       22317 :     move16();
    1478       22317 :     subframe_idx = hSpatParamRendCom->subframes_rendered;
    1479       22317 :     move16();
    1480             :     /* Set some memories to zero */
    1481      228600 :     FOR( ch = 0; ch < nchan_out_woLFE; ch++ )
    1482             :     {
    1483      973995 :         FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
    1484             :         {
    1485      767712 :             set32_fx( Cldfb_RealBuffer_fx[ch][slot_idx], 0, hSpatParamRendCom->num_freq_bands );
    1486      767712 :             set32_fx( Cldfb_ImagBuffer_fx[ch][slot_idx], 0, hSpatParamRendCom->num_freq_bands );
    1487             :         }
    1488             :     }
    1489             : 
    1490             : 
    1491             :     Word16 real_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME];
    1492             :     Word16 imag_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME];
    1493      106365 :     FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
    1494             :     {
    1495       84048 :         index_slot = add( slot_idx_start, slot_idx );
    1496             : 
    1497             : 
    1498      252144 :         FOR( ch = 0; ch < nchan_transport; ch++ )
    1499             :         {
    1500      168096 :             Word16 cldfb_idx = add( imult1616( imult1616( index_slot, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) );
    1501      168096 :             Cldfb_RealBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[cldfb_idx]; // Q11
    1502      168096 :             Cldfb_ImagBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[cldfb_idx]; // Q11
    1503             :         }
    1504             : 
    1505             :         /* Compute bandwise rendering to target LS using covariance rendering */
    1506       84048 :         real_exp[slot_idx] = 0;
    1507       84048 :         move16();
    1508       84048 :         imag_exp[slot_idx] = 0;
    1509       84048 :         move16();
    1510       84048 :         ivas_param_ism_render_slot_fx( hParamIsmDec, hSpatParamRendCom,
    1511       84048 :                                        Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &real_exp[slot_idx], &imag_exp[slot_idx],
    1512       84048 :                                        hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx,
    1513             :                                        index_slot, slot_idx, nchan_out_woLFE, nchan_transport );
    1514             :     }
    1515             : 
    1516             :     /* CLDFB Synthesis */
    1517       22317 :     idx_in = 0;
    1518       22317 :     move16();
    1519       22317 :     idx_lfe = 0;
    1520       22317 :     move16();
    1521             :     // Word16 tmp_buff_Q[MAX_OUTPUT_CHANNELS];
    1522             : 
    1523      248745 :     FOR( ch = 0; ch < nchan_out; ch++ )
    1524             :     {
    1525      226428 :         test();
    1526      226428 :         IF( ( hSetup.num_lfe > 0 ) && EQ_16( hSetup.index_lfe[idx_lfe], ch ) )
    1527             :         {
    1528       20145 :             set32_fx( output_f_fx[ch], 0, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) );
    1529             : 
    1530       20145 :             if ( LT_16( idx_lfe, sub( hSetup.num_lfe, 1 ) ) )
    1531             :             {
    1532           0 :                 idx_lfe = add( idx_lfe, 1 );
    1533             :             }
    1534             :         }
    1535             :         ELSE
    1536             :         {
    1537             : 
    1538             :             Word32 *RealBuffer_fx[16];
    1539             :             Word32 *ImagBuffer_fx[16];
    1540             : 
    1541      206283 :             Word16 Q_real = 31;
    1542      206283 :             move16();
    1543             : 
    1544      973995 :             FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
    1545             :             {
    1546      767712 :                 RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i];
    1547      767712 :                 ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i];
    1548      767712 :                 Q_real = s_min( Q_real, sub( 31, imag_exp[i] ) );
    1549      767712 :                 Q_real = s_min( Q_real, sub( 31, real_exp[i] ) );
    1550             :             }
    1551             : 
    1552      206283 :             Q_real = sub( Q_real, 3 ); // guarded bits
    1553             : 
    1554      973995 :             FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
    1555             :             {
    1556      767712 :                 Scale_sig32( RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, add( sub( Q_real, 31 ), real_exp[i] ) ); // Q_real
    1557      767712 :                 Scale_sig32( ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, add( sub( Q_real, 31 ), imag_exp[i] ) ); // Q_real
    1558             :             }
    1559             : 
    1560      206283 :             Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1
    1561      206283 :             st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 );
    1562      206283 :             move16();
    1563      206283 :             cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] );
    1564      206283 :             Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11
    1565      206283 :             st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
    1566      206283 :             move16();
    1567             : 
    1568             :             /*scaling the output_f buffer to have common Q accross the buffer*/
    1569      206283 :             samplesProcessed = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] );
    1570      206283 :             no_col_cldfb = st_ivas->cldfbSynDec[ch]->no_col;
    1571      206283 :             move16();
    1572      206283 :             IF( GT_16( samplesProcessed, -1 ) )
    1573             :             {
    1574             :                 Word32 res_dec, res_frac;
    1575      206283 :                 iDiv_and_mod_32( sub( add( samplesProcessed, st_ivas->cldfbSynDec[ch]->no_channels ), 1 ), st_ivas->cldfbSynDec[ch]->no_channels, &res_dec, &res_frac, 0 );
    1576      206283 :                 no_col_cldfb = s_min( no_col_cldfb, extract_l( res_dec ) );
    1577             :             }
    1578             : 
    1579      206283 :             size_cldfb = imult1616( st_ivas->cldfbSynDec[ch]->no_channels, no_col_cldfb );
    1580      206283 :             Scale_sig32( output_f_fx[ch], size_cldfb, sub( Q11, sub( Q_real, 1 ) ) ); // Q11
    1581             : 
    1582      206283 :             Q_output[ch] = 11;
    1583      206283 :             move16();
    1584      206283 :             idx_in = add( idx_in, 1 );
    1585             :         }
    1586             :     }
    1587             : 
    1588       22317 :     hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] );
    1589       22317 :     move16();
    1590       22317 :     hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 );
    1591       22317 :     move16();
    1592             : 
    1593       22317 :     return;
    1594             : }
    1595             : 
    1596             : 
    1597             : /*-------------------------------------------------------------------------*
    1598             :  * ivas_param_ism_dec_render()
    1599             :  *
    1600             :  *
    1601             :  *-------------------------------------------------------------------------*/
    1602        6559 : void ivas_param_ism_dec_render_fx(
    1603             :     Decoder_Struct *st_ivas,        /* i/o: IVAS decoder handle                       */
    1604             :     const UWord16 nSamplesAsked,    /* i  : number of CLDFB slots requested           */
    1605             :     UWord16 *nSamplesRendered,      /* o  : number of CLDFB slots rendered            */
    1606             :     UWord16 *nSamplesAvailableNext, /* o  : number of CLDFB slots still to render     */
    1607             :     Word32 *output_f_fx[]           /*Q11*/
    1608             : )
    1609             : {
    1610             : 
    1611             :     Word16 ch, slots_to_render, first_sf, last_sf, subframe_idx;
    1612             :     UWord16 slot_size, n_samples_sf;
    1613             :     PARAM_ISM_DEC_HANDLE hParamIsmDec;
    1614             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    1615             :     IVAS_OUTPUT_SETUP hSetup;
    1616             :     Word16 nchan_transport, nchan_out, nchan_out_woLFE;
    1617             :     Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS];
    1618             :     Word16 Q_output[MAX_OUTPUT_CHANNELS];
    1619             : 
    1620        6559 :     set16_fx( Q_output, 0, MAX_OUTPUT_CHANNELS );
    1621             : 
    1622        6559 :     hParamIsmDec = st_ivas->hParamIsmDec;
    1623        6559 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    1624        6559 :     hSetup = st_ivas->hIntSetup;
    1625        6559 :     nchan_transport = st_ivas->nchan_transport;
    1626        6559 :     move16();
    1627             : 
    1628        6559 :     IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
    1629             :     {
    1630         543 :         nchan_out = st_ivas->nchan_ism;
    1631         543 :         move16();
    1632         543 :         nchan_out_woLFE = nchan_out;
    1633         543 :         move16();
    1634         543 :         st_ivas->hDecoderConfig->nchan_out = nchan_out;
    1635         543 :         move16();
    1636             :     }
    1637             :     ELSE
    1638             :     {
    1639        6016 :         nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
    1640        6016 :         move16();
    1641        6016 :         nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
    1642        6016 :         move16();
    1643             :     }
    1644        6559 :     slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
    1645             : 
    1646             :     /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
    1647             :     Word32 res_dec, res_frac;
    1648        6559 :     iDiv_and_mod_32( nSamplesAsked, slot_size, &res_dec, &res_frac, 0 );
    1649             : 
    1650        6559 :     slots_to_render = s_min( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), extract_l( res_dec ) );
    1651        6559 :     *nSamplesRendered = imult1616( slots_to_render, extract_l( slot_size ) );
    1652        6559 :     move16();
    1653        6559 :     first_sf = hSpatParamRendCom->subframes_rendered;
    1654        6559 :     move16();
    1655        6559 :     last_sf = first_sf;
    1656        6559 :     move16();
    1657             : 
    1658       28876 :     WHILE( slots_to_render > 0 )
    1659             :     {
    1660       22317 :         slots_to_render = sub( slots_to_render, hSpatParamRendCom->subframe_nbslots[last_sf] );
    1661       22317 :         last_sf = add( last_sf, 1 );
    1662             :     }
    1663             : 
    1664       74923 :     FOR( ch = 0; ch < nchan_out; ch++ )
    1665             :     {
    1666       68364 :         output_f_local_fx[ch] = &output_f_fx[ch][0];
    1667             :     }
    1668             : 
    1669       28876 :     FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    1670             :     {
    1671       22317 :         ivas_ism_param_dec_render_sf_fx( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local_fx, Q_output );
    1672             : 
    1673       22317 :         n_samples_sf = i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size );
    1674      248745 :         FOR( ch = 0; ch < nchan_out; ch++ )
    1675             :         {
    1676      226428 :             output_f_local_fx[ch] += n_samples_sf;
    1677             :         }
    1678             :     }
    1679             : 
    1680        6559 :     IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) )
    1681             :     {
    1682             :         /* copy the memories */
    1683             :         /* store mixing matrix for next subframe */
    1684        5253 :         ivas_param_ism_update_mixing_matrix_fx( hParamIsmDec, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx, nchan_transport, nchan_out_woLFE );
    1685             : 
    1686             :         /* store MetaData parameters */
    1687       24765 :         FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ )
    1688             :         {
    1689       19512 :             IF( GT_32( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 754974720 ) /*180.f in Q22*/ )
    1690             :             {
    1691           0 :                 st_ivas->hIsmMetaData[ch]->azimuth_fx = L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 1509949440 ) /*360.0F in Q22*/;
    1692           0 :                 move32();
    1693             :             }
    1694             :             ELSE
    1695             :             {
    1696       19512 :                 st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->azimuth_values_fx[ch];
    1697       19512 :                 move32();
    1698             :             }
    1699             : 
    1700       19512 :             st_ivas->hIsmMetaData[ch]->elevation_fx = st_ivas->hParamIsmDec->elevation_values_fx[ch];
    1701       19512 :             move32();
    1702             :         }
    1703             :     }
    1704             : 
    1705        6559 :     *nSamplesAvailableNext = imult1616( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), (Word16) slot_size );
    1706        6559 :     move16();
    1707        6559 :     return;
    1708             : }
    1709             : 
    1710             : 
    1711             : /*-------------------------------------------------------------------------*
    1712             :  * ivas_param_ism_params_to_masa_param_mapping()
    1713             :  *
    1714             :  *
    1715             :  *-------------------------------------------------------------------------*/
    1716        7955 : void ivas_param_ism_params_to_masa_param_mapping_fx(
    1717             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
    1718             : )
    1719             : {
    1720             :     PARAM_ISM_DEC_HANDLE hParamIsmDec;
    1721             :     SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    1722             :     Word16 nBins;
    1723             :     Word16 band_idx, bin_idx, sf_idx;
    1724             :     Word16 brange[2];
    1725             :     Word16 azimuth[2];
    1726             :     Word16 elevation[2];
    1727             :     Word16 power_ratio_fx[2]; /* Q15 */
    1728             :     Word32 ivas_total_brate;
    1729             : 
    1730        7955 :     hParamIsmDec = st_ivas->hParamIsmDec;
    1731        7955 :     hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    1732        7955 :     nBins = hSpatParamRendCom->num_freq_bands;
    1733        7955 :     move16();
    1734        7955 :     ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    1735        7955 :     move32();
    1736             : 
    1737        7955 :     test();
    1738        7955 :     IF( !( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || ivas_total_brate == FRAME_NO_DATA ) )
    1739             :     {
    1740        7691 :         ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism );
    1741        7691 :         ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec );
    1742        7691 :         st_ivas->hISMDTX.dtx_flag = 0;
    1743        7691 :         move16();
    1744             :     }
    1745             :     ELSE
    1746             :     {
    1747         264 :         st_ivas->hISMDTX.dtx_flag = 1;
    1748         264 :         move16();
    1749             :     }
    1750             : 
    1751        7955 :     IF( GT_16( st_ivas->nchan_ism, 1 ) )
    1752             :     {
    1753        7955 :         IF( st_ivas->hISMDTX.dtx_flag )
    1754             :         {
    1755             :             Word32 energy_ratio_fx;                                                                                                                                                /* Q30 */
    1756         264 :             energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx, st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ); /* Q15 + Q15 -> Q30 */
    1757             : 
    1758         264 :             hSpatParamRendCom->numSimultaneousDirections = 1;
    1759         264 :             move16();
    1760         264 :             azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0
    1761         264 :             move16();
    1762         264 :             elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ONE_IN_Q21 ), 22 ) ); // Q0
    1763         264 :             move16();
    1764             : 
    1765        1320 :             FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    1766             :             {
    1767       64416 :                 FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
    1768             :                 {
    1769       63360 :                     hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
    1770       63360 :                     move16();
    1771       63360 :                     hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
    1772       63360 :                     move16();
    1773       63360 :                     hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = energy_ratio_fx;
    1774       63360 :                     move16();
    1775       63360 :                     hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
    1776       63360 :                     move16();
    1777       63360 :                     hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
    1778       63360 :                     move16();
    1779             :                 }
    1780             :             }
    1781             :         }
    1782             :         ELSE
    1783             :         {
    1784        7691 :             hSpatParamRendCom->numSimultaneousDirections = 2;
    1785        7691 :             move16();
    1786       92292 :             FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
    1787             :             {
    1788       84601 :                 brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
    1789       84601 :                 move16();
    1790       84601 :                 brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
    1791       84601 :                 move16();
    1792             : 
    1793       84601 :                 azimuth[0] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0
    1794       84601 :                 move16();
    1795       84601 :                 elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]], ( 1 << 21 ) ), 22 ) ); // Q0
    1796       84601 :                 move16();
    1797       84601 :                 power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0];
    1798       84601 :                 move16();
    1799       84601 :                 azimuth[1] = extract_l( L_shr( L_add( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0
    1800       84601 :                 move16();
    1801       84601 :                 elevation[1] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]], ( 1 << 21 ) ), 22 ) ); // Q0
    1802       84601 :                 move16();
    1803       84601 :                 power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1];
    1804       84601 :                 move16();
    1805             : 
    1806      423005 :                 FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    1807             :                 {
    1808     2124164 :                     FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
    1809             :                     {
    1810     1785760 :                         hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
    1811     1785760 :                         move16();
    1812     1785760 :                         hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
    1813     1785760 :                         move16();
    1814     1785760 :                         hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[0], Q15 ); // Q30
    1815     1785760 :                         move32();
    1816     1785760 :                         hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1];
    1817     1785760 :                         move16();
    1818     1785760 :                         hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1];
    1819     1785760 :                         move16();
    1820     1785760 :                         hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[1], Q15 ); // Q30
    1821     1785760 :                         move32();
    1822             :                     }
    1823             :                 }
    1824             :             }
    1825             : 
    1826       38455 :             FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    1827             :             {
    1828     1816524 :                 FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
    1829             :                 {
    1830     1785760 :                     hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
    1831     1785760 :                     move16();
    1832     1785760 :                     hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = 0;
    1833     1785760 :                     move16();
    1834     1785760 :                     hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
    1835     1785760 :                     move16();
    1836             :                 }
    1837             :             }
    1838             :         }
    1839             :     }
    1840             :     ELSE
    1841             :     {
    1842           0 :         hSpatParamRendCom->numSimultaneousDirections = 1;
    1843           0 :         move16();
    1844           0 :         azimuth[0] = extract_l( L_shr( ( L_add( hParamIsmDec->azimuth_values_fx[0], ( 1 << 21 ) ) ), 22 ) ); // Q0
    1845           0 :         move16();
    1846           0 :         elevation[0] = extract_l( L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ( 1 << 21 ) ), 22 ) ); // Q0
    1847           0 :         move16();
    1848             : 
    1849           0 :         FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    1850             :         {
    1851           0 :             FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
    1852             :             {
    1853           0 :                 hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
    1854           0 :                 move16();
    1855           0 :                 hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
    1856           0 :                 move16();
    1857           0 :                 hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = ONE_IN_Q30; /* 1.0f in Q30 */
    1858           0 :                 move32();
    1859           0 :                 hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
    1860           0 :                 move16();
    1861           0 :                 hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
    1862           0 :                 move16();
    1863             :             }
    1864             :         }
    1865             :     }
    1866        7955 :     return;
    1867             : }

Generated by: LCOV version 1.14