LCOV - code coverage report
Current view: top level - lib_enc - ivas_stereo_icbwe_enc.c (source / functions) Hit Total Coverage
Test: Coverage on main -- merged total coverage @ 0c62f5312a76f89f3e6d6ab9a8d50516c9ab4059 Lines: 324 327 99.1 %
Date: 2025-12-17 10:49:08 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      413753 : 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      413753 :     set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, LPC_SHB_ORDER );
      59             : 
      60             :     /* inter-channel BWE spectral shape adj. */
      61      413753 :     hStereoICBWE->prevSpecMapping = 0;
      62      413753 :     hStereoICBWE->prevgsMapping = 1.0f;
      63      413753 :     set_f( &( hStereoICBWE->memShbSpecMapping ), 0, 1 );
      64      413753 :     set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
      65      413753 :     set_f( hStereoICBWE->memGsEnerMap, 1.0f, 2 );
      66      413753 :     set_f( hStereoICBWE->mem_nrg_L, 0, 2 );
      67      413753 :     set_f( hStereoICBWE->mem_nrg_R, 0, 2 );
      68      413753 :     set_f( hStereoICBWE->mem_nrg_DMX, 0, 2 );
      69      413753 :     hStereoICBWE->gDes_pastFrame = 1.0f;
      70      413753 :     hStereoICBWE->icbweRefEner = 0.0f;
      71             : 
      72      413753 :     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         673 : 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         673 :     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         673 :     alpha = 0.5f;
      97             :     /* Calculate rxx(1)/rxx(0) of the non ref target */
      98         673 :     temp0 = dotp( shb_frame_target, shb_frame_target, L_FRAME16k - 1 );
      99         673 :     temp1 = dotp( shb_frame_target, shb_frame_target + 1, L_FRAME16k - 1 );
     100             : 
     101             :     /* Smoothing */
     102         673 :     temp0 = alpha * memShbSpecXcorr[0] + ( 1 - alpha ) * temp0;
     103         673 :     temp1 = alpha * memShbSpecXcorr[1] + ( 1 - alpha ) * temp1;
     104         673 :     memShbSpecXcorr[0] = temp0;
     105         673 :     memShbSpecXcorr[1] = temp1;
     106             : 
     107         673 :     T_nonref_target = ( temp0 != 0 ) ? ( temp1 / temp0 ) : ( 0 );
     108             : 
     109             :     /* Calculate rxx(1)/rxx(0) of the non ref synth */
     110         673 :     temp0 = dotp( shb_synth_nonref, shb_synth_nonref, L_FRAME16k - 3 );
     111         673 :     temp1 = dotp( shb_synth_nonref, shb_synth_nonref + 1, L_FRAME16k - 3 );
     112         673 :     temp2 = dotp( shb_synth_nonref, shb_synth_nonref + 2, L_FRAME16k - 3 );
     113         673 :     temp3 = dotp( shb_synth_nonref, shb_synth_nonref + 3, L_FRAME16k - 3 );
     114             : 
     115             :     /* Smoothing */
     116         673 :     temp0 = alpha * memShbSpecXcorr[2] + ( 1 - alpha ) * temp0;
     117         673 :     temp1 = alpha * memShbSpecXcorr[3] + ( 1 - alpha ) * temp1;
     118         673 :     temp2 = alpha * memShbSpecXcorr[4] + ( 1 - alpha ) * temp2;
     119         673 :     temp3 = alpha * memShbSpecXcorr[5] + ( 1 - alpha ) * temp3;
     120             : 
     121         673 :     memShbSpecXcorr[2] = temp0;
     122         673 :     memShbSpecXcorr[3] = temp1;
     123         673 :     memShbSpecXcorr[4] = temp2;
     124         673 :     memShbSpecXcorr[5] = temp3;
     125             : 
     126         673 :     if ( temp0 != 0 )
     127             :     {
     128         673 :         Txx1 = temp1 / temp0;
     129         673 :         Txx2 = temp2 / temp0;
     130         673 :         Txx3 = temp3 / temp0;
     131             :     }
     132             : 
     133         673 :     T_desired = T_nonref_target;
     134             : 
     135         673 :     a = 2 * Txx2 * T_desired - Txx3 - Txx1;
     136         673 :     b = ( 2 * T_desired * Txx1 - Txx2 - 1.0f );
     137         673 :     c = ( T_desired - Txx1 );
     138             : 
     139         673 :     u = *specMapping;
     140         673 :     temp = ( b * b - 4 * a * c );
     141         673 :     if ( temp >= 0 && a != 0 )
     142             :     {
     143         613 :         temp = sqrtf( temp );
     144         613 :         u1 = ( -b + temp ) / ( 2 * a );
     145         613 :         u2 = ( -b - temp ) / ( 2 * a );
     146             : 
     147         613 :         if ( fabsf( u1 ) < 1.0f && fabsf( u2 ) < 1.0f )
     148             :         {
     149          23 :             u = min( u1, u2 );
     150             :         }
     151         590 :         else if ( fabsf( u1 ) < 1.0f )
     152             :         {
     153           0 :             u = u1;
     154             :         }
     155         590 :         else if ( fabsf( u2 ) < 1.0f )
     156             :         {
     157         584 :             u = u2;
     158             :         }
     159             :     }
     160         673 :     u = max( min( u, 0 ), -0.6f );
     161             : 
     162             :     /* Quantize spec. mapping **/
     163         673 :     idx = (int16_t) usquant( u, specMapping, -0.6f, 0.2f, 1 << STEREO_ICBWE_SPBITS );
     164             : 
     165             :     /* IC-BWE spec mapping */
     166         673 :     deemph( shb_synth_nonref, *specMapping, L_FRAME16k, memShbSpecMapping );
     167             : 
     168         673 :     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      375869 : 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      375869 :     int16_t idx = 0;
     189             :     float temp1, temp2;
     190             :     float alpha;
     191             :     float prev_gsMapping;
     192             : 
     193      375869 :     alpha = 0;
     194      375869 :     prev_gsMapping = *gsMapping;
     195             : 
     196             :     /* rel gain of synth signals */
     197   120653949 :     for ( i = 0, temp1 = 0, temp2 = 0; i < L_FRAME16k; i++ )
     198             :     {
     199   120278080 :         temp1 += fabsf( shbSynth[i] );
     200   120278080 :         temp2 += fabsf( synthSHB_nonref[i] );
     201             :     }
     202      375869 :     temp1 = alpha * memEner[0] + ( 1 - alpha ) * temp1;
     203      375869 :     temp2 = alpha * memEner[1] + ( 1 - alpha ) * temp2;
     204             : 
     205      375869 :     memEner[0] = temp1;
     206      375869 :     memEner[1] = temp2;
     207             : 
     208      375869 :     *gsMapping = ( temp2 == 0 ) ? ( *gsMapping ) : ( ( relG_targ * temp1 ) / temp2 );
     209      375869 :     temp2 = ( 0.0f ) * log10f( prev_gsMapping ) + ( 1.0f ) * log10f( *gsMapping ); /* no impact from prev_gsMapping */
     210             : 
     211             :     /* quantize the IC-BWE GS mapping*/
     212      375869 :     if ( element_mode == IVAS_CPE_TD )
     213             :     {
     214        1613 :         idx = squant( temp2, gsMapping, icbwe_gsMapping_tbl, 1 << STEREO_ICBWE_GSBITS );
     215             :     }
     216             :     else
     217             :     {
     218      374256 :         idx = squant( temp2, gsMapping, icbwe_gsMappingDFT_tbl, 1 << STEREO_ICBWE_GSBITS_DFT );
     219             :     }
     220             : 
     221      375869 :     *gsMapping = powf( 10, *gsMapping );
     222             : 
     223      375869 :     return idx;
     224             : }
     225             : 
     226             : 
     227             : /*----------------------------------------------------------------------*
     228             :  * icbwe_dft_stereo_param()
     229             :  *
     230             :  * Estimate ICBWE parameters in DFT stereo
     231             :  *-----------------------------------------------------------------------*/
     232             : 
     233      374256 : 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      374256 :     const float slope_table[4] = { -2.17141801027151f, -1.29118591145892f, -0.588623666024448f, 0 };
     245      374256 :     const float spec_table[4] = { -0.6f, -0.4f, -0.2f, 0 };
     246             : 
     247      374256 :     BSTR_ENC_HANDLE hBstr = st->hBstr;
     248             : 
     249      374256 :     normFac = 2.5f; /* 1000 * (10/((14400+10400)/2 - (6400+10400)/2)) */
     250             : 
     251      374256 :     nrg_L = hStereoDft->nrg_L;
     252      374256 :     nrg_R = hStereoDft->nrg_R;
     253      374256 :     nrg_DMX = hStereoDft->nrg_DMX;
     254             : 
     255      374256 :     alpha = 0.0f;
     256      374256 :     hStereoICBWE->mem_nrg_L[0] = alpha * hStereoICBWE->mem_nrg_L[0] + ( 1 - alpha ) * nrg_L[0];
     257      374256 :     hStereoICBWE->mem_nrg_R[0] = alpha * hStereoICBWE->mem_nrg_R[0] + ( 1 - alpha ) * nrg_R[0];
     258      374256 :     hStereoICBWE->mem_nrg_DMX[0] = alpha * hStereoICBWE->mem_nrg_DMX[0] + ( 1 - alpha ) * nrg_DMX[0];
     259      374256 :     hStereoICBWE->mem_nrg_L[1] = alpha * hStereoICBWE->mem_nrg_L[1] + ( 1 - alpha ) * nrg_L[1];
     260      374256 :     hStereoICBWE->mem_nrg_R[1] = alpha * hStereoICBWE->mem_nrg_R[1] + ( 1 - alpha ) * nrg_R[1];
     261      374256 :     hStereoICBWE->mem_nrg_DMX[1] = alpha * hStereoICBWE->mem_nrg_DMX[1] + ( 1 - alpha ) * nrg_DMX[1];
     262             : 
     263      374256 :     sum_nrg_L = sum_f( hStereoICBWE->mem_nrg_L, 2 );
     264      374256 :     sum_nrg_R = sum_f( hStereoICBWE->mem_nrg_R, 2 );
     265      374256 :     sum_nrg_DMX = sum_f( hStereoICBWE->mem_nrg_DMX, 2 );
     266             : 
     267             :     /* refChanIndex_bwe refinement */
     268      374256 :     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       78365 :         hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
     271             :     }
     272      295891 :     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       82965 :         hStereoICBWE->refChanIndx_bwe = R_CH_INDX;
     275             :     }
     276             : 
     277             :     /* Initialization of spIndx */
     278      374256 :     slopeILD = 0;
     279      374256 :     spIndx = squant( slopeILD, &slopeILD, slope_table, 1 << STEREO_ICBWE_SPBITS_DFT );
     280             : 
     281      374256 :     if ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     282             :     {
     283             :         /* Spec Mapping Estimate */
     284      150562 :         slopeILD = normFac * ( log10f( ( hStereoICBWE->mem_nrg_L[1] * hStereoICBWE->mem_nrg_R[0] ) / ( hStereoICBWE->mem_nrg_R[1] * hStereoICBWE->mem_nrg_L[0] ) ) );
     285      150562 :         slopeILD = ( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) ? ( -slopeILD ) : ( slopeILD );
     286      150562 :         spIndx = squant( slopeILD, &slopeILD, slope_table, 1 << STEREO_ICBWE_SPBITS_DFT );
     287      150562 :         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      150562 :         hStereoICBWE->prevSpecMapping = spec_table[spIndx];
     293             : 
     294             :         /* ic bwe spec mapping application */
     295      150562 :         deemph( shb_synth_nonref, hStereoICBWE->prevSpecMapping, L_FRAME16k, &hStereoICBWE->memShbSpecMapping );
     296             :     }
     297             :     else
     298             :     {
     299      223694 :         hStereoICBWE->memShbSpecMapping = 0;
     300      223694 :         hStereoICBWE->prevSpecMapping = 0;
     301             :     }
     302             : 
     303             :     /* gsMapping estimate */
     304             : 
     305      374256 :     gDes = ( hStereoICBWE->refChanIndx_bwe == L_CH_INDX ) ? ( sum_nrg_R / sum_nrg_DMX ) : ( sum_nrg_L / sum_nrg_DMX );
     306      374256 :     gDes = sqrtf( gDes );
     307             : 
     308      374256 :     alpha = 0.5f;
     309             :     /* Geometric Mean */
     310      374256 :     hStereoICBWE->gDes_pastFrame = powf( hStereoICBWE->gDes_pastFrame, alpha ) * powf( gDes, 1 - alpha );
     311             : 
     312      374256 :     gsIndx = ic_bwe_enc_gsMapping( hStereoICBWE->gDes_pastFrame, hStereoICBWE->shbSynthRef, shb_synth_nonref, &( hStereoICBWE->prevgsMapping ), hStereoICBWE->memGsEnerMap, st->element_mode );
     313      374256 :     hStereoICBWE->gDes_pastFrame = gDes;
     314             : 
     315      374256 :     push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
     316      374256 :     if ( st->flag_ACELP16k == 1 )
     317             :     {
     318      166387 :         push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS_DFT );
     319             :     }
     320             : 
     321             :     /* IC BWE GS mapping */
     322      374256 :     push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS_DFT );
     323             : 
     324      374256 :     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      764736 : 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      764736 :     hStereoDft = hCPE->hStereoDft;
     359      764736 :     hStereoICBWE = hCPE->hStereoICBWE;
     360      764736 :     st = hCPE->hCoreCoder[0];
     361      764736 :     hBstr = st->hBstr;
     362             : 
     363      764736 :     gTarget = hCPE->hStereoTCA->targetGain; /* i  : gain norm for target (or R) channel  */
     364             : 
     365      764736 :     nonRefMemLen = L_MEM_RECALC_TBE_16K + L_FILT16k;
     366             : 
     367      764736 :     if ( st->element_mode == IVAS_CPE_TD )
     368             :     {
     369        2235 :         refMemLen = L_MEM_RECALC_TBE_16K + 20;
     370             :     }
     371      762501 :     else if ( st->element_mode == IVAS_CPE_DFT && st->core_brate > SID_2k40 )
     372             :     {
     373      728720 :         refMemLen = 20;
     374             :     }
     375             :     else
     376             :     {
     377       33781 :         ic_bwe_enc_reset( hStereoICBWE );
     378             : 
     379       33781 :         return;
     380             :     }
     381             : 
     382      730955 :     if ( st->element_mode == IVAS_CPE_DFT )
     383             :     {
     384             :         /* memory resets */
     385      728720 :         set_f( hStereoICBWE->mem_shb_speech_nonref, 0, L_LOOK_16k );
     386      728720 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     387             : 
     388             :         /* core switching reset */
     389      728720 :         if ( st->last_core != ACELP_CORE || st->core != ACELP_CORE || st->bwidth < SWB || st->extl == -1 )
     390             :         {
     391      379290 :             ic_bwe_enc_reset( hStereoICBWE );
     392      379290 :             if ( st->core != ACELP_CORE || st->bwidth < SWB || st->input_Fs < 32000 || st->extl == -1 )
     393             :             {
     394      354464 :                 return;
     395             :             }
     396             :         }
     397             : 
     398      374256 :         set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
     399             : 
     400      374256 :         hStereoICBWE->prevRefEner = 0;
     401      374256 :         hStereoICBWE->prevNonRefEner = 0;
     402             : 
     403             :         /* SHB frame buffer offsets for TBE processing << re-adjust check >>*/
     404      374256 :         set_f( shb_frame_ref, 0, L_LOOK_16k + L_FRAME16k );
     405      374256 :         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      374256 :         mvr2r( shb_speech_ref, shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k );
     409      374256 :         mvr2r( shb_frame_ref + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref, L_LOOK_16k );
     410             : 
     411      374256 :         if ( ( st->extl == SWB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     412             :         {
     413      150562 :             mvr2r( voice_factors, nlMixFac, NB_SUBFR16k );
     414             :             /*if( gDes < 0.5f || gDes > 2.0f )*/
     415      150562 :             if ( gTarget < 0.5f || gTarget > 2.0f )
     416             :             {
     417       33113 :                 v_multc( voice_factors, 0.5f, nlMixFac, NB_SUBFR16k );
     418             :             }
     419             : 
     420      150562 :             nbSubFr = ( st->flag_ACELP16k == 0 ) ? NB_SUBFR : NB_SUBFR16k;
     421      903372 :             for ( i = 0, k = 0; i < nbSubFr; i++ )
     422             :             {
     423      752810 :                 if ( st->coder_type == UNVOICED || hStereoICBWE->MSFlag == 1 )
     424             :                 {
     425      192595 :                     temp1 = 0;
     426      192595 :                     temp2 = 1.0f;
     427             :                 }
     428             :                 else
     429             :                 {
     430      560215 :                     temp1 = sqrtf( nlMixFac[i] );
     431      560215 :                     temp2 = sqrtf( 1.0f - nlMixFac[i] );
     432             :                 }
     433             : 
     434    48932650 :                 for ( j = 0; j < ( L_FRAME16k / nbSubFr ); j++, k++ )
     435             :                 {
     436    48179840 :                     excSHB_nonref[k] = temp1 * hStereoICBWE->nlExc16k[k] + temp2 * hStereoICBWE->mixExc16k[k];
     437             :                 }
     438             :             }
     439             : 
     440             :             /* LP synthesis */
     441      150562 :             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      223694 :             mvr2r( shb_frame_ref, hStereoICBWE->shbSynthRef, L_FRAME16k );
     446      223694 :             mvr2r( shb_frame_ref, shb_synth_nonref, L_FRAME16k );
     447      223694 :             set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, 10 );
     448             :         }
     449             : 
     450      374256 :         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        2235 :         set_f( shb_frame_ref, 0, L_LOOK_16k + L_FRAME16k );
     456        2235 :         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        2235 :         mvr2r( shb_speech_ref, shb_frame_ref + L_LOOK_16k - refMemLen, L_FRAME16k );
     460        2235 :         mvr2r( shb_frame_ref + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref, L_LOOK_16k );
     461             : 
     462        2235 :         set_f( shb_frame_nonref, 0, L_LOOK_16k + L_FRAME16k );
     463        2235 :         mvr2r( hStereoICBWE->mem_shb_speech_nonref, shb_frame_nonref, L_LOOK_16k );
     464        2235 :         mvr2r( shb_speech_nonref, shb_frame_nonref + L_LOOK_16k - nonRefMemLen, L_FRAME16k );
     465        2235 :         mvr2r( shb_frame_nonref + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref, L_LOOK_16k );
     466             : 
     467             :         /* core switching reset */
     468        2235 :         if ( st->last_core != ACELP_CORE || st->core != ACELP_CORE || st->bwidth < SWB || st->element_mode != IVAS_CPE_TD || st->extl == -1 )
     469             :         {
     470         682 :             ic_bwe_enc_reset( hStereoICBWE );
     471             : 
     472         682 :             if ( st->core != ACELP_CORE || st->bwidth < SWB || st->input_Fs < 32000 || st->element_mode != IVAS_CPE_TD || st->extl == -1 )
     473             :             {
     474         622 :                 return;
     475             :             }
     476             :         }
     477             : 
     478             :         /* resets done here. Need to move them to a separate function */
     479        1613 :         if ( ( hStereoICBWE->prev_refChanIndx_bwe != hStereoICBWE->refChanIndx_bwe ) || ( st->last_extl != st->extl ) || st->flag_ACELP16k != 1 )
     480             :         {
     481         371 :             hStereoICBWE->prevSpecMapping = 0;
     482         371 :             hStereoICBWE->memShbSpecMapping = 0;
     483         371 :             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        1613 :         temp2 = hStereoICBWE->icbweRefEner;
     489        1613 :         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        1613 :         gDes = ( temp2 == 0 ) ? 1.0f : ( temp1 / temp2 );
     493        1613 :         hStereoICBWE->gDes_pastFrame = powf( hStereoICBWE->gDes_pastFrame, 0.5f ) * powf( gDes, 1 - 0.5f );
     494             : 
     495        1613 :         hStereoICBWE->prevRefEner = temp2;
     496        1613 :         hStereoICBWE->prevNonRefEner = temp1;
     497             : 
     498        1613 :         if ( ( st->extl == SWB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     499             :         {
     500         673 :             mvr2r( voice_factors, nlMixFac, NB_SUBFR16k );
     501             : 
     502         673 :             if ( gTarget < 0.5f || gTarget > 2.0f )
     503             :             {
     504           5 :                 v_multc( voice_factors, 0.5f, nlMixFac, NB_SUBFR16k );
     505             :             }
     506             : 
     507         673 :             nbSubFr = ( st->flag_ACELP16k == 0 ) ? NB_SUBFR : NB_SUBFR16k;
     508        4038 :             for ( i = 0, k = 0; i < nbSubFr; i++ )
     509             :             {
     510        3365 :                 if ( st->coder_type == UNVOICED || hStereoICBWE->MSFlag == 1 )
     511             :                 {
     512        1730 :                     temp1 = 0;
     513        1730 :                     temp2 = 1.0f;
     514             :                 }
     515             :                 else
     516             :                 {
     517        1635 :                     temp1 = sqrtf( nlMixFac[i] );
     518        1635 :                     temp2 = sqrtf( 1.0f - nlMixFac[i] );
     519             :                 }
     520             : 
     521      218725 :                 for ( j = 0; j < ( L_FRAME16k / nbSubFr ); j++, k++ )
     522             :                 {
     523      215360 :                     excSHB_nonref[k] = temp1 * hStereoICBWE->nlExc16k[k] + temp2 * hStereoICBWE->mixExc16k[k];
     524             :                 }
     525             :             }
     526             : 
     527             :             /* LP synthesis */
     528         673 :             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         940 :             mvr2r( shb_frame_ref, hStereoICBWE->shbSynthRef, L_FRAME16k );
     533         940 :             mvr2r( shb_frame_ref, shb_synth_nonref, L_FRAME16k );
     534         940 :             set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, 10 );
     535             :         }
     536             : 
     537        1613 :         if ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->flag_ACELP16k == 1 )
     538             :         {
     539             :             /* IC BWE spectral mapping */
     540         673 :             spIndx = ic_bwe_enc_specMapping( shb_frame_nonref, shb_synth_nonref, &( hStereoICBWE->prevSpecMapping ), &( hStereoICBWE->memShbSpecMapping ), hStereoICBWE->memShbSpecXcorr );
     541             :         }
     542             :         else
     543             :         {
     544         940 :             spIndx = 3;
     545         940 :             hStereoICBWE->prevSpecMapping = 0;
     546             :         }
     547             : 
     548        1613 :         push_indice( hBstr, IND_STEREO_ICBWE_REF, hStereoICBWE->refChanIndx_bwe, STEREO_ICBWE_REFBITS );
     549             : 
     550        1613 :         if ( st->flag_ACELP16k == 1 )
     551             :         {
     552        1577 :             push_indice( hBstr, IND_STEREO_ICBWE_SP, spIndx, STEREO_ICBWE_SPBITS );
     553             :         }
     554             :         else
     555             :         {
     556          36 :             hStereoICBWE->prevSpecMapping = -0.6f;
     557             :         }
     558             : 
     559             :         /* IC BWE GS mapping */
     560        1613 :         gsIndx = ic_bwe_enc_gsMapping( hStereoICBWE->gDes_pastFrame, hStereoICBWE->shbSynthRef, shb_synth_nonref, &( hStereoICBWE->prevgsMapping ), hStereoICBWE->memGsEnerMap, st->element_mode );
     561        1613 :         hStereoICBWE->gDes_pastFrame = gDes;
     562        1613 :         push_indice( hBstr, IND_STEREO_ICBWE_GS, gsIndx, STEREO_ICBWE_GSBITS );
     563             :     }
     564             : 
     565             :     /* IC-BWE updates */
     566      375869 :     hStereoICBWE->prev_refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe;
     567             : 
     568      375869 :     return;
     569             : }
     570             : 
     571             : /*-------------------------------------------------------------------*
     572             :  * stereo_icBWE_init_enc()
     573             :  *
     574             :  * Stereo (inter-channel) BWE mapping - encoder initialization
     575             :  *-------------------------------------------------------------------*/
     576             : 
     577       22940 : 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       22940 :     set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     583             : 
     584             :     /* SHB ref channel */
     585       22940 :     set_f( hStereoICBWE->mem_shb_speech_ref, 0, L_LOOK_16k );
     586             : 
     587             :     /* SHB non-ref channel */
     588       22940 :     set_f( hStereoICBWE->mem_shb_speech_nonref, 0, L_LOOK_16k );
     589             : 
     590             :     /* unscaled & scaled SHB synthesis memory */
     591       22940 :     set_f( hStereoICBWE->mem_lpc_shbsynth_nonref, 0, LPC_SHB_ORDER );
     592             : 
     593             :     /* inter-channel BWE spectral shape adj. */
     594       22940 :     hStereoICBWE->prevSpecMapping = 0;
     595       22940 :     hStereoICBWE->prevgsMapping = 1.0f;
     596       22940 :     set_f( &( hStereoICBWE->memShbSpecMapping ), 0, 1 );
     597       22940 :     set_f( hStereoICBWE->memShbSpecXcorr, 0, 6 );
     598             : 
     599       22940 :     hStereoICBWE->prevNonRefEner = 1.0f;
     600       22940 :     hStereoICBWE->prevRefEner = 1.0f;
     601             : 
     602       22940 :     set_f( hStereoICBWE->memGsEnerMap, 1.0f, 2 );
     603             : 
     604       22940 :     set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     605       22940 :     set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     606       22940 :     set_f( hStereoICBWE->memHPF, 0, 8 );
     607             : 
     608             :     /* BWE ref channel */
     609       22940 :     hStereoICBWE->refChanIndx_bwe = L_CH_INDX;
     610       22940 :     hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
     611             : 
     612       22940 :     set_f( hStereoICBWE->memModifyFs_icbwe[0], 0, 2 * L_FILT32k );
     613       22940 :     set_f( hStereoICBWE->memModifyFs_icbwe[1], 0, 2 * L_FILT32k );
     614             : 
     615       22940 :     set_f( hStereoICBWE->mem_nrg_L, 0, 2 );
     616       22940 :     set_f( hStereoICBWE->mem_nrg_R, 0, 2 );
     617       22940 :     set_f( hStereoICBWE->mem_nrg_DMX, 0, 2 );
     618       22940 :     hStereoICBWE->gDes_pastFrame = 1.0f;
     619       22940 :     hStereoICBWE->icbweRefEner = 0.0f;
     620             : 
     621       22940 :     hStereoICBWE->MSFlag = 0;
     622             : 
     623       22940 :     return;
     624             : }
     625             : 
     626             : 
     627             : /*-------------------------------------------------------------------*
     628             :  * findRefChanBWE()
     629             :  *
     630             :  *  Inter-channel BWE pre-proc of the non-ref channel
     631             :  *-------------------------------------------------------------------*/
     632             : 
     633        1613 : 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        1613 :     mvr2r( input0, inp0, input_frame );
     645        1613 :     mvr2r( input1, inp1, input_frame );
     646             : 
     647        1613 :     spectral_balancer( inp0, mem0, input_frame, 1 );
     648        1613 :     spectral_balancer( inp1, mem1, input_frame, 1 );
     649             : 
     650        1613 :     tempF = sum2_f( inp0, input_frame );
     651        1613 :     tempF1 = sum2_f( inp1, input_frame );
     652             : 
     653        1613 :     if ( tempF1 < 0.64f * tempF )
     654             :     {
     655         139 :         *refChanIndx_bwe = L_CH_INDX;
     656             :     }
     657        1474 :     else if ( tempF < 0.64f * tempF1 )
     658             :     {
     659         230 :         *refChanIndx_bwe = R_CH_INDX;
     660             :     }
     661             : 
     662        1613 :     return;
     663             : }
     664             : 
     665             : 
     666             : /*-------------------------------------------------------------------*
     667             :  * stereo_icBWE_preproc()
     668             :  *
     669             :  *  Inter-channel BWE pre-proc of the non-ref channel
     670             :  *-------------------------------------------------------------------*/
     671             : 
     672      764736 : 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      764736 :     hStereoTCA = hCPE->hStereoTCA;     /* Stereo TCA encoder handle    */
     691      764736 :     hStereoICBWE = hCPE->hStereoICBWE; /* Stereo IC BWE encoder handle */
     692      764736 :     st = hCPE->hCoreCoder[0];
     693      764736 :     input_Fs = st->input_Fs;
     694             : 
     695             :     /*nonRefOffset = NS2SA(st_ivas->input_Fs, ACELP_LOOK_NS - L_MEM_RECALC_TBE_NS);*/
     696      764736 :     nonRefMemLen = NS2SA( input_Fs, L_MEM_RECALC_TBE_NS );
     697             : 
     698      764736 :     if ( hCPE->element_mode == IVAS_CPE_MDCT || st->core != ACELP_CORE || st->extl == -1 || input_Fs < 32000 )
     699             :     {
     700      348299 :         set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     701      348299 :         set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     702      348299 :         set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     703      348299 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     704      348299 :         set_f( hStereoICBWE->memHPF, 0, 8 );
     705      348299 :         hStereoICBWE->refChanIndx_bwe = hStereoICBWE->prev_refChanIndx_bwe = L_CH_INDX;
     706             : 
     707      348299 :         if ( hCPE->element_mode >= IVAS_CPE_DFT && input_Fs >= 32000 )
     708             :         {
     709      348299 :             set_f( temp_inp, 0, L_FRAME48k );
     710      348299 :             mvr2r( hStereoICBWE->dataChan[0], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     711             : 
     712      348299 :             if ( input_Fs == 48000 )
     713             :             {
     714      216671 :                 mvr2r( temp_inp, temp_in, L_FRAME48k );
     715      216671 :                 set_f( temp_inp, 0, L_FRAME48k );
     716      216671 :                 i = 2 * L_FILT48k + L_FILT_2OVER3;
     717      216671 :                 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   111803979 :             for ( i = 0; i < L_FRAME32k; i += 2 )
     721             :             {
     722   111455680 :                 temp_inp[i] *= -1.0f;
     723             :             }
     724      348299 :             mvr2r( temp_inp + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe[0], 2 * L_FILT32k );
     725             : 
     726      348299 :             set_f( temp_inp, 0, L_FRAME48k );
     727      348299 :             mvr2r( hStereoICBWE->dataChan[1], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     728             : 
     729      348299 :             if ( input_Fs == 48000 )
     730             :             {
     731      216671 :                 mvr2r( temp_inp, temp_in, L_FRAME48k );
     732      216671 :                 set_f( temp_inp, 0, L_FRAME48k );
     733      216671 :                 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      216671 :                 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   146471339 :             for ( i = 0; i < input_frame; i += 2 )
     739             :             {
     740   146123040 :                 temp_inp[i] *= -1.0f;
     741             :             }
     742      348299 :             mvr2r( temp_inp + L_FRAME32k - 2 * L_FILT32k, hStereoICBWE->memModifyFs_icbwe[1], 2 * L_FILT32k );
     743             :         }
     744             : 
     745      348299 :         return;
     746             :     }
     747             : 
     748      416437 :     if ( hCPE->element_mode != IVAS_CPE_TD )
     749             :     {
     750             :         /* initial estimate of refChanIndx_bwe */
     751      414824 :         gD = hStereoTCA->targetGain;
     752             : 
     753      414824 :         refChanIndx_bwe = hStereoTCA->refChanIndx;
     754      414824 :         if ( ( gD > 1.0f && refChanIndx_bwe == R_CH_INDX ) || ( gD < 1.0f && refChanIndx_bwe == L_CH_INDX ) )
     755             :         {
     756      182998 :             refChanIndx_bwe = !( hStereoTCA->refChanIndx );
     757             :         }
     758      414824 :         hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
     759             : 
     760      414824 :         set_f( hStereoICBWE->dec_2over3_mem, 0, L_FILT_2OVER3 );
     761      414824 :         set_f( hStereoICBWE->dec_2over3_mem_lp, 0, L_FILT_2OVER3_LP );
     762      414824 :         set_f( hStereoICBWE->mem_decim_shb_ch0, 0, ( 2 * L_FILT_MAX ) );
     763      414824 :         set_f( shb_speech_nonref, 0, L_FRAME16k );
     764      414824 :         set_f( hStereoICBWE->memHPF, 0, 8 );
     765             : 
     766      414824 :         return;
     767             :     }
     768             : 
     769        1613 :     gD = hStereoTCA->targetGain;
     770             : 
     771        1613 :     refChanIndx_bwe = hStereoTCA->refChanIndx;
     772        1613 :     if ( ( gD > 1.0f && refChanIndx_bwe == R_CH_INDX ) || ( gD < 1.0f && refChanIndx_bwe == L_CH_INDX ) )
     773             :     {
     774          55 :         refChanIndx_bwe = !( hStereoTCA->refChanIndx );
     775             :     }
     776             : 
     777        1613 :     findRefChanBWE( hStereoICBWE->dataChan[0], hStereoICBWE->dataChan[1], &refChanIndx_bwe, input_frame, &hStereoICBWE->memHPF[0], &hStereoICBWE->memHPF[4] );
     778             : 
     779        1613 :     hStereoICBWE->refChanIndx_bwe = refChanIndx_bwe;
     780             : 
     781        1613 :     if ( refChanIndx_bwe == R_CH_INDX )
     782             :     {
     783         840 :         mvr2r( hStereoICBWE->icbwe_inp_mem[0], temp_inp, nonRefMemLen );
     784         840 :         mvr2r( hStereoICBWE->dataChan[0], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     785             :     }
     786             :     else
     787             :     {
     788         773 :         mvr2r( hStereoICBWE->icbwe_inp_mem[1], temp_inp, nonRefMemLen );
     789         773 :         mvr2r( hStereoICBWE->dataChan[1], temp_inp + nonRefMemLen, input_frame - nonRefMemLen );
     790             :     }
     791             : 
     792        1613 :     if ( input_Fs == 48000 )
     793             :     {
     794             :         /*printf("\n Non-ref target HB generation for 48 kHz sample rate needs alignment verification \n");*/
     795        1493 :         mvr2r( temp_inp, temp_in, L_FRAME48k );
     796        1493 :         set_f( temp_inp, 0, L_FRAME48k );
     797        1493 :         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      756653 :     for ( i = 0; i < input_frame; i += 2 )
     802             :     {
     803      755040 :         temp_inp[i] *= -1.0f;
     804             :     }
     805             : 
     806        1613 :     if ( hCPE->element_mode >= IVAS_CPE_DFT && input_Fs >= 32000 && ( st->last_core != ACELP_CORE || st->last_extl == -1 ) )
     807             :     {
     808          60 :         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        1613 :     modify_Fs( temp_inp, L_FRAME32k, 32000, tempSHB, 16000, hStereoICBWE->mem_decim_shb_ch0, 0 );
     813             : 
     814        1613 :     mvr2r( tempSHB, shb_speech_nonref, L_FRAME16k );
     815             : 
     816        1613 :     return;
     817             : }

Generated by: LCOV version 1.14