LCOV - code coverage report
Current view: top level - lib_dec - ivas_out_setup_conversion.c (source / functions) Hit Total Coverage
Test: Coverage on main @ fec202a8f89be4a2f278a9fc377bfb58b58fab11 Lines: 424 443 95.7 %
Date: 2025-09-11 08:49:05 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include <math.h>
      36             : #include <assert.h>
      37             : #include "prot.h"
      38             : #include "ivas_prot.h"
      39             : #include "ivas_prot_rend.h"
      40             : #include "ivas_rom_com.h"
      41             : #include "ivas_rom_rend.h"
      42             : #ifdef DEBUGGING
      43             : #include "debug.h"
      44             : #endif
      45             : #include "wmc_auto.h"
      46             : 
      47             : 
      48             : /*----------------------------------------------------------------------------------*
      49             :  * Local constants
      50             :  *----------------------------------------------------------------------------------*/
      51             : 
      52             : #define LS_OUT_CONV_SMOOTHING_FACTOR 0.0435f
      53             : #define LS_OUT_CONV_CLIP_FACTOR_MAX  2.0f
      54             : #define LS_OUT_CONV_CLIP_FACTOR_MIN  0.3f
      55             : 
      56             : 
      57             : /*----------------------------------------------------------------------------------*
      58             :  * Local functions
      59             :  *----------------------------------------------------------------------------------*/
      60             : 
      61   115401370 : static void ivas_lssetupconversion_computeEQFactor(
      62             :     float *outputEnergy,
      63             :     float *inputEnergy,
      64             :     float *EQ )
      65             : {
      66             :     /* Compute the Equalization Gain */
      67   115401370 :     *EQ = sqrtf( *outputEnergy / ( EPSILON + *inputEnergy ) );
      68             : 
      69             :     /* Limit the Equalization Gain */
      70   115401370 :     *EQ = min( *EQ, LS_OUT_CONV_CLIP_FACTOR_MAX );
      71   115401370 :     *EQ = max( *EQ, LS_OUT_CONV_CLIP_FACTOR_MIN );
      72             : 
      73   115401370 :     return;
      74             : }
      75             : 
      76             : 
      77        2959 : static void ivas_lssetupconversion_mdct_init_bands(
      78             :     const int16_t output_frame, /* i  : output frame length             */
      79             :     const int16_t tcx_mode,     /* i  : tcx mode (TCX10, TCX 20)        */
      80             :     int16_t *sfbOffset,         /* o  : sfb offset table                */
      81             :     int16_t *sfbCnt             /* o  : number of sfbs                  */
      82             : )
      83             : {
      84             :     SpectrumWarping const *lpcBndsParam;
      85             :     int16_t i, cnt, specStartOffset, L_frameTCX;
      86             :     const unsigned char *sfbWidths;
      87             : 
      88        2959 :     L_frameTCX = ( tcx_mode == TCX_20_CORE ) ? output_frame : ( output_frame / 2 );
      89             : 
      90        2959 :     switch ( output_frame )
      91             :     {
      92        2291 :         case L_FRAME48k:
      93             :         case L_FRAME32k:
      94        2291 :             lpcBndsParam = sw32000Hz;
      95        2291 :             break;
      96           0 :         case L_FRAME25_6k:
      97           0 :             lpcBndsParam = sw25600Hz;
      98           0 :             break;
      99         668 :         case L_FRAME16k:
     100         668 :             lpcBndsParam = sw16000Hz;
     101         668 :             break;
     102           0 :         default:
     103           0 :             assert( !"Subband division not defined for this frame size" );
     104             :             return;
     105             :     }
     106             : 
     107        2959 :     sfbWidths = ( tcx_mode == TCX_20_CORE ? lpcBndsParam->bandLengthsTCX20 : lpcBndsParam->bandLengthsTCX10 );
     108        2959 :     cnt = ( tcx_mode == TCX_20_CORE ? 64 : 32 );
     109             : 
     110             :     /* calc sfb offsets */
     111        2959 :     specStartOffset = 0;
     112             : 
     113      192335 :     for ( i = 0; i < cnt; i++ )
     114             :     {
     115      189376 :         sfbOffset[i] = min( specStartOffset, L_frameTCX );
     116      189376 :         specStartOffset += sfbWidths[i];
     117             : 
     118      189376 :         if ( sfbOffset[i] >= L_frameTCX )
     119             :         {
     120           0 :             break;
     121             :         }
     122             :     }
     123             : 
     124        2959 :     *sfbCnt = i;
     125        2959 :     sfbOffset[*sfbCnt] = min( specStartOffset, L_frameTCX );
     126             : 
     127        2959 :     if ( sfbOffset[*sfbCnt] < L_frameTCX )
     128             :     {
     129        1352 :         int16_t nMissingBins = L_frameTCX - sfbOffset[*sfbCnt];
     130             : 
     131        1352 :         if ( sfbWidths[i] / 2 < nMissingBins )
     132             :         {
     133        1352 :             ( *sfbCnt )++;
     134             :         }
     135        1352 :         sfbOffset[*sfbCnt] = L_frameTCX;
     136             :     }
     137             : 
     138        2959 :     return;
     139             : }
     140             : 
     141             : 
     142           4 : static void get_custom_ls_conversion_matrix(
     143             :     const EFAP_HANDLE hEFAPdata,                 /* i  : EFAP handle                            */
     144             :     const IVAS_OUTPUT_SETUP hTransSetup,         /* i  : Transport channel configuration handle */
     145             :     const LSSETUP_CUSTOM_HANDLE hLsSetupCustom,  /* i  : Custom LS Setup handle                 */
     146             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion /* o  : LS Setup Conversion Handle             */
     147             : )
     148             : {
     149             :     int16_t ch_in, ch_in_woLFE;
     150             :     int16_t ch_out, ch_out_woLFE;
     151             :     int16_t nchan_in, nchan_out;
     152             :     int16_t lfe_in_idx, lfe_out_idx;
     153             : 
     154             :     float dmxCoeff_LFE;
     155             :     float tmp_gains[MAX_OUTPUT_CHANNELS];
     156             : 
     157           4 :     lfe_in_idx = -1;
     158           4 :     lfe_out_idx = -1;
     159             : 
     160           4 :     nchan_in = hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe;
     161           4 :     nchan_out = hLsSetupCustom->num_spk + hLsSetupCustom->num_lfe;
     162             : 
     163             :     /* The below code will need to be restructured in case additional LFEs must be supported */
     164           4 :     if ( hTransSetup.num_lfe > 0 )
     165             :     {
     166           4 :         lfe_in_idx = hTransSetup.index_lfe[0];
     167             :     }
     168           4 :     if ( hLsSetupCustom->num_lfe > 0 )
     169             :     {
     170           0 :         lfe_out_idx = hLsSetupCustom->lfe_idx[0];
     171             :     }
     172             : 
     173           4 :     dmxCoeff_LFE = 1.f / hTransSetup.nchan_out_woLFE;
     174             : 
     175          28 :     for ( ch_in = 0, ch_in_woLFE = 0; ch_in < nchan_in; ch_in++, ch_in_woLFE++ )
     176             :     {
     177          24 :         if ( lfe_in_idx == ch_in )
     178             :         {
     179           4 :             if ( lfe_out_idx >= 0 )
     180             :             {
     181             :                 /* re-route LFE */
     182           0 :                 hLsSetUpConversion->dmxMtx[ch_in][lfe_out_idx] = 1.0f;
     183             :             }
     184             :             else
     185             :             {
     186             :                 /* mix the LFE to all channels */
     187           4 :                 set_f( hLsSetUpConversion->dmxMtx[ch_in], dmxCoeff_LFE, nchan_out );
     188             :             }
     189             : 
     190           4 :             ch_in_woLFE--;
     191             :         }
     192          20 :         else if ( lfe_out_idx != ch_in )
     193             :         {
     194             :             /* Set the values of hLsSetUpConversion->dmxMtx to EFAP gains, skipping LFE */
     195          20 :             efap_determine_gains( hEFAPdata, tmp_gains, hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], EFAP_MODE_EFAP );
     196             : 
     197         340 :             for ( ch_out = 0, ch_out_woLFE = 0; ch_out < nchan_out; ch_out++, ch_out_woLFE++ )
     198             :             {
     199         320 :                 if ( lfe_out_idx == ch_out )
     200             :                 {
     201           0 :                     ch_out_woLFE--;
     202             :                 }
     203             :                 else
     204             :                 {
     205         320 :                     hLsSetUpConversion->dmxMtx[ch_in][ch_out] = tmp_gains[ch_out_woLFE];
     206             :                 }
     207             :             }
     208             :         }
     209             :     }
     210             : 
     211           4 :     return;
     212             : }
     213             : 
     214             : 
     215        4148 : static ivas_error get_ls_conversion_matrix(
     216             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion,
     217             :     const AUDIO_CONFIG input_config,
     218             :     const AUDIO_CONFIG output_config )
     219             : {
     220             :     int16_t i, k;
     221             :     int16_t ch_in, ch_out;
     222             :     int16_t nchan_in, nchan_out;
     223             :     int16_t index;
     224             :     float value;
     225             :     const LS_CONVERSION_MATRIX *conversion_matrix;
     226             : 
     227        4148 :     conversion_matrix = NULL;
     228             : 
     229        4148 :     nchan_in = audioCfg2channels( input_config );
     230        4148 :     nchan_out = audioCfg2channels( output_config );
     231             : 
     232             :     /* Search the table for a mapping */
     233       89115 :     for ( i = 0; i < LS_SETUP_CONVERSION_NUM_MAPPINGS; i++ )
     234             :     {
     235       89115 :         if ( ( input_config == ls_conversion_mapping[i].input_config ) && ( output_config == ls_conversion_mapping[i].output_config ) )
     236             :         {
     237             :             /* Special handling for MONO and STEREO downmix */
     238        4148 :             if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO )
     239             :             {
     240        9105 :                 for ( ch_in = 0, k = 0; ch_in < nchan_in; ch_in++, k++ )
     241             :                 {
     242             :                     /* Skip two rows in the matrix for 5.1.x formats */
     243        8216 :                     if ( ch_in == 6 && ( input_config == IVAS_AUDIO_CONFIG_5_1_2 || input_config == IVAS_AUDIO_CONFIG_5_1_4 ) )
     244             :                     {
     245         313 :                         k += 2;
     246             :                     }
     247             : 
     248       22212 :                     for ( ch_out = 0; ch_out < nchan_out; ch_out++ )
     249             :                     {
     250       13996 :                         if ( output_config == IVAS_AUDIO_CONFIG_MONO )
     251             :                         {
     252        2436 :                             hLsSetUpConversion->dmxMtx[ch_in][ch_out] = ls_conversion_cicpX_mono[k][ch_out];
     253             :                         }
     254             :                         else
     255             :                         {
     256       11560 :                             hLsSetUpConversion->dmxMtx[ch_in][ch_out] = ls_conversion_cicpX_stereo[k][ch_out];
     257             :                         }
     258             :                     }
     259             :                 }
     260         889 :                 return IVAS_ERR_OK;
     261             :             }
     262             :             else
     263             :             {
     264        3259 :                 conversion_matrix = ls_conversion_mapping[i].conversion_matrix;
     265             : 
     266             :                 /* If a mapping is defined with a NULL matrix, 1:1 upmix of input channels */
     267        3259 :                 if ( conversion_matrix == NULL )
     268             :                 {
     269       13837 :                     for ( k = 0; k < nchan_in; k++ )
     270             :                     {
     271       11406 :                         hLsSetUpConversion->dmxMtx[k][k] = 1.0f;
     272             :                     }
     273        2431 :                     return IVAS_ERR_OK;
     274             :                 }
     275             :                 else
     276             :                 {
     277        8856 :                     for ( k = 1; k < ( conversion_matrix[0].index + 1 ); k++ )
     278             :                     {
     279        8028 :                         index = conversion_matrix[k].index;
     280        8028 :                         value = conversion_matrix[k].value;
     281             : 
     282        8028 :                         ch_in = index / nchan_out;
     283        8028 :                         ch_out = index % nchan_out;
     284             : 
     285        8028 :                         hLsSetUpConversion->dmxMtx[ch_in][ch_out] = value;
     286             :                     }
     287             :                 }
     288         828 :                 return IVAS_ERR_OK;
     289             :             }
     290             :         }
     291             :     }
     292             : 
     293           0 :     return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "The conversion matrix between these formats is not defined!\n" );
     294             : }
     295             : 
     296             : 
     297             : /*-------------------------------------------------------------------------
     298             :  * ivas_ls_setup_conversion_open()
     299             :  *
     300             :  * Open the LS configuration Conversion Module
     301             :  *-------------------------------------------------------------------------*/
     302             : 
     303        4152 : ivas_error ivas_ls_setup_conversion_open(
     304             :     Decoder_Struct *st_ivas /* i/o: IVAS decoder structure  */
     305             : )
     306             : {
     307             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
     308             :     int16_t chIdx, inChannels, outChannels;
     309             :     int16_t output_frame;
     310             :     int32_t output_Fs;
     311             :     int16_t paramUpmixMonoStereo;
     312             :     ivas_error error;
     313             : 
     314        4152 :     if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
     315             :     {
     316          85 :         paramUpmixMonoStereo = TRUE;
     317             :     }
     318             :     else
     319             :     {
     320        4067 :         paramUpmixMonoStereo = FALSE;
     321             :     }
     322        4152 :     output_Fs = st_ivas->hDecoderConfig->output_Fs;
     323        4152 :     outChannels = st_ivas->hDecoderConfig->nchan_out;
     324        4152 :     output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC );
     325             : 
     326             :     /* Allocate memory to the handle */
     327        4152 :     if ( ( hLsSetUpConversion = (LSSETUP_CONVERSION_HANDLE) malloc( sizeof( LSSETUP_CONVERSION_STRUCT ) ) ) == NULL )
     328             :     {
     329           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
     330             :     }
     331             : 
     332        4152 :     assert( outChannels <= MAX_OUTPUT_CHANNELS );
     333             : 
     334        4152 :     if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC )
     335             :     {
     336        1193 :         inChannels = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
     337        1193 :         hLsSetUpConversion->sfbCnt = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f );
     338       11821 :         for ( chIdx = 0; chIdx < outChannels; chIdx++ )
     339             :         {
     340       10628 :             if ( ( hLsSetUpConversion->targetEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL )
     341             :             {
     342           0 :                 return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
     343             :             }
     344       10628 :             if ( ( hLsSetUpConversion->dmxEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL )
     345             :             {
     346           0 :                 return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
     347             :             }
     348       10628 :             set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt );
     349       10628 :             set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt );
     350             :         }
     351        9653 :         for ( ; chIdx < MAX_LS_CHANNELS; chIdx++ )
     352             :         {
     353        8460 :             hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL;
     354        8460 :             hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL;
     355             :         }
     356             :     }
     357             :     else
     358             :     {
     359        2959 :         if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
     360             :         {
     361         109 :             if ( paramUpmixMonoStereo == TRUE )
     362             :             {
     363          85 :                 inChannels = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 );
     364             :             }
     365             :             else
     366             :             {
     367          24 :                 inChannels = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
     368             :             }
     369             :         }
     370             :         else
     371             :         {
     372        2850 :             inChannels = st_ivas->nchan_transport;
     373             :         }
     374             : 
     375             :         /*Initialization of MDCT bands with TCX20 resolution */
     376        2959 :         ivas_lssetupconversion_mdct_init_bands( output_frame, TCX_20_CORE, &hLsSetUpConversion->sfbOffset[0], &hLsSetUpConversion->sfbCnt );
     377        2959 :         if ( ( hLsSetUpConversion->targetEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL )
     378             :         {
     379           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
     380             :         }
     381        2959 :         if ( ( hLsSetUpConversion->dmxEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL )
     382             :         {
     383           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
     384             :         }
     385             : 
     386       47344 :         for ( chIdx = 1; chIdx < MAX_LS_CHANNELS; chIdx++ )
     387             :         {
     388       44385 :             hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL;
     389       44385 :             hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL;
     390             :         }
     391        2959 :         set_f( hLsSetUpConversion->targetEnergyPrev[0], 0.0f, MAX_SFB + 2 );
     392        2959 :         set_f( hLsSetUpConversion->dmxEnergyPrev[0], 0.0f, MAX_SFB + 2 );
     393             :     }
     394             : 
     395             : 
     396             :     /* Initialize the DMX conversion matrix */
     397       31486 :     for ( chIdx = 0; chIdx < inChannels; chIdx++ )
     398             :     {
     399             :         /* Allocate memory depending on the number of output channels */
     400       27334 :         if ( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) malloc( outChannels * sizeof( float ) ) ) == NULL )
     401             :         {
     402           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for temp dmx matrix \n" ) );
     403             :         }
     404       27334 :         set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels );
     405             :     }
     406             : 
     407       43250 :     for ( ; chIdx < MAX_LS_CHANNELS; chIdx++ )
     408             :     {
     409       39098 :         hLsSetUpConversion->dmxMtx[chIdx] = NULL;
     410             :     }
     411             : 
     412        4152 :     if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
     413             :     {
     414           4 :         get_custom_ls_conversion_matrix( st_ivas->hEFAPdata, st_ivas->hTransSetup, st_ivas->hLsSetupCustom, hLsSetUpConversion );
     415             :     }
     416             :     else
     417             :     {
     418        4148 :         if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID )
     419             :         {
     420        3320 :             if ( paramUpmixMonoStereo == TRUE )
     421             :             {
     422          85 :                 if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
     423             :                 {
     424           0 :                     return error;
     425             :                 }
     426             :             }
     427             :             else
     428             :             {
     429        3235 :                 if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
     430             :                 {
     431           0 :                     return error;
     432             :                 }
     433             :             }
     434             :         }
     435             :         else
     436             :         {
     437         828 :             if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK )
     438             :             {
     439           0 :                 return error;
     440             :             }
     441             :         }
     442             :     }
     443             : 
     444        4152 :     st_ivas->hLsSetUpConversion = hLsSetUpConversion;
     445             : 
     446        4152 :     return IVAS_ERR_OK;
     447             : }
     448             : 
     449             : 
     450             : /*-------------------------------------------------------------------------
     451             :  * ivas_ls_setup_conversion_close()
     452             :  *
     453             :  * Close the LS configuration Conversion Module
     454             :  *-------------------------------------------------------------------------*/
     455             : 
     456       88884 : void ivas_ls_setup_conversion_close(
     457             :     LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle          */
     458             : )
     459             : {
     460             :     int16_t idx;
     461             : 
     462       88884 :     if ( hLsSetUpConversion == NULL || *hLsSetUpConversion == NULL )
     463             :     {
     464       84732 :         return;
     465             :     }
     466             : 
     467       70584 :     for ( idx = 0; idx < MAX_LS_CHANNELS; idx++ )
     468             :     {
     469       66432 :         if ( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL )
     470             :         {
     471       27334 :             free( ( *hLsSetUpConversion )->dmxMtx[idx] );
     472       27334 :             ( *hLsSetUpConversion )->dmxMtx[idx] = NULL;
     473             :         }
     474             : 
     475       66432 :         if ( ( *hLsSetUpConversion )->targetEnergyPrev[idx] != NULL )
     476             :         {
     477       13587 :             free( ( *hLsSetUpConversion )->targetEnergyPrev[idx] );
     478       13587 :             ( *hLsSetUpConversion )->targetEnergyPrev[idx] = NULL;
     479             :         }
     480             : 
     481       66432 :         if ( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] != NULL )
     482             :         {
     483       13587 :             free( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] );
     484       13587 :             ( *hLsSetUpConversion )->dmxEnergyPrev[idx] = NULL;
     485             :         }
     486             :     }
     487             : 
     488        4152 :     free( *hLsSetUpConversion );
     489        4152 :     *hLsSetUpConversion = NULL;
     490             : 
     491        4152 :     return;
     492             : }
     493             : 
     494             : 
     495             : /*-------------------------------------------------------------------------
     496             :  * ivas_ls_setup_conversion()
     497             :  *
     498             :  * Convert (downmix or upmix) the input LS configuration
     499             :  * to output LS configuration in time domain
     500             :  *-------------------------------------------------------------------------*/
     501             : 
     502      215889 : void ivas_ls_setup_conversion(
     503             :     Decoder_Struct *st_ivas,    /* i  : IVAS decoder structure           */
     504             :     const int16_t input_chans,  /* i  : number of input channels to the renderer        */
     505             :     const int16_t output_frame, /* i  : frame length                     */
     506             :     float *input[],             /* i  : LS input/output synthesis signal */
     507             :     float *output[]             /* i/o: LS input/output synthesis signal */
     508             : )
     509             : {
     510             :     int16_t chInIdx, chOutIdx, idx;
     511             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
     512             :     float dmxCoeff, tmpVal;
     513             :     float output_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k];
     514             : 
     515      215889 :     push_wmops( "LS_Renderer" );
     516             : 
     517      215889 :     hLsSetUpConversion = st_ivas->hLsSetUpConversion;
     518             : 
     519     1917015 :     for ( chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ )
     520             :     {
     521     1701126 :         set_zero( output_tmp[chOutIdx], output_frame );
     522    11047533 :         for ( chInIdx = 0; chInIdx < input_chans; chInIdx++ )
     523             :         {
     524     9346407 :             dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx];
     525             : 
     526     9346407 :             if ( dmxCoeff == 0.f )
     527             :             {
     528     7773514 :                 continue;
     529             :             }
     530     1572893 :             else if ( dmxCoeff == 1.f )
     531             :             {
     532   571415126 :                 for ( idx = 0; idx < output_frame; idx++ )
     533             :                 {
     534   570539800 :                     output_tmp[chOutIdx][idx] += input[chInIdx][idx];
     535             :                 }
     536             :             }
     537             :             else
     538             :             {
     539   518606687 :                 for ( idx = 0; idx < output_frame; idx++ )
     540             :                 {
     541   517909120 :                     tmpVal = dmxCoeff * input[chInIdx][idx];
     542   517909120 :                     output_tmp[chOutIdx][idx] += tmpVal;
     543             :                 }
     544             :             }
     545             :         }
     546             :     }
     547             : 
     548             :     /* Copy to output buffer */
     549     1917015 :     for ( chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ )
     550             :     {
     551     1701126 :         mvr2r( output_tmp[chOutIdx], output[chOutIdx], output_frame );
     552             :     }
     553             : 
     554      215889 :     pop_wmops();
     555             : 
     556      215889 :     return;
     557             : }
     558             : 
     559             : 
     560             : /*-------------------------------------------------------------------------
     561             :  * ivas_ls_setup_conversion_process_mdct()
     562             :  *
     563             :  * Equalization in MDCT Domain
     564             :  *-------------------------------------------------------------------------*/
     565             : 
     566      132458 : void ivas_ls_setup_conversion_process_mdct(
     567             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure          */
     568             :     float *output[]          /* i/o: output synthesis signal         */
     569             : )
     570             : {
     571             :     /* Declaration of all required variables */
     572             :     int16_t i, bandIdx, chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx, idx;
     573             :     int16_t inChannels, outChannels, num_CPE;
     574             :     int16_t transform_type[MAX_LS_CHANNELS][2];
     575             :     int16_t frameSize;
     576             :     float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2];
     577             :     float dmxCoeff;
     578             :     float dmxSignalReal[L_FRAME48k], dmxSignalImag[L_FRAME48k];
     579             :     float eqGain;
     580             :     float *sig[NB_DIV], *pTmp[NB_DIV], *x[MAX_LS_CHANNELS][NB_DIV];
     581             :     float mdst[L_FRAME48k];
     582             :     float convertRes[L_FRAME48k];
     583             :     int16_t start, stop, start_tcx5, stop_tcx5;
     584             :     int16_t mct_chan_mode[MAX_LS_CHANNELS];
     585             : 
     586             :     /* Declare all handles */
     587             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
     588             :     CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS];
     589             : 
     590      132458 :     push_wmops( "LS_Renderer_MDCT" );
     591             : 
     592             :     /* Assign all the declared variables */
     593      132458 :     inChannels = st_ivas->nchan_transport;
     594      132458 :     outChannels = st_ivas->hDecoderConfig->nchan_out;
     595      132458 :     num_CPE = st_ivas->nCPE;
     596             : 
     597             :     /* Assign output pointer to variable x */
     598     1082216 :     for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ )
     599             :     {
     600      949758 :         x[chInIdx][0] = output[chInIdx];
     601      949758 :         x[chInIdx][1] = output[chInIdx] + ( L_FRAME48k / 2 );
     602             :     }
     603             : 
     604             :     /* Assign all the declared handles*/
     605      132458 :     hLsSetUpConversion = st_ivas->hLsSetUpConversion;
     606      607337 :     for ( cpe_idx = 0; cpe_idx < num_CPE; cpe_idx++ )
     607             :     {
     608      474879 :         hCPE[cpe_idx] = st_ivas->hCPE[cpe_idx];
     609             :     }
     610             : 
     611             :     /* Get the core type */
     612      607337 :     for ( cpe_idx = 0; cpe_idx < num_CPE; cpe_idx++ )
     613             :     {
     614     1424637 :         for ( idx = 0; idx < CPE_CHANNELS; idx++ )
     615             :         {
     616             :             /* get the channel index */
     617      949758 :             chInIdx = cpe_idx * CPE_CHANNELS + idx;
     618      949758 :             assert( chInIdx <= inChannels );
     619      949758 :             transform_type[chInIdx][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0];
     620      949758 :             transform_type[chInIdx][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1];
     621      949758 :             mct_chan_mode[chInIdx] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode;
     622             :         }
     623             :     }
     624             : 
     625             :     /* set overall frequency resolution of (sub)frame to maximum of (sub)frame, requires conversion if both channels are not the same */
     626      132458 :     frameSize = hLsSetUpConversion->sfbOffset[hLsSetUpConversion->sfbCnt];
     627             : 
     628      132458 :     set_zero( targetEnergy, MAX_SFB + 2 );
     629      132458 :     set_zero( dmxEnergy, MAX_SFB + 2 );
     630             : 
     631     1069638 :     for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
     632             :     {
     633             :         /* Step 0: Set the buffers to zero */
     634      937180 :         set_zero( dmxSignalReal, frameSize );
     635      937180 :         set_zero( dmxSignalImag, frameSize );
     636             : 
     637     7459360 :         for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ )
     638             :         {
     639     6522180 :             dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx];
     640             : 
     641     6522180 :             if ( chInIdx != LFE_CHANNEL && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
     642             :             {
     643             :                 /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */
     644     4638661 :                 if ( dmxCoeff )
     645             :                 {
     646             :                     float tmpDMXSig, targetEne;
     647             : 
     648             :                     /* Convert the signal resolution to TCX20 */
     649             :                     /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */
     650      742234 :                     sig[0] = pTmp[0] = x[chInIdx][0];
     651      742234 :                     sig[1] = pTmp[1] = x[chInIdx][1];
     652             : 
     653             :                     /* convert (sub)frames to higher frequency resolution */
     654      742234 :                     if ( transform_type[chInIdx][0] != TCX_20 )
     655             :                     {
     656       92766 :                         for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
     657             :                         {
     658       61844 :                             if ( transform_type[chInIdx][subFrameIdx] == TCX_5 )
     659             :                             {
     660             :                                 /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */
     661       31146 :                                 pTmp[subFrameIdx] = sig[subFrameIdx] = convertRes + subFrameIdx * frameSize / 2;
     662       31146 :                                 convert_coeffs_to_higher_res( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 );
     663             :                             }
     664             :                         }
     665             : 
     666             :                         /* convert channel with TCX10 to TCX20 resolution */
     667       30922 :                         sig[0] = convertRes;
     668       30922 :                         convert_coeffs_to_higher_res( pTmp[0], pTmp[1], sig[0], frameSize / 2 );
     669             :                     }
     670             : 
     671             :                     /* MDST estimate */
     672      742234 :                     mdst[0] = mdst[frameSize - 1] = 0.f;
     673   578528486 :                     for ( i = 1; i < frameSize - 1; i++ )
     674             :                     {
     675   577786252 :                         mdst[i] = sig[0][i + 1] - sig[0][i - 1];
     676             :                     }
     677             : 
     678    48701119 :                     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     679             :                     {
     680    47958885 :                         start = hLsSetUpConversion->sfbOffset[bandIdx];
     681    47958885 :                         stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
     682             : 
     683    47958885 :                         targetEne = 0.0f;
     684             : 
     685             :                         /* Loop over all the bins in the band */
     686   627229605 :                         for ( binIdx = start; binIdx < stop; binIdx++ )
     687             :                         {
     688   579270720 :                             tmpDMXSig = dmxCoeff * sig[0][binIdx];
     689   579270720 :                             dmxSignalReal[binIdx] += tmpDMXSig;
     690   579270720 :                             targetEne += tmpDMXSig * tmpDMXSig;
     691             : 
     692   579270720 :                             tmpDMXSig = dmxCoeff * mdst[binIdx];
     693   579270720 :                             dmxSignalImag[binIdx] += tmpDMXSig;
     694   579270720 :                             targetEne += tmpDMXSig * tmpDMXSig;
     695             :                         }
     696    47958885 :                         targetEnergy[bandIdx] += targetEne;
     697             :                     } /* end of band loop */
     698             :                 }
     699             :             }
     700             :         } /* end of chInIdx loop */
     701             : 
     702    61604402 :         for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     703             :         {
     704             :             float tmpReal, tmpImag, DMXEne;
     705             : 
     706    60667222 :             start = hLsSetUpConversion->sfbOffset[bandIdx];
     707    60667222 :             stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
     708             : 
     709             :             /* Loop over all the bins in the band */
     710    60667222 :             DMXEne = 0.0f;
     711   841475542 :             for ( binIdx = start; binIdx < stop; binIdx++ )
     712             :             {
     713   780808320 :                 tmpReal = dmxSignalReal[binIdx];
     714   780808320 :                 tmpImag = dmxSignalImag[binIdx];
     715             : 
     716   780808320 :                 DMXEne += tmpReal * tmpReal + tmpImag * tmpImag;
     717             :             }
     718    60667222 :             dmxEnergy[bandIdx] += DMXEne;
     719             :         }
     720             :     } /* end of out channel loop */
     721             : 
     722             :     /* Step 3: Peform energy smoothing */
     723     8701413 :     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     724             :     {
     725     8568955 :         targetEnergy[bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * targetEnergy[bandIdx] + ( 1.0f - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->targetEnergyPrev[0][bandIdx];
     726     8568955 :         dmxEnergy[bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * dmxEnergy[bandIdx] + ( 1.0f - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->dmxEnergyPrev[0][bandIdx];
     727     8568955 :         hLsSetUpConversion->targetEnergyPrev[0][bandIdx] = targetEnergy[bandIdx];
     728     8568955 :         hLsSetUpConversion->dmxEnergyPrev[0][bandIdx] = dmxEnergy[bandIdx];
     729             :     }
     730             : 
     731             :     /* Step 4: Perform equalization */
     732     1082216 :     for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ )
     733             :     {
     734      949758 :         if ( chInIdx != LFE_CHANNEL && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
     735             :         {
     736      683672 :             if ( transform_type[chInIdx][0] == TCX_20 )
     737             :             {
     738             :                 /* TCX20 */
     739    42951136 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     740             :                 {
     741    42296510 :                     start = hLsSetUpConversion->sfbOffset[bandIdx];
     742    42296510 :                     stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
     743             : 
     744             :                     /* Compute Eq gains */
     745    42296510 :                     ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
     746   551848510 :                     for ( binIdx = start; binIdx < stop; binIdx++ )
     747             :                     {
     748   509552000 :                         x[chInIdx][0][binIdx] *= eqGain;
     749             :                     }
     750             :                 }
     751             :             }
     752             :             else
     753             :             {
     754       29046 :                 stop_tcx5 = 0;
     755     1902050 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     756             :                 {
     757     1873004 :                     start = hLsSetUpConversion->sfbOffset[bandIdx] / 2;
     758     1873004 :                     stop = hLsSetUpConversion->sfbOffset[bandIdx + 1] / 2;
     759             : 
     760             :                     /* Compute Eq gains */
     761     1873004 :                     ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
     762             : 
     763     5619012 :                     for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
     764             :                     {
     765     3746008 :                         if ( transform_type[chInIdx][subFrameIdx] == TCX_10 )
     766             :                         {
     767             :                             /* TCX10 */
     768    12417233 :                             for ( binIdx = start; binIdx < stop; binIdx++ )
     769             :                             {
     770    10557280 :                                 x[chInIdx][subFrameIdx][binIdx] *= eqGain;
     771             :                             }
     772             :                         }
     773             :                         else
     774             :                         {
     775             :                             /* TCX5*/
     776     1886055 :                             start_tcx5 = stop_tcx5;
     777     1886055 :                             stop_tcx5 = ( stop + 1 ) / 2;
     778             : 
     779     7211815 :                             for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ )
     780             :                             {
     781     5325760 :                                 x[chInIdx][subFrameIdx][binIdx] *= eqGain;
     782     5325760 :                                 x[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain;
     783             :                             }
     784             :                         }
     785             :                     }
     786             :                 }
     787             :             }
     788             :         }
     789             :     }
     790             : 
     791      132458 :     pop_wmops();
     792      132458 :     return;
     793             : }
     794             : 
     795             : 
     796             : /*-------------------------------------------------------------------------
     797             :  * ivas_ls_setup_conversion_process_mdct_param_mc()
     798             :  *
     799             :  * Equalization in MDCT Domain
     800             :  *-------------------------------------------------------------------------*/
     801             : 
     802        9272 : void ivas_ls_setup_conversion_process_mdct_param_mc(
     803             :     Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure          */
     804             :     float *x[][NB_DIV]       /* i/o: output synthesis signal         */
     805             : )
     806             : {
     807             :     /* Declaration of all required variables */
     808             :     int16_t i;
     809             :     int16_t idx;
     810             :     int16_t nchan_transport, nchan_out, nchan_transport_format;
     811             :     int16_t chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx;
     812             :     int16_t band, bandIdx, num_bands;
     813             : 
     814             :     int16_t num_CPE;
     815             :     int16_t transform_type[MAX_LS_CHANNELS][2];
     816             :     int16_t frameSize;
     817             : 
     818             :     float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2];
     819             :     float eqGain;
     820             :     float *sig[MAX_LS_CHANNELS][NB_DIV], *pTmp[NB_DIV];
     821             :     float mdst[MAX_LS_CHANNELS][L_FRAME48k];
     822             :     float convertRes[MAX_LS_CHANNELS][L_FRAME48k];
     823             :     int16_t start, stop, start_tcx5, stop_tcx5;
     824             :     int16_t mct_chan_mode[MAX_LS_CHANNELS];
     825             : 
     826             :     float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
     827             :     float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
     828             :     float cy[MAX_LS_CHANNELS * MAX_LS_CHANNELS];
     829             :     float real_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
     830             :     float imag_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
     831             :     float real_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
     832             :     float imag_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
     833             : 
     834             :     float Nrqq[MAX_OUTPUT_CHANNELS];
     835             :     float target_ch_ener[MAX_OUTPUT_CHANNELS];
     836             :     float *ild_q;
     837             : 
     838             :     float DMXEne;
     839             :     float dmxCoeff;
     840             :     float dmxSignalReal[L_FRAME48k], dmxSignalImag[L_FRAME48k];
     841             : 
     842             :     float tmpReal, tmpImag;
     843             :     float tmpDMXSig;
     844             : 
     845             :     /* Declare all handles */
     846             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
     847             :     CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS];
     848             :     PARAM_MC_DEC_HANDLE hParamMC;
     849             : 
     850             :     /* Step 0: Set the buffers to zero */
     851        9272 :     set_zero( dmxSignalReal, L_FRAME48k );
     852        9272 :     set_zero( dmxSignalImag, L_FRAME48k );
     853             : 
     854             :     /* Assign all the declared variables */
     855        9272 :     nchan_transport = st_ivas->nchan_transport;
     856        9272 :     nchan_out = st_ivas->hDecoderConfig->nchan_out;
     857        9272 :     num_CPE = st_ivas->nCPE;
     858        9272 :     nchan_transport_format = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
     859             : 
     860             :     /* Assign all the declared handles*/
     861        9272 :     hLsSetUpConversion = st_ivas->hLsSetUpConversion;
     862       22470 :     for ( cpe_idx = 0; cpe_idx < num_CPE; cpe_idx++ )
     863             :     {
     864       13198 :         hCPE[cpe_idx] = st_ivas->hCPE[cpe_idx];
     865             :     }
     866        9272 :     hParamMC = st_ivas->hParamMC;
     867             : 
     868             :     /* Get the core type */
     869       22470 :     for ( cpe_idx = 0; cpe_idx < num_CPE; cpe_idx++ )
     870             :     {
     871       39594 :         for ( idx = 0; idx < CPE_CHANNELS; idx++ )
     872             :         {
     873             :             /* get the channel index */
     874       26396 :             chInIdx = cpe_idx * CPE_CHANNELS + idx;
     875       26396 :             assert( chInIdx <= nchan_transport );
     876       26396 :             transform_type[chInIdx][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0];
     877       26396 :             transform_type[chInIdx][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1];
     878       26396 :             mct_chan_mode[chInIdx] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode;
     879             :         }
     880             :     }
     881             : 
     882             :     /* set overall frequency resolution of (sub)frame to maximum of (sub)frame, requires conversion if both channels are not the same */
     883        9272 :     frameSize = hLsSetUpConversion->sfbOffset[hLsSetUpConversion->sfbCnt];
     884             : 
     885        9272 :     set_zero( targetEnergy, MAX_SFB + 2 );
     886        9272 :     set_zero( dmxEnergy, MAX_SFB + 2 );
     887             : 
     888       31742 :     for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
     889             :     {
     890       22470 :         if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
     891             :         {
     892             :             /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */
     893       22470 :             sig[chInIdx][0] = pTmp[0] = x[chInIdx][0];
     894       22470 :             sig[chInIdx][1] = pTmp[1] = x[chInIdx][1];
     895             : 
     896             :             /* convert (sub)frames to higher frequency resolution */
     897       22470 :             if ( transform_type[chInIdx][0] != TCX_20 )
     898             :             {
     899        4053 :                 for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
     900             :                 {
     901        2702 :                     if ( transform_type[chInIdx][subFrameIdx] == TCX_5 )
     902             :                     {
     903             :                         /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */
     904        1376 :                         pTmp[subFrameIdx] = sig[chInIdx][subFrameIdx] = convertRes[chInIdx] + subFrameIdx * frameSize / 2;
     905        1376 :                         convert_coeffs_to_higher_res( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 );
     906             :                     }
     907             :                 }
     908             : 
     909             :                 /* convert channel with TCX10 to TCX20 resolution */
     910        1351 :                 sig[chInIdx][0] = convertRes[chInIdx];
     911        1351 :                 convert_coeffs_to_higher_res( pTmp[0], pTmp[1], sig[chInIdx][0], frameSize / 2 );
     912             :             }
     913             :         }
     914             :     }
     915             : 
     916             :     /* precalculate MDST estimate */
     917       31742 :     for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
     918             :     {
     919       22470 :         if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
     920             :         {
     921       22470 :             mdst[chInIdx][0] = mdst[chInIdx][frameSize - 1] = 0.f;
     922    14358330 :             for ( i = 1; i < frameSize - 1; i++ )
     923             :             {
     924    14335860 :                 mdst[chInIdx][i] = sig[chInIdx][0][i + 1] - sig[chInIdx][0][i - 1];
     925             :             }
     926             :         }
     927             :     }
     928             : 
     929             :     /* Step 1.1, calculate Cx from MDST estimate */
     930      194712 :     for ( bandIdx = 0; bandIdx < PARAM_MC_MAX_PARAMETER_BANDS; bandIdx++ )
     931             :     {
     932      185440 :         set_zero( cx[bandIdx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
     933      185440 :         set_zero( cx_imag[bandIdx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
     934             :     }
     935             : 
     936        9272 :     set_zero( Nrqq, MAX_OUTPUT_CHANNELS );
     937        9272 :     set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS );
     938             : 
     939      128818 :     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     940             :     {
     941      119546 :         set_zero( real_in_buffer, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS );
     942      119546 :         set_zero( imag_in_buffer, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS );
     943      119546 :         set_zero( real_buffer, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
     944      119546 :         set_zero( imag_buffer, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
     945             : 
     946      119546 :         start = hLsSetUpConversion->sfbOffset[bandIdx];
     947      119546 :         stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
     948      119546 :         num_bands = stop - start;
     949             : 
     950     6053626 :         for ( i = 0; i < num_bands; i++ )
     951             :         {
     952     5934080 :             band = start + i;
     953    20314880 :             for ( idx = 0; idx < nchan_transport; idx++ )
     954             :             {
     955    14380800 :                 if ( mct_chan_mode[idx] != MCT_CHAN_MODE_IGNORE )
     956             :                 {
     957    14380800 :                     real_in_buffer[i + num_bands * idx] = sig[idx][0][band];
     958    14380800 :                     imag_in_buffer[i + num_bands * idx] = mdst[idx][band];
     959             :                 }
     960             :             }
     961             :         }
     962             : 
     963      119546 :         cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_transport, real_buffer, imag_buffer );
     964             : 
     965      119546 :         v_add( cx[bandIdx], real_buffer, cx[bandIdx], nchan_transport * nchan_transport );
     966             : 
     967      119546 :         v_add( cx_imag[bandIdx], imag_buffer, cx_imag[bandIdx], nchan_transport * nchan_transport );
     968             :     }
     969             : 
     970      128818 :     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
     971             :     {
     972      119546 :         DMXEne = 0.0f;
     973      119546 :         set_zero( cy, MAX_LS_CHANNELS * MAX_LS_CHANNELS );
     974      119546 :         set_zero( Nrqq, MAX_OUTPUT_CHANNELS );
     975      119546 :         set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS );
     976             : 
     977             :         /* Step 1.2, get target channel energies for the transported format, Nrqq calculation */
     978      119546 :         ild_q = hParamMC->icld_q + bandIdx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe;
     979             : 
     980     1150574 :         for ( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ )
     981             :         {
     982     1031028 :             float ref_ener = 0.0f;
     983             :             int16_t ref_channel_cnt;
     984             :             int16_t ref_channel_idx;
     985             : 
     986     2184420 :             for ( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC->ild_mapping_conf->num_ref_channels[chInIdx]; ref_channel_cnt++ )
     987             :             {
     988     1153392 :                 ref_channel_idx = hParamMC->hMetadataPMC->ild_mapping_conf->ref_channel_idx[chInIdx][ref_channel_cnt];
     989     1153392 :                 ref_ener += cx[bandIdx][ref_channel_idx + ref_channel_idx * nchan_transport];
     990             :             }
     991             : 
     992     1031028 :             Nrqq[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[chInIdx]] = powf( 10.0f, ild_q[chInIdx] / 10.0f ) * hParamMC->hMetadataPMC->ild_factors[chInIdx] * ref_ener;
     993             :         }
     994             : 
     995             :         /* Step 1.3 get target Cy (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */
     996      305079 :         for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ )
     997             :         {
     998     1806643 :             for ( i = 0; i < nchan_transport_format; i++ )
     999             :             {
    1000     1621110 :                 target_ch_ener[chOutIdx] += hParamMC->ls_conv_dmx_matrix[chOutIdx + i * nchan_out] * Nrqq[i];
    1001             :             }
    1002      185533 :             cy[chOutIdx + nchan_out * chOutIdx] = target_ch_ener[chOutIdx];
    1003             :         }
    1004             : 
    1005             :         /* Step 1.4 final target energy for the band would then be the sum over the diagonal of Cy*/
    1006      305079 :         for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ )
    1007             :         {
    1008      185533 :             targetEnergy[bandIdx] += cy[chOutIdx + nchan_out * chOutIdx];
    1009             :         }
    1010             : 
    1011             :         /* Step 2: Calculate DMX ener */
    1012      119546 :         start = hLsSetUpConversion->sfbOffset[bandIdx];
    1013      119546 :         stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
    1014             : 
    1015      305079 :         for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ )
    1016             :         {
    1017      650359 :             for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
    1018             :             {
    1019      464826 :                 if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
    1020             :                 {
    1021      464826 :                     dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx];
    1022             : 
    1023             :                     /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */
    1024      464826 :                     if ( dmxCoeff )
    1025             :                     {
    1026             :                         /* Loop over all the bins in the band */
    1027    19758514 :                         for ( binIdx = start; binIdx < stop; binIdx++ )
    1028             :                         {
    1029    19364480 :                             tmpDMXSig = dmxCoeff * sig[chInIdx][0][binIdx];
    1030    19364480 :                             dmxSignalReal[binIdx] += tmpDMXSig;
    1031             : 
    1032    19364480 :                             tmpDMXSig = dmxCoeff * mdst[chInIdx][binIdx];
    1033    19364480 :                             dmxSignalImag[binIdx] += tmpDMXSig;
    1034             :                         }
    1035             :                     }
    1036             :                 }
    1037             :             }
    1038             : 
    1039             :             /* Loop over all the bins in the band */
    1040      185533 :             DMXEne = 0.0f;
    1041     9392573 :             for ( binIdx = start; binIdx < stop; binIdx++ )
    1042             :             {
    1043     9207040 :                 tmpReal = dmxSignalReal[binIdx];
    1044     9207040 :                 tmpImag = dmxSignalImag[binIdx];
    1045             : 
    1046     9207040 :                 DMXEne += tmpReal * tmpReal + tmpImag * tmpImag;
    1047             :             }
    1048             :         }
    1049             : 
    1050      119546 :         dmxEnergy[bandIdx] = DMXEne;
    1051             :     }
    1052             : 
    1053             :     /* Step 3: Peform energy smoothing */
    1054      128818 :     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1055             :     {
    1056      119546 :         targetEnergy[bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * targetEnergy[bandIdx] + ( 1.0f - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->targetEnergyPrev[0][bandIdx];
    1057      119546 :         dmxEnergy[bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * dmxEnergy[bandIdx] + ( 1.0f - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->dmxEnergyPrev[0][bandIdx];
    1058      119546 :         hLsSetUpConversion->targetEnergyPrev[0][bandIdx] = targetEnergy[bandIdx];
    1059      119546 :         hLsSetUpConversion->dmxEnergyPrev[0][bandIdx] = dmxEnergy[bandIdx];
    1060             :     }
    1061             : 
    1062             :     /* Step 4: Perform equalization */
    1063       31742 :     for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
    1064             :     {
    1065       22470 :         if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE )
    1066             :         {
    1067       22470 :             if ( transform_type[chInIdx][0] == TCX_20 )
    1068             :             {
    1069             :                 /*TCX20*/
    1070      300678 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1071             :                 {
    1072      279559 :                     start = hLsSetUpConversion->sfbOffset[bandIdx];
    1073      279559 :                     stop = hLsSetUpConversion->sfbOffset[bandIdx + 1];
    1074             : 
    1075             :                     /*Compute Eq gains */
    1076      279559 :                     ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
    1077    13727879 :                     for ( binIdx = start; binIdx < stop; binIdx++ )
    1078             :                     {
    1079    13448320 :                         x[chInIdx][0][binIdx] *= eqGain;
    1080             :                     }
    1081             :                 }
    1082             :             }
    1083             :             else
    1084             :             {
    1085        1351 :                 stop_tcx5 = 0;
    1086       19248 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1087             :                 {
    1088       17897 :                     start = hLsSetUpConversion->sfbOffset[bandIdx] / 2;
    1089       17897 :                     stop = hLsSetUpConversion->sfbOffset[bandIdx + 1] / 2;
    1090             : 
    1091             :                     /*Compute Eq gains */
    1092       17897 :                     ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
    1093             : 
    1094       53691 :                     for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
    1095             :                     {
    1096       35794 :                         if ( transform_type[chInIdx][subFrameIdx] == TCX_10 )
    1097             :                         {
    1098             :                             /*TCX10*/
    1099      473912 :                             for ( binIdx = start; binIdx < stop; binIdx++ )
    1100             :                             {
    1101      456320 :                                 x[chInIdx][subFrameIdx][binIdx] *= eqGain;
    1102             :                             }
    1103             :                         }
    1104             :                         else
    1105             :                         {
    1106             :                             /* TCX5*/
    1107       18202 :                             start_tcx5 = stop_tcx5;
    1108       18202 :                             stop_tcx5 = ( stop + 1 ) / 2;
    1109      251322 :                             for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ )
    1110             :                             {
    1111      233120 :                                 x[chInIdx][subFrameIdx][binIdx] *= eqGain;
    1112             :                             }
    1113             : 
    1114      251322 :                             for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ )
    1115             :                             {
    1116      233120 :                                 x[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain;
    1117             :                             }
    1118             :                         }
    1119             :                     }
    1120             :                 }
    1121             :             }
    1122             :         }
    1123             :     }
    1124             : 
    1125        9272 :     return;
    1126             : }
    1127             : 
    1128             : 
    1129             : /*-------------------------------------------------------------------------
    1130             :  * ivas_ls_setup_conversion_process_param_mc()
    1131             :  *
    1132             :  * LS setup conversion in the CLDFB domain for Parametric MC
    1133             :  *-------------------------------------------------------------------------*/
    1134             : 
    1135       60084 : void ivas_lssetupconversion_process_param_mc(
    1136             :     Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle                */
    1137             :     const int16_t num_timeslots,
    1138             :     float Cldfb_RealBuffer_InOut[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals                                         */
    1139             :     float Cldfb_ImagBuffer_InOut[MAX_LS_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals                                         */
    1140             :     int16_t channel_active[MAX_LS_CHANNELS]                                                                /* i  : bitmap indicating which output channels are active */
    1141             : )
    1142             : {
    1143             :     int16_t slotIdx, chOutIdx, chInIdx, bandIdx;
    1144             :     int16_t inChannels, outChannels;
    1145             :     float targetEnergy[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    1146             :     float dmxEnergy[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    1147             :     float tmpDMXSig, dmxCoeff, tmpReal, tmpImag;
    1148             :     float EQ;
    1149             :     float Cldfb_RealBuffer_tmp[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    1150             :     float Cldfb_ImagBuffer_tmp[MAX_LS_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    1151             :     LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
    1152             : 
    1153       60084 :     push_wmops( "LS_Renderer_Process_Param_MC" );
    1154             :     /* inits */
    1155       60084 :     inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
    1156       60084 :     outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe;
    1157             : 
    1158       60084 :     hLsSetUpConversion = st_ivas->hLsSetUpConversion;
    1159       60084 :     EQ = 0.0f;
    1160             : 
    1161       60084 :     set_s( channel_active, 0, outChannels );
    1162             : 
    1163             :     /* Loop over each time slots and compute dmx for each time slot */
    1164      300420 :     for ( slotIdx = 0; slotIdx < num_timeslots; slotIdx++ )
    1165             :     {
    1166             :         /* copy buffers */
    1167     1948464 :         for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ )
    1168             :         {
    1169     1708128 :             mvr2r( Cldfb_RealBuffer_InOut[chInIdx][slotIdx], Cldfb_RealBuffer_tmp[chInIdx], CLDFB_NO_CHANNELS_MAX );
    1170     1708128 :             mvr2r( Cldfb_ImagBuffer_InOut[chInIdx][slotIdx], Cldfb_ImagBuffer_tmp[chInIdx], CLDFB_NO_CHANNELS_MAX );
    1171             :         }
    1172             :         /* set the buffers to zero */
    1173     2753712 :         for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
    1174             :         {
    1175     2513376 :             set_f( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX );
    1176     2513376 :             set_f( Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX );
    1177             : 
    1178     2513376 :             set_f( dmxEnergy[chOutIdx], 0.0f, CLDFB_NO_CHANNELS_MAX );
    1179     2513376 :             set_f( targetEnergy[chOutIdx], 0.0f, CLDFB_NO_CHANNELS_MAX );
    1180             :         }
    1181             : 
    1182             :         /* Compute the target energy and DMX signal */
    1183     2753712 :         for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
    1184             :         {
    1185    20330784 :             for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ )
    1186             :             {
    1187    17817408 :                 dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx];
    1188    17817408 :                 if ( dmxCoeff == 0.0f )
    1189             :                 {
    1190    16109280 :                     continue;
    1191             :                 }
    1192             :                 else
    1193             :                 {
    1194     1708128 :                     channel_active[chOutIdx] |= 1;
    1195    77204448 :                     for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1196             :                     {
    1197    75496320 :                         tmpDMXSig = dmxCoeff * Cldfb_RealBuffer_tmp[chInIdx][bandIdx];
    1198    75496320 :                         Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig;
    1199    75496320 :                         targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig;
    1200             : 
    1201    75496320 :                         tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[chInIdx][bandIdx];
    1202    75496320 :                         Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig;
    1203    75496320 :                         targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig;
    1204             :                     }
    1205             :                 }
    1206             :             }
    1207             :         }
    1208             : 
    1209             :         /* Compute the DMX energy */
    1210     2753712 :         for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
    1211             :         {
    1212     2513376 :             if ( channel_active[chOutIdx] )
    1213             :             {
    1214    72528480 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1215             :                 {
    1216    70934400 :                     tmpReal = Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx];
    1217    70934400 :                     tmpImag = Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx];
    1218             : 
    1219    70934400 :                     dmxEnergy[chOutIdx][bandIdx] = tmpReal * tmpReal + tmpImag * tmpImag;
    1220             :                 }
    1221             :             }
    1222             :         }
    1223             : 
    1224             :         /* Peform energy smoothing */
    1225     2753712 :         for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
    1226             :         {
    1227     2513376 :             if ( channel_active[chOutIdx] )
    1228             :             {
    1229    72528480 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1230             :                 {
    1231    70934400 :                     targetEnergy[chOutIdx][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * targetEnergy[chOutIdx][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->targetEnergyPrev[chOutIdx][bandIdx];
    1232    70934400 :                     dmxEnergy[chOutIdx][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * dmxEnergy[chOutIdx][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->dmxEnergyPrev[chOutIdx][bandIdx];
    1233    70934400 :                     hLsSetUpConversion->targetEnergyPrev[chOutIdx][bandIdx] = targetEnergy[chOutIdx][bandIdx];
    1234    70934400 :                     hLsSetUpConversion->dmxEnergyPrev[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx];
    1235             :                 }
    1236             :             }
    1237             :         }
    1238             : 
    1239             :         /* Compute and perform equalization */
    1240     2753712 :         for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ )
    1241             :         {
    1242     2513376 :             if ( channel_active[chOutIdx] )
    1243             :             {
    1244    72528480 :                 for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
    1245             :                 {
    1246    70934400 :                     ivas_lssetupconversion_computeEQFactor( &targetEnergy[chOutIdx][bandIdx], &dmxEnergy[chOutIdx][bandIdx], &EQ );
    1247    70934400 :                     Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] *= EQ;
    1248    70934400 :                     Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] *= EQ;
    1249             :                 }
    1250             :             }
    1251             :         }
    1252             :     }
    1253             : 
    1254       60084 :     pop_wmops();
    1255       60084 :     return;
    1256             : }

Generated by: LCOV version 1.14