LCOV - code coverage report
Current view: top level - lib_enc - ivas_stereo_icbwe_enc_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 2805f2da05bf6a0aa6cf155d214db90e4067f547 Lines: 745 784 95.0 %
Date: 2025-05-20 03:25:13 Functions: 8 8 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 "cnst.h"
      37             : #include "ivas_cnst.h"
      38             : #include "prot_fx.h"
      39             : #include "wmc_auto.h"
      40             : #include "rom_com.h"
      41             : #include "ivas_rom_com.h"
      42             : 
      43             : #include "ivas_prot_fx.h"
      44             : #include "ivas_rom_com_fx.h"
      45             : 
      46             : /*-------------------------------------------------------------------*
      47             :  * ic_bwe_enc_reset()
      48             :  *
      49             :  * core switching reset of IC BWE memory
      50             :  *-------------------------------------------------------------------*/
      51       22778 : static void ic_bwe_enc_reset_fx(
      52             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo ICBWE handle */
      53             : )
      54             : {
      55             :     /* unscaled & scaled SHB synthesis memory */
      56       22778 :     set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER );
      57       22778 :     hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
      58       22778 :     move16();
      59             :     /* inter-channel BWE spectral shape adj. */
      60       22778 :     hStereoICBWE->prevSpecMapping_fx = 0;
      61       22778 :     move32();
      62       22778 :     hStereoICBWE->prevgsMapping_fx = ONE_IN_Q31; /* Q31 */
      63       22778 :     move32();
      64       22778 :     hStereoICBWE->prevgsMapping_e = 0;
      65       22778 :     move16();
      66       22778 :     set32_fx( &( hStereoICBWE->memShbSpecMapping_fx ), 0, 1 );
      67       22778 :     hStereoICBWE->memShbSpecMapping_e = 0;
      68       22778 :     move16();
      69       22778 :     set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
      70       22778 :     hStereoICBWE->memShbSpecXcorr_e = 0;
      71       22778 :     move16();
      72       22778 :     set32_fx( hStereoICBWE->memGsEnerMap_fx, ONE_IN_Q31, 2 ); /* Q31 */
      73       22778 :     hStereoICBWE->memGsEnerMap_e = 0;
      74       22778 :     move16();
      75       22778 :     set32_fx( hStereoICBWE->mem_nrg_L_fx, 0, 2 );
      76       22778 :     hStereoICBWE->mem_nrg_L_fx_e = 0;
      77       22778 :     move16();
      78       22778 :     set32_fx( hStereoICBWE->mem_nrg_R_fx, 0, 2 );
      79       22778 :     hStereoICBWE->mem_nrg_R_fx_e = 0;
      80       22778 :     move16();
      81       22778 :     set32_fx( hStereoICBWE->mem_nrg_DMX_fx, 0, 2 );
      82       22778 :     hStereoICBWE->mem_nrg_DMX_fx_e = 0;
      83       22778 :     move16();
      84       22778 :     hStereoICBWE->gDes_pastFrame_fx = ONE_IN_Q31; /* Q31 */
      85       22778 :     move32();
      86       22778 :     hStereoICBWE->gDes_pastFrame_e = 0;
      87       22778 :     move16();
      88       22778 :     hStereoICBWE->icbweRefEner_fx = 0;
      89       22778 :     move32();
      90       22778 :     hStereoICBWE->icbweRefEner_fx_e = 0;
      91       22778 :     move16();
      92             : 
      93       22778 :     return;
      94             : }
      95             : 
      96             : /*--------------------------------------------------------------------------*
      97             :  * ic_bwe_specMapping()
      98             :  *
      99             :  * Encode and apply the spectral shape mapping of ref to the non-ref channel
     100             :  *---------------------------------------------------------------------------*/
     101          62 : static Word16 ic_bwe_enc_specMapping_ivas_fx(
     102             :     const Word32 *shb_frame_target_fx, /* i  : target shb                   Q31-shb_frame_target_e*/
     103             :     Word16 shb_frame_target_e,
     104             :     Word32 *shb_synth_nonref_fx, /* o  : non-ref shb synth                   Q31-shb_synth_nonref_e*/
     105             :     Word16 *shb_synth_nonref_e,
     106             :     Word32 *specMapping_fx,       /* i/o: current frame's mapping             Qx*/
     107             :     Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping             Q31-memShbSpecMapping_e*/
     108             :     Word16 *memShbSpecMapping_e,
     109             :     Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory    Q31-memShbSpecXcorr_e*/
     110             :     Word16 *memShbSpecXcorr_e )
     111             : {
     112             :     Word16 idx;
     113             :     Word16 max_exp;
     114          62 :     Word16 Txx1_fx = 0, Txx2_fx = 0, Txx3_fx = 0, T_desired_fx = 0;
     115          62 :     Word16 Txx1_e = 0, Txx2_e = 0, Txx3_e = 0, T_desired_e = 0;
     116             :     Word16 T_nonref_target_fx, temp_fx;
     117             :     Word32 temp00_fx, temp11_fx;
     118             :     Word16 temp00_exp, temp11_exp;
     119             :     Word32 temp0_fx, temp1_fx, temp2_fx, temp3_fx;
     120             :     Word16 a_fx, b_fx, c_fx, a_e, b_e, c_e;
     121          62 :     Word16 u_fx, u1_fx, u2_fx, u_e = 0, u1_e, u2_e;
     122             :     Word16 temp0_exp, temp1_exp, temp2_exp, temp3_exp, exp, T_nonref_target_e;
     123             : 
     124          62 :     move16();
     125          62 :     move16();
     126          62 :     move16();
     127          62 :     move16();
     128          62 :     move16();
     129          62 :     move16();
     130          62 :     move16();
     131          62 :     move16();
     132          62 :     move16();
     133             : 
     134             :     /* Calculate rxx(1)/rxx(0) of the non ref target */
     135             : 
     136          62 :     temp00_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp00_exp );     /* Q31-temp0_exp */
     137          62 :     temp11_fx = dotp_fixed_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */
     138             : 
     139             :     /* Calculate rxx(1)/rxx(0) of the non ref synth */
     140          62 :     temp0_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx, *shb_synth_nonref_e, L_FRAME16k - 3, &temp0_exp );     /* Q31-temp0_exp */
     141          62 :     temp1_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 1, *shb_synth_nonref_e, L_FRAME16k - 3, &temp1_exp ); /* Q31-temp1_exp */
     142          62 :     temp2_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 2, *shb_synth_nonref_e, L_FRAME16k - 3, &temp2_exp ); /* Q31-temp2_exp */
     143          62 :     temp3_fx = dotp_fixed_ivas_fx( shb_synth_nonref_fx, *shb_synth_nonref_e, shb_synth_nonref_fx + 3, *shb_synth_nonref_e, L_FRAME16k - 3, &temp3_exp ); /* Q31-temp3_exp */
     144             : 
     145          62 :     exp = s_max( *memShbSpecXcorr_e, s_max( s_max( s_max( temp00_exp, temp11_exp ), s_max( temp0_exp, temp1_exp ) ), s_max( temp2_exp, temp3_exp ) ) );
     146             : 
     147          62 :     temp00_fx = L_shr( temp00_fx, sub( exp, temp00_exp ) );
     148          62 :     temp11_fx = L_shr( temp11_fx, sub( exp, temp11_exp ) );
     149          62 :     temp0_fx = L_shr( temp0_fx, sub( exp, temp0_exp ) );
     150          62 :     temp1_fx = L_shr( temp1_fx, sub( exp, temp1_exp ) );
     151          62 :     temp2_fx = L_shr( temp2_fx, sub( exp, temp2_exp ) );
     152          62 :     temp3_fx = L_shr( temp3_fx, sub( exp, temp3_exp ) );
     153             : 
     154             :     /* Smoothing */
     155             : 
     156         434 :     FOR( Word16 i = 0; i < 6; i++ )
     157             :     {
     158         372 :         memShbSpecXcorr_fx[i] = L_shl( memShbSpecXcorr_fx[i], sub( *memShbSpecXcorr_e, exp ) );
     159         372 :         move32();
     160             :     }
     161          62 :     *memShbSpecXcorr_e = exp;
     162          62 :     move16();
     163             : 
     164          62 :     temp00_fx = L_add( L_shr( temp00_fx, 1 ), L_shr( memShbSpecXcorr_fx[0], 1 ) );
     165          62 :     temp11_fx = L_add( L_shr( temp11_fx, 1 ), L_shr( memShbSpecXcorr_fx[1], 1 ) );
     166          62 :     temp0_fx = L_add( L_shr( temp0_fx, 1 ), L_shr( memShbSpecXcorr_fx[2], 1 ) );
     167          62 :     temp1_fx = L_add( L_shr( temp1_fx, 1 ), L_shr( memShbSpecXcorr_fx[3], 1 ) );
     168          62 :     temp2_fx = L_add( L_shr( temp2_fx, 1 ), L_shr( memShbSpecXcorr_fx[4], 1 ) );
     169          62 :     temp3_fx = L_add( L_shr( temp3_fx, 1 ), L_shr( memShbSpecXcorr_fx[5], 1 ) );
     170             : 
     171          62 :     T_nonref_target_fx = 0;
     172          62 :     move32();
     173          62 :     T_nonref_target_e = 31;
     174          62 :     move16();
     175             : 
     176          62 :     IF( temp00_fx != 0 )
     177             :     {
     178          62 :         T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp11_fx, temp00_fx, &T_nonref_target_e );
     179             :     }
     180             : 
     181             : 
     182          62 :     memShbSpecXcorr_fx[0] = temp00_fx;
     183          62 :     move32();
     184          62 :     memShbSpecXcorr_fx[1] = temp11_fx;
     185          62 :     move32();
     186          62 :     memShbSpecXcorr_fx[2] = temp0_fx; /* Q31-exp */
     187          62 :     move32();
     188          62 :     memShbSpecXcorr_fx[3] = temp1_fx; /* Q31-exp */
     189          62 :     move32();
     190          62 :     memShbSpecXcorr_fx[4] = temp2_fx; /* Q31-exp */
     191          62 :     move32();
     192          62 :     memShbSpecXcorr_fx[5] = temp3_fx; /* Q31-exp */
     193          62 :     move32();
     194             : 
     195             : 
     196          62 :     IF( temp0_fx != 0 )
     197             :     {
     198          62 :         Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e ); /* Q31-Txx1_e */
     199          62 :         Txx2_fx = BASOP_Util_Divide3232_Scale( temp2_fx, temp0_fx, &Txx2_e ); /* Q31-Txx1_e */
     200          62 :         Txx3_fx = BASOP_Util_Divide3232_Scale( temp3_fx, temp0_fx, &Txx3_e ); /* Q31-Txx1_e */
     201             :     }
     202             : 
     203          62 :     T_desired_fx = T_nonref_target_fx;
     204          62 :     T_desired_e = T_nonref_target_e;
     205          62 :     move32();
     206          62 :     move16();
     207             : 
     208             :     Word16 tmp, tmp1;
     209          62 :     exp = BASOP_Util_Add_MantExp( Txx3_fx, Txx3_e, Txx1_fx, Txx1_e, &tmp );                                /* Q15-exp */
     210          62 :     tmp1 = mult( Txx2_fx, T_desired_fx );                                                                  // Txx2_e + T_desired_e
     211          62 :     a_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx2_e, T_desired_e ), 1 ), negate( tmp ), exp, &a_fx ); /* Q15-a_e */
     212             : 
     213          62 :     exp = BASOP_Util_Add_MantExp( Txx2_fx, Txx2_e, 32767, 1, &tmp );                                       /* Q15-exp */
     214          62 :     tmp1 = mult( Txx1_fx, T_desired_fx );                                                                  // Txx1_e + T_desired_e
     215          62 :     b_e = BASOP_Util_Add_MantExp( tmp1, sub( add( Txx1_e, T_desired_e ), 1 ), negate( tmp ), exp, &b_fx ); /* Q15-b_fx */
     216             : 
     217          62 :     c_e = BASOP_Util_Add_MantExp( T_desired_fx, T_desired_e, negate( Txx1_fx ), Txx1_e, &c_fx ); /* Q15-c_fx */
     218             : 
     219          62 :     u_fx = extract_l( *specMapping_fx );
     220             : 
     221             : 
     222             :     /* while performing (-32768)*(-32768), overflow occurs because the result comes out as 32768 after mult. This is the only case for mult where overflow happens. In order to avoid this scenario mult_sat is used */
     223             : 
     224          62 :     tmp = mult_sat( b_fx, b_fx );  // b_e  + b_e;
     225          62 :     tmp1 = mult_sat( a_fx, c_fx ); // a_e + c_e + 2
     226             : 
     227          62 :     exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx ); /* Q15-exp */
     228          62 :     test();
     229          62 :     IF( temp_fx >= 0 && a_fx != 0 )
     230             :     {
     231          62 :         temp_fx = Sqrt16( temp_fx, &exp );                                       /* Q15-exp */
     232          62 :         exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, temp_fx, exp, &tmp ); /* Q15-exp */
     233          62 :         u1_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u1_fx );                 /* Q15-u1_e */
     234          62 :         u1_e = add( u1_e, sub( exp, add( a_e, 1 ) ) );
     235             : 
     236          62 :         exp = BASOP_Util_Add_MantExp( negate( b_fx ), b_e, negate( temp_fx ), exp, &tmp ); /* Q15-exp */
     237          62 :         u2_e = BASOP_Util_Divide1616_Scale( tmp, a_fx, &u2_fx );                           /* Q15-u2_e */
     238          62 :         u2_e = add( u2_e, sub( exp, add( a_e, 1 ) ) );
     239             : 
     240          62 :         test();
     241          62 :         IF( ( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( abs_s( u1_fx ) ), u1_e, 1, 31 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( abs_s( u2_fx ) ), u2_e, 1, 31 ) < 0 ) )
     242             :         {
     243           0 :             IF( ( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( abs_s( u1_fx ) ), u1_e, L_deposit_h( abs_s( u2_fx ) ), u2_e ) < 0 ) )
     244             :             {
     245           0 :                 u_fx = u1_fx;
     246           0 :                 u_e = u1_e;
     247             :             }
     248             :             ELSE
     249             :             {
     250           0 :                 u_fx = u2_fx;
     251           0 :                 u_e = u2_e;
     252             :             }
     253           0 :             move32();
     254           0 :             move16();
     255             :         }
     256          62 :         ELSE IF( ( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( abs_s( u1_fx ) ), u1_e, 1, 31 ) < 0 ) )
     257             :         {
     258          14 :             u_fx = u1_fx;
     259          14 :             u_e = u1_e;
     260          14 :             move32();
     261          14 :             move16();
     262             :         }
     263          48 :         ELSE IF( ( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( abs_s( u2_fx ) ), u2_e, 1, 31 ) < 0 ) )
     264             :         {
     265          48 :             u_fx = u2_fx;
     266          48 :             u_e = u2_e;
     267          48 :             move32();
     268          48 :             move16();
     269             :         }
     270             :     }
     271             : 
     272          62 :     IF( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( u_fx ), u_e, 0, 0 ) > 0 )
     273             :     {
     274          62 :         u_fx = 0;
     275          62 :         u_e = 0;
     276          62 :         move32();
     277          62 :         move16();
     278             :     }
     279             : 
     280          62 :     IF( BASOP_Util_Cmp_Mant32Exp( L_deposit_h( u_fx ), u_e, -1288490188, 0 ) < 0 ) // -0.6 in Q31
     281             :     {
     282           0 :         u_fx = -1288490188 >> 16; //-0.6 in Q31 -> Q15
     283           0 :         u_e = 0;
     284           0 :         move32();
     285           0 :         move16();
     286             :     }
     287             : 
     288             : 
     289             :     /* Quantize spec. mapping **/
     290             :     Word16 specMapping16;
     291          62 :     idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553 >> 1, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
     292          62 :     *specMapping_fx = L_deposit_h( specMapping16 );
     293          62 :     move32();
     294             : 
     295          62 :     max_exp = s_max( sub( *memShbSpecMapping_e, norm_l( *memShbSpecMapping_fx ) ), *shb_synth_nonref_e );
     296             : 
     297          62 :     *memShbSpecMapping_fx = L_shl( *memShbSpecMapping_fx, sub( *memShbSpecMapping_e, max_exp ) ); // max_exp
     298          62 :     move32();
     299          62 :     *memShbSpecMapping_e = max_exp;
     300          62 :     move16();
     301             : 
     302          62 :     scale_sig32( shb_synth_nonref_fx, L_FRAME16k, sub( *shb_synth_nonref_e, max_exp ) ); // max_exp
     303          62 :     *shb_synth_nonref_e = max_exp;
     304          62 :     move16();
     305             : 
     306             :     /* IC-BWE spec mapping */
     307          62 :     deemph_fx_32( shb_synth_nonref_fx, specMapping16, L_FRAME16k, memShbSpecMapping_fx ); // shb_synth_nonref_e
     308             : 
     309          62 :     return idx;
     310             : }
     311             : 
     312             : 
     313             : /*----------------------------------------------------------------------*
     314             :  * ic_bwe_gsMapping()
     315             :  *
     316             :  * Encode and apply the gain shape mapping of ref to the non-ref channel
     317             :  *-----------------------------------------------------------------------*/
     318             : 
     319             : /*! r: return quant. index value */
     320             : /*----------------------------------------------------------------------*
     321             :  * ic_bwe_gsMapping()
     322             :  *
     323             :  * Encode and apply the gain shape mapping of ref to the non-ref channel
     324             :  *-----------------------------------------------------------------------*/
     325             : 
     326             : /*! r: return quant. index value */
     327       26711 : static Word16 ic_bwe_enc_gsMapping_ivas_fx(
     328             :     const Word32 relG_targ_fx, /* i  : gDes, rel gain target       Q31-relG_targ_e*/
     329             :     Word16 relG_targ_e,
     330             :     const Word16 *shbSynth_fx,  /* i  : ref synth signal             Q15-shbSynth_e*/
     331             :     Word16 shbSynth_e,          /* i  : ref synth signal             */
     332             :     Word32 *synthSHB_nonref_fx, /* i  : nonref synth signal         Q31-synthSHB_nonref_e*/
     333             :     Word16 *synthSHB_nonref_e,  /* i  : nonref synth signal          */
     334             :     Word32 *gsMapping_fx,       /* i/o: gs mapping                  Q31-gsMapping_e*/
     335             :     Word16 *gsMapping_e,        /* i/o: gs mapping                  */
     336             :     Word32 *memEner_fx,         /*                                  Q31-memEner_e*/
     337             :     Word16 *memEner_e,
     338             :     const Word16 element_mode /* i  : element mode                  Q0*/
     339             : )
     340             : {
     341             :     Word16 i;
     342       26711 :     Word16 idx = 0, temp1;
     343       26711 :     move16();
     344       26711 :     Word32 temp1_fx32 = 0, temp2_fx32 = 0;
     345       26711 :     move32();
     346       26711 :     move32();
     347             :     Word32 L_mult;
     348             :     Word16 temp2_fx, gsMapping_fx16;
     349             : 
     350             :     /* rel gain of synth signals */
     351       26711 :     Word16 exp1 = shbSynth_e, exp2 = *synthSHB_nonref_e, temp1_exp = 0, temp2_exp = 0, exp = 0;
     352       26711 :     move16();
     353       26711 :     move16();
     354       26711 :     move16();
     355       26711 :     move16();
     356       26711 :     move16();
     357     8574231 :     FOR( i = 0; i < L_FRAME16k; i++ )
     358             :     {
     359     8547520 :         temp1_fx32 = BASOP_Util_Add_Mant32Exp( temp1_fx32, temp1_exp, L_abs( L_deposit_h( shbSynth_fx[i] ) ), exp1, &temp1_exp ); /* Q31-temp1_exp */
     360     8547520 :         temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp );         /* Q31-temp2_exp */
     361             :     }
     362             : 
     363       26711 :     memEner_fx[0] = L_shr( temp1_fx32, sub( s_max( temp1_exp, temp2_exp ), temp1_exp ) );
     364       26711 :     memEner_fx[1] = L_shr( temp2_fx32, sub( s_max( temp1_exp, temp2_exp ), temp2_exp ) );
     365       26711 :     move32();
     366       26711 :     move32();
     367       26711 :     *memEner_e = s_max( temp1_exp, temp2_exp );
     368       26711 :     move16();
     369             : 
     370       26711 :     IF( temp2_fx32 == 0 )
     371             :     {
     372           0 :         *gsMapping_fx = *gsMapping_fx;
     373           0 :         move32();
     374             :     }
     375             :     ELSE
     376             :     {
     377       26711 :         L_mult = Mpy_32_32( relG_targ_fx, temp1_fx32 );                  // relG_targ_e + temp1_e
     378       26711 :         temp1 = BASOP_Util_Divide3232_Scale( L_mult, temp2_fx32, &exp ); // exp = exp - ( relG_targ_e + temp1_e - temp2_e )
     379       26711 :         exp = add( exp, sub( add( relG_targ_e, temp1_exp ), temp2_exp ) );
     380       26711 :         *gsMapping_fx = L_deposit_h( temp1 ); // exp
     381       26711 :         move32();
     382             :     }
     383             : 
     384       26711 :     temp2_fx32 = BASOP_Util_Log10( *gsMapping_fx, exp ); /* no impact from prev_gsMapping */ // Q25
     385             :     /* quantize the IC-BWE GS mapping*/
     386       26711 :     IF( EQ_16( element_mode, IVAS_CPE_TD ) )
     387             :     {
     388          74 :         IF( LT_32( temp2_fx32, -( 2 << 25 ) ) )
     389             :         {
     390           0 :             temp2_fx = -( 2 << 12 ); // Q12
     391           0 :             move16();
     392             :         }
     393          74 :         ELSE IF( GT_32( temp2_fx32, 1 << 25 ) )
     394             :         {
     395          61 :             temp2_fx = 1 << 12; // Q12
     396          61 :             move16();
     397             :         }
     398             : 
     399          74 :         temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12
     400          74 :         gsMapping_fx16 = 0;
     401          74 :         move16();
     402          74 :         idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12
     403             :     }
     404             :     ELSE
     405             :     {
     406       26637 :         IF( LT_32( temp2_fx32, -( 5 << 25 ) ) )
     407             :         {
     408           0 :             temp2_fx = -( 5 << 12 ); // Q12
     409           0 :             move16();
     410             :         }
     411       26637 :         ELSE IF( GT_32( temp2_fx32, 1 << 25 ) )
     412             :         {
     413           0 :             temp2_fx = 1 << 12; // Q12
     414           0 :             move16();
     415             :         }
     416             : 
     417       26637 :         temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12
     418       26637 :         gsMapping_fx16 = 0;
     419       26637 :         move16();
     420       26637 :         idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS_DFT ) ); // Q12
     421             :     }
     422       26711 :     *gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28
     423       26711 :     move32();
     424             :     Word16 e;
     425       26711 :     L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q28 + Q13 - Q15 -> Q26
     426       26711 :     *gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e );               /* Q31-e */
     427       26711 :     move32();
     428             : 
     429       26711 :     *gsMapping_e = e; // Q31
     430       26711 :     move16();
     431       26711 :     return idx;
     432             : }
     433             : 
     434             : /*----------------------------------------------------------------------*
     435             :  * icbwe_dft_stereo_param()
     436             :  *
     437             :  * Estimate ICBWE parameters in DFT stereo
     438             :  *-----------------------------------------------------------------------*/
     439       26637 : static void icbwe_dft_stereo_param_ivas_fx(
     440             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE,  /* i/o: */
     441             :     STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i  : */
     442             :     Encoder_State *st,                     /* i/o: */
     443             :     Word32 *shb_synth_nonref_fx,           /* i/o: Q31-shb_synth_nonref_e*/
     444             :     Word16 *shb_synth_nonref_e             /* i/o: */
     445             : )
     446             : {
     447             :     Word16 slopeILD_fx;
     448             :     Word32 normFac_fx;
     449             :     Word16 gsIndx, spIndx, gDes_fx;
     450             : 
     451             :     Word32 *nrg_L_fx, *nrg_R_fx, *nrg_DMX_fx;
     452             :     Word32 sum_nrg_L_fx, sum_nrg_R_fx, sum_nrg_DMX_fx;
     453       26637 :     const Word32 spec_table_fx[4] = { -1288490189, -858993459, -429496730, 0 }; // Q31
     454       26637 :     const Word16 slope_table_fx16[4] = { -278, -165, -75, 0 };                  // Q7
     455             : 
     456       26637 :     BSTR_ENC_HANDLE hBstr = st->hBstr;
     457       26637 :     normFac_fx = 1342177280; /* 1000 * (10/((14400+10400)/2 - (6400+10400)/2)) */ // Q29
     458       26637 :     move32();
     459             : 
     460       26637 :     nrg_L_fx = hStereoDft->nrg_L_fx;
     461       26637 :     nrg_R_fx = hStereoDft->nrg_R_fx;
     462       26637 :     nrg_DMX_fx = hStereoDft->nrg_DMX_fx;
     463             : 
     464       26637 :     hStereoICBWE->mem_nrg_L_fx_e = s_max( hStereoDft->nrg_L_fx_e[0], hStereoDft->nrg_L_fx_e[1] );
     465       26637 :     hStereoICBWE->mem_nrg_R_fx_e = s_max( hStereoDft->nrg_R_fx_e[0], hStereoDft->nrg_R_fx_e[1] );
     466       26637 :     hStereoICBWE->mem_nrg_DMX_fx_e = s_max( hStereoDft->nrg_DMX_fx_e[0], hStereoDft->nrg_DMX_fx_e[1] );
     467       26637 :     move16();
     468       26637 :     move16();
     469       26637 :     move16();
     470       26637 :     hStereoICBWE->mem_nrg_L_fx[0] = L_shr( nrg_L_fx[0], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[0] ) );
     471       26637 :     hStereoICBWE->mem_nrg_R_fx[0] = L_shr( nrg_R_fx[0], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[0] ) );
     472       26637 :     hStereoICBWE->mem_nrg_DMX_fx[0] = L_shr( nrg_DMX_fx[0], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[0] ) );
     473       26637 :     hStereoICBWE->mem_nrg_L_fx[1] = L_shr( nrg_L_fx[1], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[1] ) );
     474       26637 :     hStereoICBWE->mem_nrg_R_fx[1] = L_shr( nrg_R_fx[1], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[1] ) );
     475       26637 :     hStereoICBWE->mem_nrg_DMX_fx[1] = L_shr( nrg_DMX_fx[1], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[1] ) );
     476       26637 :     move32();
     477       26637 :     move32();
     478       26637 :     move32();
     479       26637 :     move32();
     480       26637 :     move32();
     481       26637 :     move32();
     482             : 
     483       26637 :     Word16 sum_nrg_L_e = hStereoICBWE->mem_nrg_L_fx_e, sum_nrg_R_e = hStereoICBWE->mem_nrg_R_fx_e, sum_nrg_DMX_e = hStereoICBWE->mem_nrg_DMX_fx_e;
     484       26637 :     sum_nrg_L_fx = sum_32_fx( hStereoICBWE->mem_nrg_L_fx, 2, &sum_nrg_L_e );       // hStereoICBWE->mem_nrg_L_fx_e
     485       26637 :     sum_nrg_R_fx = sum_32_fx( hStereoICBWE->mem_nrg_R_fx, 2, &sum_nrg_R_e );       // hStereoICBWE->mem_nrg_R_fx_e
     486       26637 :     sum_nrg_DMX_fx = sum_32_fx( hStereoICBWE->mem_nrg_DMX_fx, 2, &sum_nrg_DMX_e ); // hStereoICBWE->mem_nrg_DMX_fx_e
     487       26637 :     move16();
     488       26637 :     move16();
     489       26637 :     move16();
     490             : 
     491             :     /* refChanIndex_bwe refinement */
     492             : 
     493       26637 :     test();
     494       26637 :     test();
     495       26637 :     test();
     496       26637 :     test();
     497       26637 :     IF( ( ( BASOP_Util_Cmp_Mant32Exp( sum_nrg_R_fx, sum_nrg_R_e, Mpy_32_32( 1374389534, sum_nrg_L_fx ), sum_nrg_L_e ) < 0 ) && EQ_16( hStereoICBWE->refChanIndx_bwe, hStereoICBWE->prev_refChanIndx_bwe ) ) || ( BASOP_Util_Cmp_Mant32Exp( sum_nrg_R_fx, sum_nrg_R_e, Mpy_32_32( 773094113, sum_nrg_L_fx ), sum_nrg_L_e ) < 0 ) ) // 0.64 in Q31 -> 1374389534, 0.36 in Q31 -> 773094113
     498             :     {
     499        4364 :         hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
     500        4364 :         move16();
     501             :     }
     502       22273 :     ELSE IF( ( ( BASOP_Util_Cmp_Mant32Exp( sum_nrg_L_fx, sum_nrg_L_e, Mpy_32_32( 1374389534, sum_nrg_R_fx ), sum_nrg_R_e ) < 0 ) && EQ_16( hStereoICBWE->refChanIndx_bwe, hStereoICBWE->prev_refChanIndx_bwe ) ) || ( BASOP_Util_Cmp_Mant32Exp( sum_nrg_L_fx, sum_nrg_L_e, Mpy_32_32( 773094113, sum_nrg_R_fx ), sum_nrg_R_e ) < 0 ) ) //  0.64 in Q31 -> 1374389534, 0.36 in Q31 -> 773094113
     503             :     {
     504        9633 :         hStereoICBWE->refChanIndx_bwe = R_CH_INDX;
     505        9633 :         move16();
     506             :     }
     507             : 
     508             :     /* Initialization of spIndx */
     509       26637 :     slopeILD_fx = 0;
     510       26637 :     move32();
     511             : 
     512       26637 :     spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
     513             : 
     514       26637 :     test();
     515       26637 :     test();
     516       26637 :     test();
     517       26637 :     IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
     518       12569 :     {
     519             :         /* Spec Mapping Estimate */
     520             :         Word16 max_exp;
     521             :         Word16 tmp1, exp1;
     522             :         Word32 L_tmp, L_tmp1;
     523       12569 :         L_tmp = Mpy_32_32( hStereoICBWE->mem_nrg_L_fx[1], hStereoICBWE->mem_nrg_R_fx[0] );  // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
     524       12569 :         L_tmp1 = Mpy_32_32( hStereoICBWE->mem_nrg_R_fx[1], hStereoICBWE->mem_nrg_L_fx[0] ); // hStereoICBWE->mem_nrg_L_fx_e[1] + hStereoICBWE->mem_nrg_R_fx_e[1]
     525       12569 :         tmp1 = BASOP_Util_Divide3232_Scale( L_tmp, L_tmp1, &exp1 );                         /* Q15-exp1 */
     526       12569 :         exp1 = add( exp1, sub( add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ), add( hStereoICBWE->mem_nrg_L_fx_e, hStereoICBWE->mem_nrg_R_fx_e ) ) );
     527       12569 :         L_tmp = BASOP_Util_Log10( L_deposit_h( tmp1 ), exp1 );
     528       12569 :         L_tmp = Mpy_32_32( normFac_fx, L_tmp );        // // Q25 + Q29 - Q31 -> Q23
     529       12569 :         slopeILD_fx = extract_l( L_shr( L_tmp, 16 ) ); // Q23 - Q16 -> Q7
     530       12569 :         IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
     531             :         {
     532        4078 :             slopeILD_fx = negate( slopeILD_fx ); /* Q7 */
     533             :         }
     534       12569 :         spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT );
     535       12569 :         IF( Mpy_32_32( spec_table_fx[spIndx], hStereoICBWE->prevSpecMapping_fx ) < 0 )
     536             :         {
     537           0 :             slopeILD_fx = 0;
     538           0 :             move32();
     539           0 :             spIndx = squant_fx( slopeILD_fx, &slopeILD_fx, slope_table_fx16, 1 << STEREO_ICBWE_SPBITS_DFT ); /* Q0 */
     540             :         }
     541             : 
     542       12569 :         hStereoICBWE->prevSpecMapping_fx = spec_table_fx[spIndx]; // q31
     543             : 
     544       12569 :         max_exp = s_max( *shb_synth_nonref_e, sub( hStereoICBWE->memShbSpecMapping_e, norm_l( hStereoICBWE->memShbSpecMapping_fx ) ) );
     545             : 
     546       12569 :         hStereoICBWE->memShbSpecMapping_fx = L_shl( hStereoICBWE->memShbSpecMapping_fx, sub( hStereoICBWE->memShbSpecMapping_e, max_exp ) ); // max_exp
     547       12569 :         move32();
     548       12569 :         hStereoICBWE->memShbSpecMapping_e = max_exp;
     549       12569 :         move16();
     550             : 
     551       12569 :         scale_sig32( shb_synth_nonref_fx, L_FRAME16k, sub( *shb_synth_nonref_e, max_exp ) );
     552       12569 :         *shb_synth_nonref_e = max_exp;
     553       12569 :         move16();
     554             : 
     555             :         /* ic bwe spec mapping application */
     556       12569 :         deemph_fx_32( shb_synth_nonref_fx, extract_h( hStereoICBWE->prevSpecMapping_fx ), L_FRAME16k, &hStereoICBWE->memShbSpecMapping_fx ); // shb_synth_nonref_e
     557             :     }
     558             :     ELSE
     559             :     {
     560       14068 :         hStereoICBWE->memShbSpecMapping_e = 0;
     561       14068 :         move16();
     562       14068 :         hStereoICBWE->memShbSpecMapping_fx = 0;
     563       14068 :         hStereoICBWE->prevSpecMapping_fx = 0;
     564       14068 :         move32();
     565       14068 :         move32();
     566             :     }
     567             : 
     568             :     /* gsMapping estimate */
     569             : 
     570             :     Word16 exp;
     571       26637 :     IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
     572             :     {
     573        8938 :         gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_R_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
     574        8938 :         exp = add( exp, sub( sum_nrg_R_e, sum_nrg_DMX_e ) );
     575             :     }
     576             :     ELSE
     577             :     {
     578       17699 :         gDes_fx = BASOP_Util_Divide3232_Scale( sum_nrg_L_fx, sum_nrg_DMX_fx, &exp ); /* Q15-exp */
     579       17699 :         exp = add( exp, sub( sum_nrg_L_e, sum_nrg_DMX_e ) );
     580             :     }
     581             : 
     582       26637 :     gDes_fx = Sqrt16( gDes_fx, &exp ); /* Q15-exp */
     583       26637 :     Word16 exp1 = hStereoICBWE->gDes_pastFrame_e, exp2, tmp;
     584       26637 :     Word32 tmp321 = 0, tmp322 = 0;
     585       26637 :     move32();
     586       26637 :     move32();
     587             :     /* Geometric Mean */
     588       26637 :     tmp321 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp1 ); // exp1
     589       26637 :     exp2 = exp;
     590       26637 :     move16();
     591       26637 :     tmp = Sqrt16( gDes_fx, &exp2 );                   /* Q15-exp2 */
     592       26637 :     tmp322 = Mpy_32_32( tmp321, L_deposit_h( tmp ) ); // exp1 + exp2
     593       26637 :     hStereoICBWE->gDes_pastFrame_fx = tmp322;
     594       26637 :     hStereoICBWE->gDes_pastFrame_e = add( exp1, exp2 );
     595       26637 :     move32();
     596       26637 :     move16();
     597             : 
     598       26637 :     gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
     599             : 
     600       26637 :     hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */
     601       26637 :     hStereoICBWE->gDes_pastFrame_e = exp;
     602       26637 :     move32();
     603       26637 :     move16();
     604             : 
     605       26637 :     push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
     606       26637 :     IF( EQ_16( st->flag_ACELP16k, 1 ) )
     607             :     {
     608       13106 :         push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS_DFT );
     609             :     }
     610             : 
     611             :     /* IC BWE GS mapping */
     612       26637 :     push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS_DFT );
     613             : 
     614       26637 :     return;
     615             : }
     616             : 
     617       48267 : void stereo_icBWE_enc_ivas_fx(
     618             :     CPE_ENC_HANDLE hCPE,              /* i/o: CPE encoder structure                */
     619             :     const Word32 shb_speech_ref_fx[], /* i  : SHB speech ref channel               Q31-shb_speech_ref_e*/
     620             :     const Word16 shb_speech_ref_e,    /* i  : SHB speech ref channel               */
     621             :     Word32 shb_speech_nonref_fx[],    /* i/o: SHB speech non-ref channel           Q31-shb_speech_nonref_e*/
     622             :     Word16 shb_speech_nonref_e,       /* i/o: SHB speech non-ref channel           */
     623             :     const Word32 *voice_factors_fx    /* i  : voicing factors                     Q31 */
     624             : )
     625             : {
     626             :     Word16 i, j, k, nbSubFr;
     627             :     STEREO_DFT_ENC_DATA_HANDLE hStereoDft;
     628             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
     629             :     BSTR_ENC_HANDLE hBstr;
     630             :     Encoder_State *st;
     631             :     Word16 spIndx, gsIndx;
     632             : 
     633             :     Word16 nonRefMemLen, refMemLen;
     634       48267 :     Word16 shb_synth_nonref_e = 0, max_e;
     635       48267 :     move16();
     636             : 
     637             :     Word32 nlMixFac_fx[NB_SUBFR16k];
     638             :     Word32 excSHB_nonref_fx[L_FRAME16k];
     639       48267 :     set32_fx( excSHB_nonref_fx, 0, L_FRAME16k );
     640             :     Word32 shb_synth_nonref_fx[L_FRAME16k];
     641             :     Word32 shb_frame_nonref_fx[L_LOOK_16k + L_FRAME16k], gTarget_fx;
     642             :     Word32 shb_frame_ref_fx[L_LOOK_16k + L_FRAME16k];
     643             :     Word32 gDes_fx;
     644             :     Word32 temp1_fx, temp2_fx;
     645             :     Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp;
     646             : 
     647             : 
     648             :     /* initialization */
     649       48267 :     hStereoDft = hCPE->hStereoDft;
     650       48267 :     hStereoICBWE = hCPE->hStereoICBWE;
     651       48267 :     st = hCPE->hCoreCoder[0];
     652       48267 :     hBstr = st->hBstr;
     653             : 
     654       48267 :     gTarget_fx = hCPE->hStereoTCA->targetGain_fx; /* i  : gain norm for target (or R) channel  */ // Q29
     655       48267 :     move32();
     656             : 
     657       48267 :     nonRefMemLen = L_MEM_RECALC_TBE_16K + L_FILT16k;
     658       48267 :     move16();
     659             : 
     660       48267 :     test();
     661       48267 :     IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
     662             :     {
     663         103 :         refMemLen = L_MEM_RECALC_TBE_16K + 20;
     664         103 :         move16();
     665             :     }
     666       48164 :     ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GT_32( st->core_brate, SID_2k40 ) )
     667             :     {
     668       39996 :         refMemLen = 20;
     669       39996 :         move16();
     670             :     }
     671             :     ELSE
     672             :     {
     673        8168 :         ic_bwe_enc_reset_fx( hStereoICBWE );
     674        8168 :         return;
     675             :     }
     676             : 
     677       40099 :     IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
     678             :     {
     679             :         /* memory resets */
     680       39996 :         set16_fx( hStereoICBWE->mem_shb_speech_nonref_fx, 0, L_LOOK_16k );
     681       39996 :         set32_fx( shb_speech_nonref_fx, 0, L_FRAME16k );
     682             : 
     683             :         /* core switching reset */
     684       39996 :         test();
     685       39996 :         test();
     686       39996 :         test();
     687       39996 :         IF( st->last_core != ACELP_CORE || st->core != ACELP_CORE || LT_16( st->bwidth, SWB ) || EQ_16( st->extl, -1 ) )
     688             :         {
     689             : 
     690       14581 :             ic_bwe_enc_reset_fx( hStereoICBWE );
     691       14581 :             test();
     692       14581 :             test();
     693       14581 :             test();
     694       14581 :             IF( st->core != ACELP_CORE || LT_16( st->bwidth, SWB ) || LT_32( st->input_Fs, 32000 ) || EQ_16( st->extl, -1 ) )
     695             :             {
     696       13359 :                 return;
     697             :             }
     698             :         }
     699             : 
     700       26637 :         set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
     701             : 
     702       26637 :         hStereoICBWE->prevRefEner_fx = 0;
     703       26637 :         hStereoICBWE->prevNonRefEner_fx = 0;
     704       26637 :         move32();
     705       26637 :         move32();
     706             : 
     707             :         /* SHB frame buffer offsets for TBE processing << re-adjust check >>*/
     708             : 
     709       26637 :         max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e );
     710       26637 :         Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e
     711             : 
     712       26637 :         set32_fx( shb_frame_ref_fx, 0, L_LOOK_16k + L_FRAME16k );
     713       26637 :         Copy_Scale_sig_16_32_DEPREC( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, 0 );                 // Q = 15 - mem_shb_speech_ref_e
     714       26637 :         scale_sig32( shb_frame_ref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // Q = 31 - mem_shb_speech_ref_e
     715             : 
     716       26637 :         hStereoICBWE->mem_shb_speech_ref_e = max_e;
     717       26637 :         shb_frame_ref_e = max_e;
     718       26637 :         move16();
     719       26637 :         move16();
     720             :         /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
     721             : 
     722       26637 :         shb_synth_nonref_e = max_e;
     723       26637 :         move16();
     724             : 
     725       26637 :         Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );                                   /* shb_speech_ref_e */
     726       26637 :         Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) - Q16 ); // mem_shb_speech_ref_e
     727             : 
     728             : 
     729       26637 :         test();
     730       26637 :         test();
     731       26637 :         IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
     732       12569 :         {
     733       12569 :             Copy32( voice_factors_fx, nlMixFac_fx, NB_SUBFR16k ); // Q31
     734             :             /*if( gDes < 0.5f || gDes > 2.0f )*/
     735       12569 :             test();
     736       12569 :             IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 or 2.0 in Q29
     737             :             {
     738        1275 :                 v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k ); // Q31, 0.5 in Q31 -> 1073741824
     739             :             }
     740             : 
     741       12569 :             Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR;
     742       12569 :             move16();
     743       12569 :             IF( st->flag_ACELP16k == 0 )
     744             :             {
     745           0 :                 nbSubFr = NB_SUBFR;
     746           0 :                 move16();
     747             :             }
     748             :             ELSE
     749             :             {
     750       12569 :                 nbSubFr = NB_SUBFR16k;
     751       12569 :                 move16();
     752       12569 :                 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k;
     753       12569 :                 move16();
     754             :             }
     755             : 
     756             :             Word16 exp_buf[L_FRAME16k];
     757       12569 :             set16_fx( exp_buf, 0, L_FRAME16k );
     758       75414 :             FOR( ( i = 0, k = 0 ); i < nbSubFr; i++ )
     759             :             {
     760       62845 :                 test();
     761       62845 :                 IF( EQ_16( st->coder_type, UNVOICED ) || EQ_16( hStereoICBWE->MSFlag, 1 ) )
     762             :                 {
     763       15190 :                     temp1_fx = 0;
     764       15190 :                     temp1_e = 0;
     765       15190 :                     temp2_fx = ONE_IN_Q31; /* Q31 */
     766       15190 :                     temp2_e = 0;
     767       15190 :                     move16();
     768       15190 :                     move32();
     769       15190 :                     move16();
     770       15190 :                     move32();
     771             :                 }
     772             :                 ELSE
     773             :                 {
     774       47655 :                     temp1_e = 0, temp2_e = 0;
     775       47655 :                     move16();
     776       47655 :                     move16();
     777       47655 :                     temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );
     778       47655 :                     temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31-temp2_e */
     779             :                 }
     780             : 
     781     4084925 :                 FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) )
     782             :                 {
     783     4022080 :                     excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */
     784     4022080 :                     move32();
     785             :                 }
     786             :             }
     787             : 
     788       12569 :             max_e = exp_buf[0];
     789       12569 :             move16();
     790     4034649 :             FOR( j = 0; j < L_FRAME16k; j++ )
     791             :             {
     792     4022080 :                 IF( GT_16( exp_buf[j], max_e ) )
     793             :                 {
     794       25041 :                     max_e = exp_buf[j];
     795       25041 :                     move16();
     796             :                 }
     797             :             }
     798             : 
     799     4034649 :             FOR( j = 0; j < L_FRAME16k; j++ )
     800             :             {
     801     4022080 :                 excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
     802     4022080 :                 move32();
     803             :             }
     804             :             /* LP synthesis */
     805             : 
     806       12569 :             Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
     807       12569 :             Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) );                                                                                      /* Q31-tmp_e */
     808       12569 :             max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
     809       12569 :             hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
     810             : 
     811       12569 :             syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 );
     812             :         }
     813             :         ELSE
     814             :         {
     815       14068 :             Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); /* Q15-shb_frame_ref_e */
     816       14068 :             hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
     817       14068 :             move16();
     818       14068 :             Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_frame_ref_e */
     819       14068 :             shb_synth_nonref_e = shb_frame_ref_e;
     820       14068 :             move16();
     821       14068 :             set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
     822       14068 :             hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
     823       14068 :             move16();
     824             :         }
     825             : 
     826       26637 :         icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e );
     827             :     }
     828             :     ELSE
     829             :     {
     830             : 
     831         103 :         max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e );
     832         103 :         Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e
     833             : 
     834         103 :         set32_fx( shb_frame_ref_fx, 0, L_LOOK_16k + L_FRAME16k );
     835         103 :         Copy_Scale_sig_16_32_no_sat( hStereoICBWE->mem_shb_speech_ref_fx, shb_frame_ref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
     836         103 :         hStereoICBWE->mem_shb_speech_ref_e = max_e;
     837         103 :         shb_frame_ref_e = max_e;
     838         103 :         move16();
     839         103 :         move16();
     840             :         /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
     841             : 
     842         103 :         Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) );                                         /* Q31-max_e */
     843         103 :         Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
     844             : 
     845         103 :         set32_fx( shb_frame_nonref_fx, 0, L_LOOK_16k + L_FRAME16k );
     846             : 
     847         103 :         max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e );
     848         103 :         Copy_Scale_sig( hStereoICBWE->mem_shb_speech_nonref_fx, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ) );       // mem_shb_speech_ref_e
     849         103 :         Copy_Scale_sig_16_32_no_sat( hStereoICBWE->mem_shb_speech_nonref_fx, shb_frame_nonref_fx, L_LOOK_16k, add( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
     850         103 :         hStereoICBWE->mem_shb_speech_nonref_e = max_e;
     851         103 :         shb_frame_nonref_e = max_e;
     852         103 :         move16();
     853         103 :         move16();
     854             :         /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
     855             : 
     856         103 :         Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) );                                   /* Q31-max_e */
     857         103 :         Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e
     858             : 
     859             : 
     860             :         /* core switching reset */
     861         103 :         test();
     862         103 :         test();
     863         103 :         test();
     864         103 :         test();
     865         103 :         IF( st->last_core != ACELP_CORE || st->core != ACELP_CORE || LT_16( st->bwidth, SWB ) || NE_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->extl, -1 ) )
     866             :         {
     867          29 :             ic_bwe_enc_reset_fx( hStereoICBWE );
     868          29 :             test();
     869          29 :             test();
     870          29 :             test();
     871          29 :             test();
     872          29 :             IF( st->core != ACELP_CORE || LT_16( st->bwidth, SWB ) || LT_32( st->input_Fs, 32000 ) || NE_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->extl, -1 ) )
     873             :             {
     874          29 :                 return;
     875             :             }
     876             :         }
     877             : 
     878             :         /* resets done here. Need to move them to a separate function */
     879          74 :         test();
     880          74 :         test();
     881          74 :         IF( ( NE_16( hStereoICBWE->prev_refChanIndx_bwe, hStereoICBWE->refChanIndx_bwe ) ) || NE_16( st->last_extl, st->extl ) || NE_16( st->flag_ACELP16k, 1 ) )
     882             :         {
     883          24 :             hStereoICBWE->prevSpecMapping_fx = 0;
     884          24 :             hStereoICBWE->memShbSpecMapping_e = 0;
     885          24 :             move16();
     886          24 :             hStereoICBWE->memShbSpecMapping_fx = 0;
     887          24 :             move32();
     888          24 :             move32();
     889          24 :             set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
     890             :         }
     891             : 
     892             :         /* voice fac adjustment based on IC intensities */
     893             :         /*temp2 = (float)sqrt(sum2_f(shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k));*/
     894             : 
     895             :         Word32 L_tmp, L_tmp1;
     896          74 :         temp2_fx = hStereoICBWE->icbweRefEner_fx;
     897          74 :         temp2_e = hStereoICBWE->icbweRefEner_e;
     898          74 :         temp1_e = shb_frame_nonref_e;
     899          74 :         move16();
     900          74 :         move32();
     901          74 :         move32();
     902          74 :         L_tmp = sum2_32_fx( shb_frame_nonref_fx + sub( L_LOOK_16k, refMemLen ), L_FRAME16k, &temp1_e );
     903          74 :         temp1_fx = Sqrt32( L_tmp, &temp1_e ); /* Q31-temp1_e */
     904             : 
     905             :         /*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/
     906             :         /*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/
     907             : 
     908          74 :         IF( temp2_fx == 0 )
     909             :         {
     910           0 :             gDes_fx = 1073741824; /* 1.0 in Q30 */
     911           0 :             gDes_e = 1;
     912           0 :             move16();
     913           0 :             move32();
     914             :         }
     915             :         ELSE
     916             :         {
     917          74 :             tmp = BASOP_Util_Divide3232_Scale( temp1_fx, temp2_fx, &exp );
     918          74 :             gDes_fx = L_deposit_h( tmp ); // exp
     919          74 :             gDes_e = exp;
     920          74 :             move16();
     921             :         }
     922          74 :         tmp = gDes_e;
     923          74 :         exp = hStereoICBWE->gDes_pastFrame_e;
     924          74 :         move16();
     925          74 :         move16();
     926          74 :         L_tmp = Sqrt32( gDes_fx, &tmp );                          /* Q31-tmp */
     927          74 :         L_tmp1 = Sqrt32( hStereoICBWE->gDes_pastFrame_fx, &exp ); /* Q31-exp */
     928             : 
     929          74 :         hStereoICBWE->gDes_pastFrame_fx = Mpy_32_32( L_tmp, L_tmp1 ); // tmp + exp
     930          74 :         hStereoICBWE->gDes_pastFrame_e = add( tmp, exp );
     931          74 :         move32();
     932          74 :         move16();
     933             : 
     934          74 :         hStereoICBWE->prevRefEner_fx = temp2_fx;
     935          74 :         hStereoICBWE->prevRefEner_e = temp2_e;
     936          74 :         hStereoICBWE->prevNonRefEner_fx = temp1_fx;
     937          74 :         hStereoICBWE->prevNonRefEner_e = temp1_e;
     938          74 :         move32();
     939          74 :         move32();
     940          74 :         move16();
     941          74 :         move16();
     942             : 
     943          74 :         test();
     944          74 :         test();
     945          74 :         IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
     946          62 :         {
     947          62 :             Copy32( voice_factors_fx, nlMixFac_fx, NB_SUBFR16k ); // Q31
     948             : 
     949          62 :             test();
     950          62 :             IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 & 2.0 in Q29
     951             :             {
     952           0 :                 v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */
     953             :             }
     954             : 
     955          62 :             Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR;
     956          62 :             move16();
     957          62 :             IF( st->flag_ACELP16k == 0 )
     958             :             {
     959           0 :                 nbSubFr = NB_SUBFR;
     960           0 :                 move16();
     961             :             }
     962             :             ELSE
     963             :             {
     964          62 :                 nbSubFr = NB_SUBFR16k;
     965          62 :                 move16();
     966          62 :                 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k;
     967          62 :                 move16();
     968             :             }
     969             : 
     970             :             Word16 exp_buf[L_FRAME16k];
     971          62 :             set16_fx( exp_buf, 0, L_FRAME16k );
     972         372 :             FOR( ( i = 0, k = 0 ); i < nbSubFr; i++ )
     973             :             {
     974         310 :                 test();
     975         310 :                 IF( EQ_16( st->coder_type, UNVOICED ) || EQ_16( hStereoICBWE->MSFlag, 1 ) )
     976             :                 {
     977             : 
     978         310 :                     temp1_fx = 0;
     979         310 :                     temp1_e = 0;
     980         310 :                     temp2_fx = ONE_IN_Q31; /* Q31 */
     981         310 :                     temp2_e = 0;
     982         310 :                     move32();
     983         310 :                     move32();
     984         310 :                     move16();
     985         310 :                     move16();
     986             :                 }
     987             :                 ELSE
     988             :                 {
     989           0 :                     temp1_e = 0, temp2_e = 0;
     990           0 :                     temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e );                      /* Q31-temp1_e */
     991           0 :                     temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31 */
     992           0 :                     move16();
     993           0 :                     move16();
     994             :                 }
     995             : 
     996       20150 :                 FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) )
     997             :                 {
     998       19840 :                     excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */
     999       19840 :                     move32();
    1000             :                 }
    1001             :             }
    1002             : 
    1003          62 :             max_e = exp_buf[0];
    1004          62 :             move16();
    1005       19902 :             FOR( j = 0; j < L_FRAME16k; j++ )
    1006             :             {
    1007       19840 :                 IF( GT_16( exp_buf[j], max_e ) )
    1008             :                 {
    1009          84 :                     max_e = exp_buf[j];
    1010          84 :                     move16();
    1011             :                 }
    1012             :             }
    1013             : 
    1014       19902 :             FOR( j = 0; j < L_FRAME16k; j++ )
    1015             :             {
    1016       19840 :                 excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
    1017       19840 :                 move32();
    1018             :             }
    1019             :             /* LP synthesis */
    1020          62 :             Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
    1021          62 :             Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) );                                                                                      /* Q31-tmp_e */
    1022          62 :             max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
    1023          62 :             hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
    1024             : 
    1025          62 :             syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 );
    1026             :         }
    1027             :         ELSE
    1028             :         {
    1029          12 :             Copy_Scale_sig_32_16( shb_frame_ref_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k, -16 ); // max_e
    1030          12 :             hStereoICBWE->shbSynthRef_e = shb_frame_ref_e;
    1031          12 :             move16();
    1032          12 :             Copy32( shb_frame_ref_fx, shb_synth_nonref_fx, L_FRAME16k ); /* Q31-shb_synth_nonref_e */
    1033          12 :             shb_synth_nonref_e = shb_frame_ref_e;
    1034          12 :             move16();
    1035          12 :             set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
    1036          12 :             hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
    1037          12 :             move16();
    1038             :         }
    1039             : 
    1040          74 :         test();
    1041          74 :         test();
    1042          74 :         test();
    1043          74 :         IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
    1044             :         {
    1045             :             /* IC BWE spectral mapping */
    1046          62 :             spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */
    1047             :         }
    1048             :         ELSE
    1049             :         {
    1050          12 :             spIndx = 3;
    1051          12 :             hStereoICBWE->prevSpecMapping_fx = 0;
    1052          12 :             move16();
    1053          12 :             move32();
    1054             :         }
    1055             : 
    1056          74 :         push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
    1057             : 
    1058          74 :         IF( EQ_16( st->flag_ACELP16k, 1 ) )
    1059             :         {
    1060          62 :             push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS );
    1061             :         }
    1062             :         ELSE
    1063             :         {
    1064          12 :             hStereoICBWE->prevSpecMapping_fx = -1288490188; // -0.6 in Q31
    1065          12 :             move32();
    1066             :         }
    1067             : 
    1068             :         /* IC BWE GS mapping */
    1069             : 
    1070          74 :         gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
    1071             : 
    1072          74 :         hStereoICBWE->gDes_pastFrame_fx = gDes_fx; /* Q31-hStereoICBWE->gDes_pastFrame_e */
    1073          74 :         hStereoICBWE->gDes_pastFrame_e = gDes_e;
    1074          74 :         move32();
    1075          74 :         move16();
    1076          74 :         push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS );
    1077             :     }
    1078             : 
    1079             :     /* IC-BWE updates */
    1080       26711 :     hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe; /* Q0 */
    1081       26711 :     move16();
    1082             : 
    1083       26711 :     return;
    1084             : }
    1085             : 
    1086             : 
    1087             : /*-------------------------------------------------------------------*
    1088             :  * stereo_icBWE_init_enc()
    1089             :  *
    1090             :  * Stereo (inter-channel) BWE mapping - encoder initialization
    1091             :  *-------------------------------------------------------------------*/
    1092         884 : void stereo_icBWE_init_enc_fx(
    1093             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */
    1094             : )
    1095             : {
    1096             :     /* SHB speech resampler memory */
    1097         884 :     set16_fx( hStereoICBWE->mem_decim_shb_ch0_fx, 0, shl( L_FILT_MAX, 1 ) );
    1098             : 
    1099             :     /* SHB ref channel */
    1100         884 :     set16_fx( hStereoICBWE->mem_shb_speech_ref_fx, 0, L_LOOK_16k );
    1101         884 :     hStereoICBWE->mem_shb_speech_ref_e = 0;
    1102         884 :     move16();
    1103             : 
    1104             :     /* SHB non-ref channel */
    1105         884 :     set16_fx( hStereoICBWE->mem_shb_speech_nonref_fx, 0, L_LOOK_16k );
    1106         884 :     hStereoICBWE->mem_shb_speech_nonref_e = 0;
    1107         884 :     move16();
    1108             : 
    1109             :     /* unscaled & scaled SHB synthesis memory */
    1110         884 :     set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER );
    1111         884 :     hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
    1112         884 :     move16();
    1113             : 
    1114             :     /* inter-channel BWE spectral shape adj. */
    1115         884 :     hStereoICBWE->prevSpecMapping_fx = 0;
    1116         884 :     hStereoICBWE->prevgsMapping_fx = MAX_32; // Q31
    1117         884 :     move32();
    1118         884 :     move32();
    1119         884 :     set32_fx( &( hStereoICBWE->memShbSpecMapping_fx ), 0, 1 );
    1120         884 :     hStereoICBWE->memShbSpecMapping_e = 0;
    1121         884 :     move16();
    1122         884 :     set32_fx( hStereoICBWE->memShbSpecXcorr_fx, 0, 6 );
    1123         884 :     hStereoICBWE->memShbSpecXcorr_e = 0;
    1124         884 :     move16();
    1125             : 
    1126         884 :     hStereoICBWE->prevNonRefEner_fx = MAX_32; // Q31
    1127         884 :     hStereoICBWE->prevRefEner_fx = MAX_32;    // Q31
    1128         884 :     move32();
    1129         884 :     move32();
    1130             : 
    1131         884 :     set32_fx( hStereoICBWE->memGsEnerMap_fx, MAX_32, 2 ); // Q31
    1132             : 
    1133         884 :     set16_fx( hStereoICBWE->dec_2over3_mem_fx, 0, L_FILT_2OVER3 );
    1134         884 :     set16_fx( hStereoICBWE->dec_2over3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
    1135         884 :     set16_fx( hStereoICBWE->memHPF_fx, 0, 8 );
    1136             : 
    1137             :     /* BWE ref channel */
    1138         884 :     hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
    1139         884 :     hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
    1140         884 :     move16();
    1141         884 :     move16();
    1142             : 
    1143         884 :     set16_fx( hStereoICBWE->memModifyFs_icbwe_fx[0], 0, shl( L_FILT32k, 1 ) );
    1144         884 :     set16_fx( hStereoICBWE->memModifyFs_icbwe_fx[1], 0, shl( L_FILT32k, 1 ) );
    1145             : 
    1146         884 :     set32_fx( hStereoICBWE->mem_nrg_L_fx, 0, 2 );
    1147         884 :     hStereoICBWE->mem_nrg_L_fx_e = 0;
    1148         884 :     move16();
    1149         884 :     set32_fx( hStereoICBWE->mem_nrg_R_fx, 0, 2 );
    1150         884 :     hStereoICBWE->mem_nrg_R_fx_e = 0;
    1151         884 :     move16();
    1152         884 :     set32_fx( hStereoICBWE->mem_nrg_DMX_fx, 0, 2 );
    1153         884 :     hStereoICBWE->mem_nrg_DMX_fx_e = 0;
    1154         884 :     move16();
    1155             : 
    1156         884 :     hStereoICBWE->gDes_pastFrame_fx = MAX_32; // Q31
    1157         884 :     hStereoICBWE->icbweRefEner_fx = 0;
    1158         884 :     move32();
    1159         884 :     move32();
    1160         884 :     hStereoICBWE->gDes_pastFrame_fx = MAX_32; // Q31
    1161         884 :     move32();
    1162         884 :     hStereoICBWE->gDes_pastFrame_e = 0; // Q31
    1163         884 :     move16();
    1164         884 :     hStereoICBWE->prevgsMapping_fx = MAX_32;
    1165         884 :     move32();
    1166         884 :     hStereoICBWE->prevgsMapping_e = 0;
    1167         884 :     move16();
    1168         884 :     hStereoICBWE->MSFlag = 0;
    1169         884 :     move16();
    1170             : 
    1171         884 :     set16_fx( hStereoICBWE->nlExc16k_fx, 0, L_FRAME16k );
    1172         884 :     hStereoICBWE->nlExc16k_e = 0;
    1173         884 :     move16();
    1174         884 :     set16_fx( hStereoICBWE->mixExc16k_fx, 0, L_FRAME16k );
    1175         884 :     hStereoICBWE->mixExc16k_e = 0;
    1176         884 :     move16();
    1177             : 
    1178         884 :     return;
    1179             : }
    1180             : /*-------------------------------------------------------------------*
    1181             :  * findRefChanBWE()
    1182             :  *
    1183             :  *  Inter-channel BWE pre-proc of the non-ref channel
    1184             :  *-------------------------------------------------------------------*/
    1185          74 : static void findRefChanBWE_fx(
    1186             :     const Word16 *input0_fx,  /* i/o  : input 0 Qx                   q_dataChan_fx*/
    1187             :     const Word16 *input1_fx,  /* i/o  : input 1 Qx                   q_dataChan_fx*/
    1188             :     Word16 *refChanIndx_bwe,  /* o  : Ref Channel Index bwe          Q0*/
    1189             :     const Word16 input_frame, /* i  : input 0 & 1 frame length       Q0*/
    1190             :     Word16 *mem0_fx,          /* i/o  : mem 0 for input 0 Qx         q_dataChan_fx*/
    1191             :     Word16 *mem1_fx           /* i/o  : mem 1 for input 1 Qx         q_dataChan_fx*/
    1192             : )
    1193             : {
    1194             :     Word16 inp0_fx[L_FRAME48k], inp1_fx[L_FRAME48k];
    1195             :     Word32 tempF_fx, tempF1_fx;
    1196             : 
    1197          74 :     Copy( input0_fx, inp0_fx, input_frame ); /* q_dataChan_fx */
    1198          74 :     Copy( input1_fx, inp1_fx, input_frame ); /* q_dataChan_fx */
    1199             : 
    1200          74 :     spectral_balancer_fx16( inp0_fx, mem0_fx, input_frame, 1 );
    1201          74 :     spectral_balancer_fx16( inp1_fx, mem1_fx, input_frame, 1 );
    1202             : 
    1203          74 :     tempF_fx = sum2_f_16_gb_fx( inp0_fx, input_frame, find_guarded_bits_fx( input_frame ) );  // Q(2x-find_guarded_bits_fx( input_frame ))
    1204          74 :     tempF1_fx = sum2_f_16_gb_fx( inp1_fx, input_frame, find_guarded_bits_fx( input_frame ) ); // Q(2x-find_guarded_bits_fx( input_frame ))
    1205             : 
    1206          74 :     IF( LT_32( tempF1_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF_fx ) ) )
    1207             :     {
    1208           0 :         *refChanIndx_bwe = L_CH_INDX; /* Q0 */
    1209           0 :         move16();
    1210             :     }
    1211          74 :     ELSE IF( LT_32( tempF_fx, Mpy_32_32( 1374389535 /* 0.64f Q31 */, tempF1_fx ) ) )
    1212             :     {
    1213          10 :         *refChanIndx_bwe = R_CH_INDX; /* Q0 */
    1214          10 :         move16();
    1215             :     }
    1216             : 
    1217          74 :     return;
    1218             : }
    1219             : 
    1220             : 
    1221             : /*-------------------------------------------------------------------*
    1222             :  * stereo_icBWE_preproc()
    1223             :  *
    1224             :  *  Inter-channel BWE pre-proc of the non-ref channel
    1225             :  *-------------------------------------------------------------------*/
    1226       48267 : void stereo_icBWE_preproc_fx(
    1227             :     CPE_ENC_HANDLE hCPE,           /* i/o: CPE encoder structure         */
    1228             :     const Word16 input_frame,      /* i  : input frame length            Q0*/
    1229             :     Word16 shb_speech_nonref_fx[], /* o  : SHB speech non-ref channel    q_shb_speech_nonref_fx*/
    1230             :     Word16 q_shb_speech_nonref_fx  /* i  : Q SHB speech non-ref channel  */
    1231             : )
    1232             : {
    1233             :     Word16 i, refChanIndx_bwe;
    1234             :     STEREO_TCA_ENC_HANDLE hStereoTCA;
    1235             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
    1236             :     Encoder_State *st;
    1237             :     Word16 temp_inp_fx[L_FRAME48k];
    1238             :     Word16 tempSHB_fx[L_FRAME16k];
    1239             :     Word16 temp_in_fx[L_FRAME48k];
    1240             :     Word16 /*nonRefOffset,*/ nonRefMemLen;
    1241             :     Word32 gD_fx;
    1242             :     Word32 input_Fs;
    1243             : 
    1244       48267 :     set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1245             : 
    1246             :     /* initialization */
    1247       48267 :     hStereoTCA = hCPE->hStereoTCA;     /* Stereo TCA encoder handle    */
    1248       48267 :     hStereoICBWE = hCPE->hStereoICBWE; /* Stereo IC BWE encoder handle */
    1249       48267 :     st = hCPE->hCoreCoder[0];
    1250       48267 :     input_Fs = st->input_Fs;
    1251       48267 :     move32();
    1252             : 
    1253             :     /*nonRefOffset = NS2SA(st_ivas->input_Fs, ACELP_LOOK_NS - L_MEM_RECALC_TBE_NS);*/
    1254       48267 :     nonRefMemLen = NS2SA_FX2( input_Fs, L_MEM_RECALC_TBE_NS );
    1255             : 
    1256       48267 :     test();
    1257       48267 :     test();
    1258       48267 :     test();
    1259       48267 :     IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) || NE_16( st->core, ACELP_CORE ) || EQ_16( st->extl, -1 ) || LT_32( input_Fs, 32000 ) )
    1260             :     {
    1261       13078 :         set16_fx( hStereoICBWE->dec_2over3_mem_fx, 0, L_FILT_2OVER3 );
    1262       13078 :         set16_fx( hStereoICBWE->dec_2over3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
    1263       13078 :         set16_fx( hStereoICBWE->mem_decim_shb_ch0_fx, 0, ( 2 * L_FILT_MAX ) );
    1264       13078 :         set16_fx( shb_speech_nonref_fx, 0, L_FRAME16k );
    1265       13078 :         set16_fx( hStereoICBWE->memHPF_fx, 0, 8 );
    1266       13078 :         hStereoICBWE->refChanIndx_bwe = hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
    1267       13078 :         move16();
    1268       13078 :         move16();
    1269             : 
    1270       13078 :         test();
    1271       13078 :         IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) )
    1272             :         {
    1273       13078 :             set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1274       13078 :             Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
    1275             : 
    1276       13078 :             IF( EQ_32( input_Fs, 48000 ) )
    1277             :             {
    1278        5998 :                 Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
    1279        5998 :                 set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1280        5998 :                 i = 2 * L_FILT48k + L_FILT_2OVER3;
    1281        5998 :                 move16();
    1282             : 
    1283        5998 :                 decimate_2_over_3_allpass_fx( temp_in_fx + sub( input_frame, i ), i, temp_inp_fx + mult( sub( input_frame, i ), 21845 /* 2/3 Q15*/ ), hStereoICBWE->dec_2over3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hStereoICBWE->dec_2over3_mem_lp_fx );
    1284             :             }
    1285             :             /* flip the spectrum */
    1286     4198038 :             FOR( i = 0; i < L_FRAME32k; i += 2 )
    1287             :             {
    1288     4184960 :                 temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
    1289     4184960 :                 move16();
    1290             :             }
    1291       13078 :             Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[0], 2 * L_FILT32k ); /* q_dataChan_fx */
    1292             : 
    1293       13078 :             set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1294       13078 :             Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
    1295             : 
    1296       13078 :             IF( EQ_32( input_Fs, 48000 ) )
    1297             :             {
    1298        5998 :                 Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
    1299        5998 :                 set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1300        5998 :                 i = 2 * L_FILT48k + L_FILT_2OVER3;
    1301        5998 :                 move16();
    1302             : 
    1303             :                 /* IVAS-219: the same filter memories are used for both channels; the continuity is thus lost; shouldn't the memories be separated? */
    1304        5998 :                 decimate_2_over_3_allpass_fx( temp_in_fx + sub( input_frame, i ), i, temp_inp_fx + mult( sub( input_frame, i ), 21845 /* 2/3 Q15*/ ), hStereoICBWE->dec_2over3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hStereoICBWE->dec_2over3_mem_lp_fx );
    1305             :             }
    1306             :             /* flip the spectrum */
    1307     5157718 :             FOR( i = 0; i < input_frame; i += 2 )
    1308             :             {
    1309     5144640 :                 temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
    1310     5144640 :                 move16();
    1311             :             }
    1312       13078 :             Copy( temp_inp_fx + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe_fx[1], 2 * L_FILT32k ); /* q_dataChan_fx */
    1313             :         }
    1314             : 
    1315       13078 :         return;
    1316             :     }
    1317             : 
    1318       35189 :     IF( NE_16( hCPE->element_mode, IVAS_CPE_TD ) )
    1319             :     {
    1320             :         /* initial estimate of refChanIndx_bwe */
    1321       35115 :         gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
    1322       35115 :         move32();
    1323             : 
    1324       35115 :         refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
    1325       35115 :         move16();
    1326       35115 :         test();
    1327       35115 :         test();
    1328       35115 :         test();
    1329       35115 :         IF( ( GT_32( gD_fx, ONE_IN_Q29 ) && EQ_16( refChanIndx_bwe, R_CH_INDX ) ) || ( LT_32( gD_fx, ONE_IN_Q29 ) && EQ_16( refChanIndx_bwe, L_CH_INDX ) ) )
    1330             :         {
    1331       21711 :             refChanIndx_bwe = !( hStereoTCA->refChanIndx );
    1332       21711 :             move16();
    1333             :         }
    1334       35115 :         hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe; /* Q0 */
    1335       35115 :         move16();
    1336             : 
    1337       35115 :         set16_fx( hStereoICBWE->dec_2over3_mem_fx, 0, L_FILT_2OVER3 );
    1338       35115 :         set16_fx( hStereoICBWE->dec_2over3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
    1339       35115 :         set16_fx( hStereoICBWE->mem_decim_shb_ch0_fx, 0, ( 2 * L_FILT_MAX ) );
    1340       35115 :         set16_fx( shb_speech_nonref_fx, 0, L_FRAME16k );
    1341       35115 :         set16_fx( hStereoICBWE->memHPF_fx, 0, 8 );
    1342             : 
    1343       35115 :         return;
    1344             :     }
    1345             : 
    1346          74 :     gD_fx = hStereoTCA->targetGain_fx; /* Q29 */
    1347          74 :     move32();
    1348             : 
    1349          74 :     refChanIndx_bwe = hStereoTCA->refChanIndx; /* Q0 */
    1350          74 :     move16();
    1351          74 :     test();
    1352          74 :     test();
    1353          74 :     test();
    1354          74 :     IF( ( GT_32( gD_fx, ONE_IN_Q29 ) && EQ_16( refChanIndx_bwe, R_CH_INDX ) ) || ( LT_32( gD_fx, ONE_IN_Q29 ) && EQ_16( refChanIndx_bwe, L_CH_INDX ) ) )
    1355             :     {
    1356           3 :         refChanIndx_bwe = !( hStereoTCA->refChanIndx );
    1357           3 :         move16();
    1358             :     }
    1359             : 
    1360          74 :     findRefChanBWE_fx( hStereoICBWE->dataChan_fx[0], hStereoICBWE->dataChan_fx[1], &refChanIndx_bwe, input_frame, &hStereoICBWE->memHPF_fx[0], &hStereoICBWE->memHPF_fx[4] );
    1361             : 
    1362          74 :     hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
    1363          74 :     move16();
    1364             : 
    1365          74 :     IF( EQ_16( refChanIndx_bwe, R_CH_INDX ) )
    1366             :     {
    1367          10 :         Copy( hStereoICBWE->icbwe_inp_mem_fx[0], temp_inp_fx, nonRefMemLen );                               /* q_dataChan_fx */
    1368          10 :         Copy( hStereoICBWE->dataChan_fx[0], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
    1369             :     }
    1370             :     ELSE
    1371             :     {
    1372          64 :         Copy( hStereoICBWE->icbwe_inp_mem_fx[1], temp_inp_fx, nonRefMemLen );                               /* q_dataChan_fx */
    1373          64 :         Copy( hStereoICBWE->dataChan_fx[1], temp_inp_fx + nonRefMemLen, sub( input_frame, nonRefMemLen ) ); /* q_dataChan_fx */
    1374             :     }
    1375             : 
    1376          74 :     IF( EQ_32( input_Fs, 48000 ) )
    1377             :     {
    1378             :         /*printf("\n Non-ref target HB generation for 48 kHz sample rate needs alignment verification \n");*/
    1379           2 :         Copy( temp_inp_fx, temp_in_fx, L_FRAME48k ); /* q_dataChan_fx */
    1380           2 :         set16_fx( temp_inp_fx, 0, L_FRAME48k );
    1381             : 
    1382           2 :         decimate_2_over_3_allpass_fx( temp_in_fx, L_FRAME48k, temp_inp_fx, hStereoICBWE->dec_2over3_mem_fx, allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hStereoICBWE->dec_2over3_mem_lp_fx );
    1383             :     }
    1384             : 
    1385             :     /* flip the spectrum */
    1386       24074 :     FOR( i = 0; i < input_frame; i += 2 )
    1387             :     {
    1388       24000 :         temp_inp_fx[i] = negate( temp_inp_fx[i] ); /* q_dataChan_fx */
    1389       24000 :         move16();
    1390             :     }
    1391             : 
    1392          74 :     test();
    1393          74 :     test();
    1394          74 :     test();
    1395          74 :     IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && GE_32( input_Fs, 32000 ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_extl, -1 ) ) )
    1396             :     {
    1397           0 :         Copy_Scale_sig( hStereoICBWE->memModifyFs_icbwe_fx[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0_fx, 2 * L_FILT32k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* Q0 */
    1398             :     }
    1399             : 
    1400             :     Word16 Q_new_inp, mem_decim_size;
    1401          74 :     Scale_sig( temp_inp_fx, L_FRAME48k, sub( 0, hStereoICBWE->q_dataChan_fx ) ); /* q_dataChan_fx */
    1402             : 
    1403             :     /* IVAS-219: Re-wire the shb nonref estimation through a lite CLDFB */
    1404          74 :     modify_Fs_ivas_fx( temp_inp_fx, L_FRAME32k, 32000, tempSHB_fx, 16000, hStereoICBWE->mem_decim_shb_ch0_fx, 0, &Q_new_inp, &mem_decim_size );
    1405             : 
    1406          74 :     Copy_Scale_sig( tempSHB_fx, shb_speech_nonref_fx, L_FRAME16k, sub( q_shb_speech_nonref_fx, Q_new_inp ) ); /* q_shb_speech_nonref_fx */
    1407             : 
    1408          74 :     return;
    1409             : }

Generated by: LCOV version 1.14