LCOV - code coverage report
Current view: top level - lib_enc - ivas_stereo_icbwe_enc.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 8834b716eb6d7dfb881d5c69dd21cb18e1692722 Lines: 320 327 97.9 %
Date: 2025-07-09 08:36:12 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.h"
      39             : #include "ivas_prot.h"
      40             : #include "wmc_auto.h"
      41             : #include "rom_com.h"
      42             : #include "ivas_rom_com.h"
      43             : #ifdef DEBUGGING
      44             : #include "debug.h"
      45             : #endif
      46             : 
      47             : /*-------------------------------------------------------------------*
      48             :  * ic_bwe_enc_reset()
      49             :  *
      50             :  * core switching reset of IC BWE memory
      51             :  *-------------------------------------------------------------------*/
      52             : 
      53       22773 : static void ic_bwe_enc_reset(
      54             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo ICBWE handle */
      55             : )
      56             : {
      57             :     /* unscaled & scaled SHB synthesis memory */
      58       22773 :     set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, LPC_SHB_ORDER );
      59             : 
      60             :     /* inter-channel BWE spectral shape adj. */
      61       22773 :     hStereoICBWE->prevSpecMapping = 0;
      62       22773 :     hStereoICBWE->prevgsMapping = 1.0f;
      63       22773 :     set_f( &( hStereoICBWE->memShbSpecMapping ), 0, 1 );
      64       22773 :     set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
      65       22773 :     set_f( hStereoICBWE->memGsEnerMap, 1.0f, 2 );
      66       22773 :     set_f( hStereoICBWE->mem_nrg_L, 0, 2 );
      67       22773 :     set_f( hStereoICBWE->mem_nrg_R, 0, 2 );
      68       22773 :     set_f( hStereoICBWE->mem_nrg_DMX, 0, 2 );
      69       22773 :     hStereoICBWE->gDes_pastFrame = 1.0f;
      70       22773 :     hStereoICBWE->icbweRefEner = 0.0f;
      71             : 
      72       22773 :     return;
      73             : }
      74             : 
      75             : /*--------------------------------------------------------------------------*
      76             :  * ic_bwe_specMapping()
      77             :  *
      78             :  * Encode and apply the spectral shape mapping of ref to the non-ref channel
      79             :  *---------------------------------------------------------------------------*/
      80             : 
      81          22 : static int16_t ic_bwe_enc_specMapping(
      82             :     const float *shb_frame_target, /* i  : target shb                          */
      83             :     float *shb_synth_nonref,       /* o  : non-ref shb synth                   */
      84             :     float *specMapping,            /* i/o: current frame's mapping             */
      85             :     float *memShbSpecMapping,      /* i/o: ic bwe filtering memory             */
      86             :     float *memShbSpecXcorr         /* i/o: ic bwe spec mapping scorr memory    */
      87             : )
      88             : {
      89             :     int16_t idx;
      90          22 :     float Txx1 = 0, Txx2 = 0, Txx3 = 0, T_desired = 0;
      91             :     float T_nonref_target;
      92             :     float temp, temp0, temp1, temp2, temp3, alpha;
      93             :     float a, b, c;
      94             :     float u, u1, u2;
      95             : 
      96          22 :     alpha = 0.5f;
      97             :     /* Calculate rxx(1)/rxx(0) of the non ref target */
      98          22 :     temp0 = dotp( shb_frame_target, shb_frame_target, L_FRAME16k - 1 );
      99          22 :     temp1 = dotp( shb_frame_target, shb_frame_target + 1, L_FRAME16k - 1 );
     100             : 
     101             :     /* Smoothing */
     102          22 :     temp0 = alpha * memShbSpecXcorr[0] + ( 1 - alpha ) * temp0;
     103          22 :     temp1 = alpha * memShbSpecXcorr[1] + ( 1 - alpha ) * temp1;
     104          22 :     memShbSpecXcorr[0] = temp0;
     105          22 :     memShbSpecXcorr[1] = temp1;
     106             : 
     107          22 :     T_nonref_target = ( temp0 != 0 ) ? ( temp1 / temp0 ) : ( 0 );
     108             : 
     109             :     /* Calculate rxx(1)/rxx(0) of the non ref synth */
     110          22 :     temp0 = dotp( shb_synth_nonref, shb_synth_nonref, L_FRAME16k - 3 );
     111          22 :     temp1 = dotp( shb_synth_nonref, shb_synth_nonref + 1, L_FRAME16k - 3 );
     112          22 :     temp2 = dotp( shb_synth_nonref, shb_synth_nonref + 2, L_FRAME16k - 3 );
     113          22 :     temp3 = dotp( shb_synth_nonref, shb_synth_nonref + 3, L_FRAME16k - 3 );
     114             : 
     115             :     /* Smoothing */
     116          22 :     temp0 = alpha * memShbSpecXcorr[2] + ( 1 - alpha ) * temp0;
     117          22 :     temp1 = alpha * memShbSpecXcorr[3] + ( 1 - alpha ) * temp1;
     118          22 :     temp2 = alpha * memShbSpecXcorr[4] + ( 1 - alpha ) * temp2;
     119          22 :     temp3 = alpha * memShbSpecXcorr[5] + ( 1 - alpha ) * temp3;
     120             : 
     121          22 :     memShbSpecXcorr[2] = temp0;
     122          22 :     memShbSpecXcorr[3] = temp1;
     123          22 :     memShbSpecXcorr[4] = temp2;
     124          22 :     memShbSpecXcorr[5] = temp3;
     125             : 
     126          22 :     if ( temp0 != 0 )
     127             :     {
     128          22 :         Txx1 = temp1 / temp0;
     129          22 :         Txx2 = temp2 / temp0;
     130          22 :         Txx3 = temp3 / temp0;
     131             :     }
     132             : 
     133          22 :     T_desired = T_nonref_target;
     134             : 
     135          22 :     a = 2 * Txx2 * T_desired - Txx3 - Txx1;
     136          22 :     b = ( 2 * T_desired * Txx1 - Txx2 - 1.0f );
     137          22 :     c = ( T_desired - Txx1 );
     138             : 
     139          22 :     u = *specMapping;
     140          22 :     temp = ( b * b - 4 * a * c );
     141          22 :     if ( temp >= 0 && a != 0 )
     142             :     {
     143          22 :         temp = sqrtf( temp );
     144          22 :         u1 = ( -b + temp ) / ( 2 * a );
     145          22 :         u2 = ( -b - temp ) / ( 2 * a );
     146             : 
     147          22 :         if ( fabsf( u1 ) < 1.0f && fabsf( u2 ) < 1.0f )
     148             :         {
     149           0 :             u = min( u1, u2 );
     150             :         }
     151          22 :         else if ( fabsf( u1 ) < 1.0f )
     152             :         {
     153           0 :             u = u1;
     154             :         }
     155          22 :         else if ( fabsf( u2 ) < 1.0f )
     156             :         {
     157          22 :             u = u2;
     158             :         }
     159             :     }
     160          22 :     u = max( min( u, 0 ), -0.6f );
     161             : 
     162             :     /* Quantize spec. mapping **/
     163          22 :     idx = (int16_t) usquant( u, specMapping, -0.6f, 0.2f, 1 << STEREO_ICBWE_SPBITS );
     164             : 
     165             :     /* IC-BWE spec mapping */
     166          22 :     deemph( shb_synth_nonref, *specMapping, L_FRAME16k, memShbSpecMapping );
     167             : 
     168          22 :     return idx;
     169             : }
     170             : 
     171             : /*----------------------------------------------------------------------*
     172             :  * ic_bwe_gsMapping()
     173             :  *
     174             :  * Encode and apply the gain shape mapping of ref to the non-ref channel
     175             :  *-----------------------------------------------------------------------*/
     176             : 
     177             : /*! r: return quant. index value */
     178       26753 : static int16_t ic_bwe_enc_gsMapping(
     179             :     const float relG_targ,  /* i  : gDes, rel gain target       */
     180             :     const float *shbSynth,  /* i  : ref synth signal            */
     181             :     float *synthSHB_nonref, /* i  : nonref synth signal         */
     182             :     float *gsMapping,       /* i/o: gs mapping                  */
     183             :     float *memEner,
     184             :     const int16_t element_mode /* i  : element mode                 */
     185             : )
     186             : {
     187             :     int16_t i;
     188       26753 :     int16_t idx = 0;
     189             :     float temp1, temp2;
     190             :     float alpha;
     191             :     float prev_gsMapping;
     192             : 
     193       26753 :     alpha = 0;
     194       26753 :     prev_gsMapping = *gsMapping;
     195             : 
     196             :     /* rel gain of synth signals */
     197     8587713 :     for ( i = 0, temp1 = 0, temp2 = 0; i < L_FRAME16k; i++ )
     198             :     {
     199     8560960 :         temp1 += fabsf( shbSynth[i] );
     200     8560960 :         temp2 += fabsf( synthSHB_nonref[i] );
     201             :     }
     202       26753 :     temp1 = alpha * memEner[0] + ( 1 - alpha ) * temp1;
     203       26753 :     temp2 = alpha * memEner[1] + ( 1 - alpha ) * temp2;
     204             : 
     205       26753 :     memEner[0] = temp1;
     206       26753 :     memEner[1] = temp2;
     207             : 
     208       26753 :     *gsMapping = ( temp2 == 0 ) ? ( *gsMapping ) : ( ( relG_targ * temp1 ) / temp2 );
     209       26753 :     temp2 = ( 0.0f ) * log10f( prev_gsMapping ) + ( 1.0f ) * log10f( *gsMapping ); /* no impact from prev_gsMapping */
     210             : 
     211             :     /* quantize the IC-BWE GS mapping*/
     212       26753 :     if ( element_mode == IVAS_CPE_TD )
     213             :     {
     214          34 :         idx = squant( temp2, gsMapping, icbwe_gsMapping_tbl, 1 << STEREO_ICBWE_GSBITS );
     215             :     }
     216             :     else
     217             :     {
     218       26719 :         idx = squant( temp2, gsMapping, icbwe_gsMappingDFT_tbl, 1 << STEREO_ICBWE_GSBITS_DFT );
     219             :     }
     220             : 
     221       26753 :     *gsMapping = powf( 10, *gsMapping );
     222             : 
     223       26753 :     return idx;
     224             : }
     225             : 
     226             : 
     227             : /*----------------------------------------------------------------------*
     228             :  * icbwe_dft_stereo_param()
     229             :  *
     230             :  * Estimate ICBWE parameters in DFT stereo
     231             :  *-----------------------------------------------------------------------*/
     232             : 
     233       26719 : static void icbwe_dft_stereo_param(
     234             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE,  /* i/o: */
     235             :     STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i  : */
     236             :     Encoder_State *st,                     /* i/o: */
     237             :     float *shb_synth_nonref                /* i/o: */
     238             : )
     239             : {
     240             :     float slopeILD, normFac, gDes, alpha;
     241             :     int16_t gsIndx, spIndx;
     242             :     float *nrg_L, *nrg_R, *nrg_DMX;
     243             :     float sum_nrg_L, sum_nrg_R, sum_nrg_DMX;
     244       26719 :     const float slope_table[4] = { -2.17141801027151f, -1.29118591145892f, -0.588623666024448f, 0 };
     245       26719 :     const float spec_table[4] = { -0.6f, -0.4f, -0.2f, 0 };
     246             : 
     247       26719 :     BSTR_ENC_HANDLE hBstr = st->hBstr;
     248             : 
     249       26719 :     normFac = 2.5f; /* 1000 * (10/((14400+10400)/2 - (6400+10400)/2)) */
     250             : 
     251       26719 :     nrg_L = hStereoDft->nrg_L;
     252       26719 :     nrg_R = hStereoDft->nrg_R;
     253       26719 :     nrg_DMX = hStereoDft->nrg_DMX;
     254             : 
     255       26719 :     alpha = 0.0f;
     256       26719 :     hStereoICBWE->mem_nrg_L[0] = alpha * hStereoICBWE->mem_nrg_L[0] + ( 1 - alpha ) * nrg_L[0];
     257       26719 :     hStereoICBWE->mem_nrg_R[0] = alpha * hStereoICBWE->mem_nrg_R[0] + ( 1 - alpha ) * nrg_R[0];
     258       26719 :     hStereoICBWE->mem_nrg_DMX[0] = alpha * hStereoICBWE->mem_nrg_DMX[0] + ( 1 - alpha ) * nrg_DMX[0];
     259       26719 :     hStereoICBWE->mem_nrg_L[1] = alpha * hStereoICBWE->mem_nrg_L[1] + ( 1 - alpha ) * nrg_L[1];
     260       26719 :     hStereoICBWE->mem_nrg_R[1] = alpha * hStereoICBWE->mem_nrg_R[1] + ( 1 - alpha ) * nrg_R[1];
     261       26719 :     hStereoICBWE->mem_nrg_DMX[1] = alpha * hStereoICBWE->mem_nrg_DMX[1] + ( 1 - alpha ) * nrg_DMX[1];
     262             : 
     263       26719 :     sum_nrg_L = sum_f( hStereoICBWE->mem_nrg_L, 2 );
     264       26719 :     sum_nrg_R = sum_f( hStereoICBWE->mem_nrg_R, 2 );
     265       26719 :     sum_nrg_DMX = sum_f( hStereoICBWE->mem_nrg_DMX, 2 );
     266             : 
     267             :     /* refChanIndex_bwe refinement */
     268       26719 :     if ( ( sum_nrg_R < 0.64f * sum_nrg_L && hStereoICBWE->refChanIndx_bwe == hStereoICBWE->prev_refChanIndx_bwe ) || sum_nrg_R < 0.36f * sum_nrg_L )
     269             :     {
     270        4433 :         hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
     271             :     }
     272       22286 :     else if ( ( sum_nrg_L < 0.64f * sum_nrg_R && hStereoICBWE->refChanIndx_bwe == hStereoICBWE->prev_refChanIndx_bwe ) || sum_nrg_L < 0.36f * sum_nrg_R )
     273             :     {
     274        9600 :         hStereoICBWE->refChanIndx_bwe = R_CH_INDX;
     275             :     }
     276             : 
     277             :     /* Initialization of spIndx */
     278       26719 :     slopeILD = 0;
     279       26719 :     spIndx = squant( slopeILD, &slopeILD, slope_table, 1 << STEREO_ICBWE_SPBITS_DFT );
     280             : 
     281       26719 :     if ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     282             :     {
     283             :         /* Spec Mapping Estimate */
     284       12586 :         slopeILD = normFac * ( log10f( ( hStereoICBWE->mem_nrg_L[1] * hStereoICBWE->mem_nrg_R[0] ) / ( hStereoICBWE->mem_nrg_R[1] * hStereoICBWE->mem_nrg_L[0] ) ) );
     285       12586 :         slopeILD = ( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) ? ( -slopeILD ) : ( slopeILD );
     286       12586 :         spIndx = squant( slopeILD, &slopeILD, slope_table, 1 << STEREO_ICBWE_SPBITS_DFT );
     287       12586 :         if ( spec_table[spIndx] * hStereoICBWE->prevSpecMapping < 0 )
     288             :         {
     289           0 :             slopeILD = 0;
     290           0 :             spIndx = squant( slopeILD, &slopeILD, slope_table, 1 << STEREO_ICBWE_SPBITS_DFT );
     291             :         }
     292       12586 :         hStereoICBWE->prevSpecMapping = spec_table[spIndx];
     293             : 
     294             :         /* ic bwe spec mapping application */
     295       12586 :         deemph( shb_synth_nonref, hStereoICBWE->prevSpecMapping, L_FRAME16k, &hStereoICBWE->memShbSpecMapping );
     296             :     }
     297             :     else
     298             :     {
     299       14133 :         hStereoICBWE->memShbSpecMapping = 0;
     300       14133 :         hStereoICBWE->prevSpecMapping = 0;
     301             :     }
     302             : 
     303             :     /* gsMapping estimate */
     304             : 
     305       26719 :     gDes = ( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) ? ( sum_nrg_R / sum_nrg_DMX ) : ( sum_nrg_L / sum_nrg_DMX );
     306       26719 :     gDes = sqrtf( gDes );
     307             : 
     308       26719 :     alpha = 0.5f;
     309             :     /* Geometric Mean */
     310       26719 :     hStereoICBWE->gDes_pastFrame = powf( hStereoICBWE->gDes_pastFrame, alpha ) * powf( gDes, 1 - alpha );
     311             : 
     312       26719 :     gsIndx = ic_bwe_enc_gsMapping( hStereoICBWE->gDes_pastFrame, hStereoICBWE->shbSynthRef, shb_synth_nonref, &( hStereoICBWE->prevgsMapping ), hStereoICBWE->memGsEnerMap, st->element_mode );
     313       26719 :     hStereoICBWE->gDes_pastFrame = gDes;
     314             : 
     315       26719 :     push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
     316       26719 :     if ( st->flag_ACELP16k == 1 )
     317             :     {
     318       13109 :         push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS_DFT );
     319             :     }
     320             : 
     321             :     /* IC BWE GS mapping */
     322       26719 :     push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS_DFT );
     323             : 
     324       26719 :     return;
     325             : }
     326             : 
     327             : 
     328             : /*-------------------------------------------------------------------*
     329             :  * stereo_icBWE_enc()
     330             :  *
     331             :  * Encode the spatial mapping of reference to the non-reference channels in HB
     332             :  *-------------------------------------------------------------------*/
     333             : 
     334       48232 : void stereo_icBWE_enc(
     335             :     CPE_ENC_HANDLE hCPE,          /* i/o: CPE encoder structure                */
     336             :     const float shb_speech_ref[], /* i  : SHB speech ref channel               */
     337             :     float shb_speech_nonref[],    /* i/o: SHB speech non-ref channel           */
     338             :     const float *voice_factors    /* i  : voicing factors                      */
     339             : )
     340             : {
     341             :     int16_t i, j, k, nbSubFr;
     342             :     STEREO_DFT_ENC_DATA_HANDLE hStereoDft;
     343             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
     344             :     BSTR_ENC_HANDLE hBstr;
     345             :     Encoder_State *st;
     346             :     int16_t spIndx, gsIndx;
     347             :     float shb_frame_ref[L_LOOK_16k + L_FRAME16k];
     348             :     float excSHB_nonref[L_FRAME16k];
     349             :     float shb_frame_nonref[L_LOOK_16k + L_FRAME16k];
     350             :     float shb_synth_nonref[L_FRAME16k];
     351             : 
     352             :     float nlMixFac[NB_SUBFR16k];
     353             :     float temp1, temp2;
     354             :     float gDes, gTarget;
     355             :     int16_t nonRefMemLen, refMemLen;
     356             : 
     357             :     /* initialization */
     358       48232 :     hStereoDft = hCPE->hStereoDft;
     359       48232 :     hStereoICBWE = hCPE->hStereoICBWE;
     360       48232 :     st = hCPE->hCoreCoder[0];
     361       48232 :     hBstr = st->hBstr;
     362             : 
     363       48232 :     gTarget = hCPE->hStereoTCA->targetGain; /* i  : gain norm for target (or R) channel  */
     364             : 
     365       48232 :     nonRefMemLen = L_MEM_RECALC_TBE_16K + L_FILT16k;
     366             : 
     367       48232 :     if ( st->element_mode == IVAS_CPE_TD )
     368             :     {
     369         108 :         refMemLen = L_MEM_RECALC_TBE_16K + 20;
     370             :     }
     371       48124 :     else if ( st->element_mode == IVAS_CPE_DFT && st->core_brate > SID_2k40 )
     372             :     {
     373       39919 :         refMemLen = 20;
     374             :     }
     375             :     else
     376             :     {
     377        8205 :         ic_bwe_enc_reset( hStereoICBWE );
     378             : 
     379        8205 :         return;
     380             :     }
     381             : 
     382       40027 :     if ( st->element_mode == IVAS_CPE_DFT )
     383             :     {
     384             :         /* memory resets */
     385       39919 :         set_f( hStereoICBWE->mem_shb_speech_nonref, 0, L_LOOK_16k );
     386       39919 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     387             : 
     388             :         /* core switching reset */
     389       39919 :         if ( st->last_core != ACELP_CORE || st->core != ACELP_CORE || st->bwidth < SWB || st->extl == -1 )
     390             :         {
     391       14494 :             ic_bwe_enc_reset( hStereoICBWE );
     392       14494 :             if ( st->core != ACELP_CORE || st->bwidth < SWB || st->input_Fs < 32000 || st->extl == -1 )
     393             :             {
     394       13200 :                 return;
     395             :             }
     396             :         }
     397             : 
     398       26719 :         set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
     399             : 
     400       26719 :         hStereoICBWE->prevRefEner = 0;
     401       26719 :         hStereoICBWE->prevNonRefEner = 0;
     402             : 
     403             :         /* SHB frame buffer offsets for TBE processing << re-adjust check >>*/
     404       26719 :         set_f( shb_frame_ref, 0, L_LOOK_16k + L_FRAME16k );
     405       26719 :         mvr2r( hStereoICBWE->mem_shb_speech_ref, shb_frame_ref, L_LOOK_16k );
     406             : 
     407             :         /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
     408       26719 :         mvr2r( shb_speech_ref, shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k );
     409       26719 :         mvr2r( shb_frame_ref + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref, L_LOOK_16k );
     410             : 
     411       26719 :         if ( ( st->extl == SWB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     412             :         {
     413       12586 :             mvr2r( voice_factors, nlMixFac, NB_SUBFR16k );
     414             :             /*if( gDes < 0.5f || gDes > 2.0f )*/
     415       12586 :             if ( gTarget < 0.5f || gTarget > 2.0f )
     416             :             {
     417        1167 :                 v_multc( voice_factors, 0.5f, nlMixFac, NB_SUBFR16k );
     418             :             }
     419             : 
     420       12586 :             nbSubFr = ( st->flag_ACELP16k == 0 ) ? NB_SUBFR : NB_SUBFR16k;
     421       75516 :             for ( i = 0, k = 0; i < nbSubFr; i++ )
     422             :             {
     423       62930 :                 if ( st->coder_type == UNVOICED || hStereoICBWE->MSFlag == 1 )
     424             :                 {
     425       14595 :                     temp1 = 0;
     426       14595 :                     temp2 = 1.0f;
     427             :                 }
     428             :                 else
     429             :                 {
     430       48335 :                     temp1 = sqrtf( nlMixFac[i] );
     431       48335 :                     temp2 = sqrtf( 1.0f - nlMixFac[i] );
     432             :                 }
     433             : 
     434     4090450 :                 for ( j = 0; j < ( L_FRAME16k / nbSubFr ); j++, k++ )
     435             :                 {
     436     4027520 :                     excSHB_nonref[k] = temp1 * hStereoICBWE->nlExc16k[k] + temp2 * hStereoICBWE->mixExc16k[k];
     437             :                 }
     438             :             }
     439             : 
     440             :             /* LP synthesis */
     441       12586 :             syn_filt( hStereoICBWE->lpSHBRef, LPC_SHB_ORDER, excSHB_nonref, shb_synth_nonref, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref, 1 );
     442             :         }
     443             :         else
     444             :         {
     445       14133 :             mvr2r( shb_frame_ref, hStereoICBWE->shbSynthRef, L_FRAME16k );
     446       14133 :             mvr2r( shb_frame_ref, shb_synth_nonref, L_FRAME16k );
     447       14133 :             set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, 10 );
     448             :         }
     449             : 
     450       26719 :         icbwe_dft_stereo_param( hStereoICBWE, hStereoDft, st, shb_synth_nonref );
     451             :     }
     452             :     else
     453             :     {
     454             :         /* SHB frame buffer offsets for TBE processing << re-adjust check >>*/
     455         108 :         set_f( shb_frame_ref, 0, L_LOOK_16k + L_FRAME16k );
     456         108 :         mvr2r( hStereoICBWE->mem_shb_speech_ref, shb_frame_ref, L_LOOK_16k );
     457             : 
     458             :         /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */
     459         108 :         mvr2r( shb_speech_ref, shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k );
     460         108 :         mvr2r( shb_frame_ref + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref, L_LOOK_16k );
     461             : 
     462         108 :         set_f( shb_frame_nonref, 0, L_LOOK_16k + L_FRAME16k );
     463         108 :         mvr2r( hStereoICBWE->mem_shb_speech_nonref, shb_frame_nonref, L_LOOK_16k );
     464         108 :         mvr2r( shb_speech_nonref, shb_frame_nonref + L_LOOK_16k - nonRefMemLen, L_FRAME16k );
     465         108 :         mvr2r( shb_frame_nonref + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref, L_LOOK_16k );
     466             : 
     467             :         /* core switching reset */
     468         108 :         if ( st->last_core != ACELP_CORE || st->core != ACELP_CORE || st->bwidth < SWB || st->element_mode != IVAS_CPE_TD || st->extl == -1 )
     469             :         {
     470          74 :             ic_bwe_enc_reset( hStereoICBWE );
     471             : 
     472          74 :             if ( st->core != ACELP_CORE || st->bwidth < SWB || st->input_Fs < 32000 || st->element_mode != IVAS_CPE_TD || st->extl == -1 )
     473             :             {
     474          74 :                 return;
     475             :             }
     476             :         }
     477             : 
     478             :         /* resets done here. Need to move them to a separate function */
     479          34 :         if ( ( hStereoICBWE->prev_refChanIndx_bwe != hStereoICBWE->refChanIndx_bwe ) || ( st->last_extl != st->extl ) || st->flag_ACELP16k != 1 )
     480             :         {
     481          28 :             hStereoICBWE->prevSpecMapping = 0;
     482          28 :             hStereoICBWE->memShbSpecMapping = 0;
     483          28 :             set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
     484             :         }
     485             : 
     486             :         /* voice fac adjustment based on IC intensities */
     487             :         /*temp2 = (float)sqrt(sum2_f(shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k));*/
     488          34 :         temp2 = hStereoICBWE->icbweRefEner;
     489          34 :         temp1 = sqrtf( sum2_f( shb_frame_nonref + L_LOOK_16k - refMemLen, L_FRAME16k ) );
     490             :         /*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/
     491             :         /*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/
     492          34 :         gDes = ( temp2 == 0 ) ? 1.0f : ( temp1 / temp2 );
     493          34 :         hStereoICBWE->gDes_pastFrame = powf( hStereoICBWE->gDes_pastFrame, 0.5f ) * powf( gDes, 1 - 0.5f );
     494             : 
     495          34 :         hStereoICBWE->prevRefEner = temp2;
     496          34 :         hStereoICBWE->prevNonRefEner = temp1;
     497             : 
     498          34 :         if ( ( st->extl == SWB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     499             :         {
     500          22 :             mvr2r( voice_factors, nlMixFac, NB_SUBFR16k );
     501             : 
     502          22 :             if ( gTarget < 0.5f || gTarget > 2.0f )
     503             :             {
     504           0 :                 v_multc( voice_factors, 0.5f, nlMixFac, NB_SUBFR16k );
     505             :             }
     506             : 
     507          22 :             nbSubFr = ( st->flag_ACELP16k == 0 ) ? NB_SUBFR : NB_SUBFR16k;
     508         132 :             for ( i = 0, k = 0; i < nbSubFr; i++ )
     509             :             {
     510         110 :                 if ( st->coder_type == UNVOICED || hStereoICBWE->MSFlag == 1 )
     511             :                 {
     512          10 :                     temp1 = 0;
     513          10 :                     temp2 = 1.0f;
     514             :                 }
     515             :                 else
     516             :                 {
     517         100 :                     temp1 = sqrtf( nlMixFac[i] );
     518         100 :                     temp2 = sqrtf( 1.0f - nlMixFac[i] );
     519             :                 }
     520             : 
     521        7150 :                 for ( j = 0; j < ( L_FRAME16k / nbSubFr ); j++, k++ )
     522             :                 {
     523        7040 :                     excSHB_nonref[k] = temp1 * hStereoICBWE->nlExc16k[k] + temp2 * hStereoICBWE->mixExc16k[k];
     524             :                 }
     525             :             }
     526             : 
     527             :             /* LP synthesis */
     528          22 :             syn_filt( hStereoICBWE->lpSHBRef, LPC_SHB_ORDER, excSHB_nonref, shb_synth_nonref, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref, 1 );
     529             :         }
     530             :         else
     531             :         {
     532          12 :             mvr2r( shb_frame_ref, hStereoICBWE->shbSynthRef, L_FRAME16k );
     533          12 :             mvr2r( shb_frame_ref, shb_synth_nonref, L_FRAME16k );
     534          12 :             set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, 10 );
     535             :         }
     536             : 
     537          34 :         if ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     538             :         {
     539             :             /* IC BWE spectral mapping */
     540          22 :             spIndx = ic_bwe_enc_specMapping( shb_frame_nonref, shb_synth_nonref, &( hStereoICBWE->prevSpecMapping ), &( hStereoICBWE->memShbSpecMapping ), hStereoICBWE->memShbSpecXcorr );
     541             :         }
     542             :         else
     543             :         {
     544          12 :             spIndx = 3;
     545          12 :             hStereoICBWE->prevSpecMapping = 0;
     546             :         }
     547             : 
     548          34 :         push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
     549             : 
     550          34 :         if ( st->flag_ACELP16k == 1 )
     551             :         {
     552          22 :             push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS );
     553             :         }
     554             :         else
     555             :         {
     556          12 :             hStereoICBWE->prevSpecMapping = -0.6f;
     557             :         }
     558             : 
     559             :         /* IC BWE GS mapping */
     560          34 :         gsIndx = ic_bwe_enc_gsMapping( hStereoICBWE->gDes_pastFrame, hStereoICBWE->shbSynthRef, shb_synth_nonref, &( hStereoICBWE->prevgsMapping ), hStereoICBWE->memGsEnerMap, st->element_mode );
     561          34 :         hStereoICBWE->gDes_pastFrame = gDes;
     562          34 :         push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS );
     563             :     }
     564             : 
     565             :     /* IC-BWE updates */
     566       26753 :     hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe;
     567             : 
     568       26753 :     return;
     569             : }
     570             : 
     571             : /*-------------------------------------------------------------------*
     572             :  * stereo_icBWE_init_enc()
     573             :  *
     574             :  * Stereo (inter-channel) BWE mapping - encoder initialization
     575             :  *-------------------------------------------------------------------*/
     576             : 
     577         879 : void stereo_icBWE_init_enc(
     578             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */
     579             : )
     580             : {
     581             :     /* SHB speech resampler memory */
     582         879 :     set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     583             : 
     584             :     /* SHB ref channel */
     585         879 :     set_f( hStereoICBWE->mem_shb_speech_ref, 0, L_LOOK_16k );
     586             : 
     587             :     /* SHB non-ref channel */
     588         879 :     set_f( hStereoICBWE->mem_shb_speech_nonref, 0, L_LOOK_16k );
     589             : 
     590             :     /* unscaled & scaled SHB synthesis memory */
     591         879 :     set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, LPC_SHB_ORDER );
     592             : 
     593             :     /* inter-channel BWE spectral shape adj. */
     594         879 :     hStereoICBWE->prevSpecMapping = 0;
     595         879 :     hStereoICBWE->prevgsMapping = 1.0f;
     596         879 :     set_f( &( hStereoICBWE->memShbSpecMapping ), 0, 1 );
     597         879 :     set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
     598             : 
     599         879 :     hStereoICBWE->prevNonRefEner = 1.0f;
     600         879 :     hStereoICBWE->prevRefEner = 1.0f;
     601             : 
     602         879 :     set_f( hStereoICBWE->memGsEnerMap, 1.0f, 2 );
     603             : 
     604         879 :     set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     605         879 :     set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     606         879 :     set_f( hStereoICBWE->memHPF, 0, 8 );
     607             : 
     608             :     /* BWE ref channel */
     609         879 :     hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
     610         879 :     hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
     611             : 
     612         879 :     set_f( hStereoICBWE->memModifyFs_icbwe[0], 0, 2 * L_FILT32k );
     613         879 :     set_f( hStereoICBWE->memModifyFs_icbwe[1], 0, 2 * L_FILT32k );
     614             : 
     615         879 :     set_f( hStereoICBWE->mem_nrg_L, 0, 2 );
     616         879 :     set_f( hStereoICBWE->mem_nrg_R, 0, 2 );
     617         879 :     set_f( hStereoICBWE->mem_nrg_DMX, 0, 2 );
     618         879 :     hStereoICBWE->gDes_pastFrame = 1.0f;
     619         879 :     hStereoICBWE->icbweRefEner = 0.0f;
     620             : 
     621         879 :     hStereoICBWE->MSFlag = 0;
     622             : 
     623         879 :     return;
     624             : }
     625             : 
     626             : 
     627             : /*-------------------------------------------------------------------*
     628             :  * findRefChanBWE()
     629             :  *
     630             :  *  Inter-channel BWE pre-proc of the non-ref channel
     631             :  *-------------------------------------------------------------------*/
     632             : 
     633          34 : static void findRefChanBWE(
     634             :     const float *input0,
     635             :     const float *input1,
     636             :     int16_t *refChanIndx_bwe,
     637             :     const int16_t input_frame,
     638             :     float *mem0,
     639             :     float *mem1 )
     640             : {
     641             :     float inp0[L_FRAME48k], inp1[L_FRAME48k];
     642             :     float tempF, tempF1;
     643             : 
     644          34 :     mvr2r( input0, inp0, input_frame );
     645          34 :     mvr2r( input1, inp1, input_frame );
     646             : 
     647          34 :     spectral_balancer( inp0, mem0, input_frame, 1 );
     648          34 :     spectral_balancer( inp1, mem1, input_frame, 1 );
     649             : 
     650          34 :     tempF = sum2_f( inp0, input_frame );
     651          34 :     tempF1 = sum2_f( inp1, input_frame );
     652             : 
     653          34 :     if ( tempF1 < 0.64f * tempF )
     654             :     {
     655           1 :         *refChanIndx_bwe = L_CH_INDX;
     656             :     }
     657          33 :     else if ( tempF < 0.64f * tempF1 )
     658             :     {
     659          12 :         *refChanIndx_bwe = R_CH_INDX;
     660             :     }
     661             : 
     662          34 :     return;
     663             : }
     664             : 
     665             : 
     666             : /*-------------------------------------------------------------------*
     667             :  * stereo_icBWE_preproc()
     668             :  *
     669             :  *  Inter-channel BWE pre-proc of the non-ref channel
     670             :  *-------------------------------------------------------------------*/
     671             : 
     672       48232 : void stereo_icBWE_preproc(
     673             :     CPE_ENC_HANDLE hCPE,       /* i/o: CPE encoder structure       */
     674             :     const int16_t input_frame, /* i  : input frame length          */
     675             :     float shb_speech_nonref[]  /* o  : SHB speech non-ref channel  */
     676             : )
     677             : {
     678             :     int16_t i, refChanIndx_bwe;
     679             :     STEREO_TCA_ENC_HANDLE hStereoTCA;
     680             :     STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
     681             :     Encoder_State *st;
     682             :     float temp_inp[L_FRAME48k];
     683             :     float tempSHB[L_FRAME16k];
     684             :     float temp_in[L_FRAME48k];
     685             :     int16_t /*nonRefOffset,*/ nonRefMemLen;
     686             :     float gD;
     687             :     int32_t input_Fs;
     688             : 
     689             :     /* initialization */
     690       48232 :     hStereoTCA = hCPE->hStereoTCA;     /* Stereo TCA encoder handle    */
     691       48232 :     hStereoICBWE = hCPE->hStereoICBWE; /* Stereo IC BWE encoder handle */
     692       48232 :     st = hCPE->hCoreCoder[0];
     693       48232 :     input_Fs = st->input_Fs;
     694             : 
     695             :     /*nonRefOffset = NS2SA(st_ivas->input_Fs, ACELP_LOOK_NS - L_MEM_RECALC_TBE_NS);*/
     696       48232 :     nonRefMemLen = NS2SA( input_Fs, L_MEM_RECALC_TBE_NS );
     697             : 
     698       48232 :     if ( hCPE->element_mode == IVAS_CPE_MDCT || st->core != ACELP_CORE || st->extl == -1 || input_Fs < 32000 )
     699             :     {
     700       13176 :         set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     701       13176 :         set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     702       13176 :         set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     703       13176 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     704       13176 :         set_f( hStereoICBWE->memHPF, 0, 8 );
     705       13176 :         hStereoICBWE->refChanIndx_bwe = hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
     706             : 
     707       13176 :         if ( hCPE->element_mode >= IVAS_CPE_DFT && input_Fs >= 32000 )
     708             :         {
     709       13176 :             set_f( temp_inp, 0, L_FRAME48k );
     710       13176 :             mvr2r( hStereoICBWE->dataChan[0], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     711             : 
     712       13176 :             if ( input_Fs == 48000 )
     713             :             {
     714        5936 :                 mvr2r( temp_inp, temp_in, L_FRAME48k );
     715        5936 :                 set_f( temp_inp, 0, L_FRAME48k );
     716        5936 :                 i = 2 * L_FILT48k + L_FILT_2OVER3;
     717        5936 :                 decimate_2_over_3_allpass( temp_in + ( input_frame - i ), i, temp_inp + ( 2 * ( input_frame - i ) ) / 3, hStereoICBWE->dec_2over3_mem, hStereoICBWE->dec_2over3_mem_lp );
     718             :             }
     719             :             /* flip the spectrum */
     720     4229496 :             for ( i = 0; i < L_FRAME32k; i += 2 )
     721             :             {
     722     4216320 :                 temp_inp[i] *= -1.0f;
     723             :             }
     724       13176 :             mvr2r( temp_inp + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe[0], 2 * L_FILT32k );
     725             : 
     726       13176 :             set_f( temp_inp, 0, L_FRAME48k );
     727       13176 :             mvr2r( hStereoICBWE->dataChan[1], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     728             : 
     729       13176 :             if ( input_Fs == 48000 )
     730             :             {
     731        5936 :                 mvr2r( temp_inp, temp_in, L_FRAME48k );
     732        5936 :                 set_f( temp_inp, 0, L_FRAME48k );
     733        5936 :                 i = 2 * L_FILT48k + L_FILT_2OVER3;
     734             :                 /* IVAS-219: the same filter memories are used for both channels; the continuity is thus lost; shouldn't the memories be separated? */
     735        5936 :                 decimate_2_over_3_allpass( temp_in + ( input_frame - i ), i, temp_inp + ( 2 * ( input_frame - i ) ) / 3, hStereoICBWE->dec_2over3_mem, hStereoICBWE->dec_2over3_mem_lp );
     736             :             }
     737             :             /* flip the spectrum */
     738     5179256 :             for ( i = 0; i < input_frame; i += 2 )
     739             :             {
     740     5166080 :                 temp_inp[i] *= -1.0f;
     741             :             }
     742       13176 :             mvr2r( temp_inp + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe[1], 2 * L_FILT32k );
     743             :         }
     744             : 
     745       13176 :         return;
     746             :     }
     747             : 
     748       35056 :     if ( hCPE->element_mode != IVAS_CPE_TD )
     749             :     {
     750             :         /* initial estimate of refChanIndx_bwe */
     751       35022 :         gD = hStereoTCA->targetGain;
     752             : 
     753       35022 :         refChanIndx_bwe = hStereoTCA->refChanIndx;
     754       35022 :         if ( ( gD > 1.0f && refChanIndx_bwe == R_CH_INDX ) || ( gD < 1.0f && refChanIndx_bwe == L_CH_INDX ) )
     755             :         {
     756       21523 :             refChanIndx_bwe = !( hStereoTCA->refChanIndx );
     757             :         }
     758       35022 :         hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
     759             : 
     760       35022 :         set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     761       35022 :         set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     762       35022 :         set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     763       35022 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     764       35022 :         set_f( hStereoICBWE->memHPF, 0, 8 );
     765             : 
     766       35022 :         return;
     767             :     }
     768             : 
     769          34 :     gD = hStereoTCA->targetGain;
     770             : 
     771          34 :     refChanIndx_bwe = hStereoTCA->refChanIndx;
     772          34 :     if ( ( gD > 1.0f && refChanIndx_bwe == R_CH_INDX ) || ( gD < 1.0f && refChanIndx_bwe == L_CH_INDX ) )
     773             :     {
     774           0 :         refChanIndx_bwe = !( hStereoTCA->refChanIndx );
     775             :     }
     776             : 
     777          34 :     findRefChanBWE( hStereoICBWE->dataChan[0], hStereoICBWE->dataChan[1], &refChanIndx_bwe, input_frame, &hStereoICBWE->memHPF[0], &hStereoICBWE->memHPF[4] );
     778             : 
     779          34 :     hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
     780             : 
     781          34 :     if ( refChanIndx_bwe == R_CH_INDX )
     782             :     {
     783          13 :         mvr2r( hStereoICBWE->icbwe_inp_mem[0], temp_inp, nonRefMemLen );
     784          13 :         mvr2r( hStereoICBWE->dataChan[0], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     785             :     }
     786             :     else
     787             :     {
     788          21 :         mvr2r( hStereoICBWE->icbwe_inp_mem[1], temp_inp, nonRefMemLen );
     789          21 :         mvr2r( hStereoICBWE->dataChan[1], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     790             :     }
     791             : 
     792          34 :     if ( input_Fs == 48000 )
     793             :     {
     794             :         /*printf("\n Non-ref target HB generation for 48 kHz sample rate needs alignment verification \n");*/
     795           4 :         mvr2r( temp_inp, temp_in, L_FRAME48k );
     796           4 :         set_f( temp_inp, 0, L_FRAME48k );
     797           4 :         decimate_2_over_3_allpass( temp_in, L_FRAME48k, temp_inp, hStereoICBWE->dec_2over3_mem, hStereoICBWE->dec_2over3_mem_lp );
     798             :     }
     799             : 
     800             :     /* flip the spectrum */
     801       11554 :     for ( i = 0; i < input_frame; i += 2 )
     802             :     {
     803       11520 :         temp_inp[i] *= -1.0f;
     804             :     }
     805             : 
     806          34 :     if ( hCPE->element_mode >= IVAS_CPE_DFT && input_Fs >= 32000 && ( st->last_core != ACELP_CORE || st->last_extl == -1 ) )
     807             :     {
     808           0 :         mvr2r( hStereoICBWE->memModifyFs_icbwe[!refChanIndx_bwe], hStereoICBWE->mem_decim_shb_ch0, 2 * L_FILT32k );
     809             :     }
     810             : 
     811             :     /* IVAS-219: Re-wire the shb nonref estimation through a lite CLDFB */
     812          34 :     modify_Fs( temp_inp, L_FRAME32k, 32000, tempSHB, 16000, hStereoICBWE->mem_decim_shb_ch0, 0 );
     813             : 
     814          34 :     mvr2r( tempSHB, shb_speech_nonref, L_FRAME16k );
     815             : 
     816          34 :     return;
     817             : }

Generated by: LCOV version 1.14