LCOV - code coverage report
Current view: top level - lib_dec - ivas_post_proc_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 334 335 99.7 %
Date: 2025-05-03 01:55:50 Functions: 2 2 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 <assert.h>
      34             : #include <stdint.h>
      35             : #include "options.h"
      36             : #include "cnst.h"
      37             : #include "rom_com.h"
      38             : #include "prot_fx.h"
      39             : #include "ivas_prot_fx.h"
      40             : #include "ivas_cnst.h"
      41             : #include "wmc_auto.h"
      42             : 
      43             : /*-------------------------------------------------------------------------
      44             :  * ivas_post_proc()
      45             :  *
      46             :  * IVAS post-processing
      47             :  * - in SCE, post-processing of output channel
      48             :  * - in CPE_DFT, post-processing on output channels
      49             :  * - in CPE_TD, post-processing on decoded channels before upmixing
      50             :  *-------------------------------------------------------------------------*/
      51             : 
      52     1028889 : void ivas_post_proc_fx(
      53             :     SCE_DEC_HANDLE hSCE,                /* i/o: SCE decoder structure              */
      54             :     CPE_DEC_HANDLE hCPE,                /* i/o: CPE decoder structure              */
      55             :     const Word16 n,                     /* i  : channel number                     Q0*/
      56             :     Word32 synth[],                     /* i/o: output synthesis signal            Q11*/
      57             :     Word32 *output[CPE_CHANNELS],       /* i/o: output synthesis signal            output_q*/
      58             :     const Word16 output_frame,          /* i  : output frame length                Q0*/
      59             :     const Word16 sba_dirac_stereo_flag, /* i  : signal stereo output for SBA DirAC Q0*/
      60             :     Word16 output_q )
      61             : {
      62             :     Word16 k;
      63             :     Word16 delay_comp;
      64             :     Word32 output_Fs;
      65             :     Decoder_State **sts;
      66             :     TCX_LTP_DEC_HANDLE hTcxLtpDec;
      67             : 
      68     1028889 :     IF( hSCE != NULL )
      69             :     {
      70      311046 :         sts = hSCE->hCoreCoder;
      71             :     }
      72             :     ELSE
      73             :     {
      74      717843 :         sts = hCPE->hCoreCoder;
      75             :     }
      76             : 
      77     1028889 :     output_Fs = sts[0]->output_Fs;
      78     1028889 :     move32();
      79             : 
      80     1028889 :     test();
      81     1028889 :     test();
      82     1028889 :     test();
      83     1028889 :     test();
      84     1028889 :     test();
      85     1028889 :     IF( ( NE_16( sts[n]->element_mode, IVAS_CPE_DFT ) && !( sba_dirac_stereo_flag && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) ) || ( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) )
      86             :     {
      87      983033 :         IF( sts[n]->hTcxLtpDec != NULL )
      88             :         {
      89      979282 :             hTcxLtpDec = sts[n]->hTcxLtpDec;
      90             : 
      91      979282 :             test();
      92      979282 :             IF( NE_16( sts[n]->core, TCX_20_CORE ) && NE_16( sts[n]->core, TCX_10_CORE ) )
      93             :             {
      94             :                 /* TCX-LTP Postfilter: used in Mode 1 to update memories and to avoid discontinuities when the past frame was TCX */
      95      143481 :                 tcx_ltp_post_fx32( sts[n], hTcxLtpDec, ACELP_CORE, output_frame, 0, synth, NULL, output_q );
      96             :             }
      97             :             ELSE
      98             :             {
      99             :                 /* set delay */
     100      835801 :                 delay_comp = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); /*Q0*/
     101      835801 :                 move16();
     102             : 
     103      835801 :                 test();
     104      835801 :                 test();
     105      835801 :                 test();
     106      835801 :                 test();
     107      835801 :                 IF( EQ_16( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ), 0 ) && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) )
     108             :                 {
     109      197828 :                     Copy32( sts[n]->delay_buf_out32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/
     110             :                 }
     111      637973 :                 ELSE IF( sba_dirac_stereo_flag && EQ_16( sts[n]->element_mode, IVAS_CPE_MDCT ) )
     112             :                 {
     113       22423 :                     Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/
     114       22423 :                     move16();
     115       22423 :                     Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/
     116             :                 }
     117             : 
     118      835801 :                 tcx_ltp_post_fx32( sts[n], hTcxLtpDec, sts[n]->core, output_frame, add( NS2SA_FX2( output_Fs, ACELP_LOOK_NS ), delay_comp ), synth, sts[n]->hTcxDec->FBTCXdelayBuf_32, output_q );
     119             :             }
     120             :         }
     121             :     }
     122             :     ELSE /* IVAS_CPE_DFT */
     123             :     {
     124             :         Word16 pit_res_max_past_tmp;
     125             : 
     126       45856 :         pit_res_max_past_tmp = sts[0]->pit_res_max_past; /*Q0*/
     127       45856 :         move16();
     128      132223 :         FOR( k = 0; k < hCPE->nchan_out; k++ )
     129             :         {
     130       86367 :             IF( k == 0 )
     131             :             {
     132       45856 :                 hTcxLtpDec = sts[0]->hTcxLtpDec;
     133             :             }
     134             :             ELSE
     135             :             {
     136       40511 :                 hTcxLtpDec = hCPE->hStereoDft->hTcxLtpDec;
     137             :                 /* copy LTP side-info of downmix channel also to right channel struct */
     138       40511 :                 hTcxLtpDec->tcxltp = sts[0]->hTcxLtpDec->tcxltp; /*Q0*/
     139       40511 :                 move16();
     140       40511 :                 hTcxLtpDec->tcxltp_gain = sts[0]->hTcxLtpDec->tcxltp_gain; /*Q15*/
     141       40511 :                 move16();
     142       40511 :                 hTcxLtpDec->tcxltp_pitch_int = sts[0]->hTcxLtpDec->tcxltp_pitch_int; /*Q0*/
     143       40511 :                 move16();
     144       40511 :                 hTcxLtpDec->tcxltp_pitch_fr = sts[0]->hTcxLtpDec->tcxltp_pitch_fr; /*Q0*/
     145       40511 :                 move16();
     146             :                 /* revert update of pit_res_max_past to have correct value also in right channel */
     147       40511 :                 sts[0]->pit_res_max_past = pit_res_max_past_tmp; /*Q0*/
     148       40511 :                 move16();
     149             :             }
     150             : 
     151             :             /*TCX-LTP*/
     152       86367 :             IF( NE_16( sts[0]->core, TCX_20_CORE ) && NE_16( sts[0]->core, TCX_10_CORE ) )
     153             :             {
     154             :                 /* update memories and to avoid discontinuities when the past frame was TCX */
     155       60695 :                 tcx_ltp_post_fx32( sts[0], hTcxLtpDec, ACELP_CORE, output_frame, 0, output[k], NULL, output_q );
     156             :             }
     157             :             ELSE
     158             :             {
     159             :                 /*Use channel 0 side info.*/
     160       25672 :                 tcx_ltp_post_fx32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q );
     161             :             }
     162             :         }
     163             :     }
     164             : 
     165     1028889 :     return;
     166             : }
     167             : 
     168             : 
     169             : /*-------------------------------------------------------------------------
     170             :  * stereo_dft_dec_core_switching_fx()
     171             :  *
     172             :  * core switching in DFT stereo
     173             :  *-------------------------------------------------------------------------*/
     174             : 
     175       63558 : void stereo_dft_dec_core_switching_fx(
     176             :     CPE_DEC_HANDLE hCPE,                             /* i/o: CPE decoder structure               */
     177             :     Word32 output_fx[],                              /* i/o: synthesis @internal Fs              q*/
     178             :     Word32 synth_fx[],                               /* i/o: synthesis @output Fs                q*/
     179             :     Word32 hb_synth_fx[],                            /* i/o: hb synthesis                        q*/
     180             :     Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o  : DFT buffers                         q_DFT*/
     181             :     const Word16 output_frame,                       /* i  : output frame length                 Q0*/
     182             :     const Word16 use_cldfb_for_dft,                  /* i  : flag to use of CLDFB FOR DFT Stereo Q0*/
     183             :     const Word16 sba_dirac_stereo_dtx_flag,          /* i  : DTX indicator FOR SBA DirAC stereo  Q0*/
     184             :     Word16 *q,
     185             :     Word16 *q_DFT )
     186             : {
     187             :     Word32 output_Fs;
     188             :     Decoder_State *st;
     189             :     Word16 i, tmps;
     190             :     Word16 delay_dft_dec, delay_dft_dec_lb, delay_tdbwe, delay_comp;
     191             :     Word16 L_frameTCX;
     192             :     Word16 predelay, ap_fade_len;
     193             :     Word32 ap_fade_len_inv, ap_fade_len_fx;
     194             :     Word16 qap_fade_len;
     195             :     Word32 pAp_input_fx[L_FRAME16k];
     196             :     Word32 tcx_core_buf_fx[L_FRAME16k];
     197             :     Word64 calc_inv;
     198             :     Word32 synth_tmp_fx[L_FRAME48k];
     199             : 
     200             : 
     201       63558 :     st = hCPE->hCoreCoder[0];  /* in DFT stereo, only M channel is decoded by the CoreCoder */
     202       63558 :     output_Fs = st->output_Fs; /*Q0*/
     203       63558 :     move32();
     204       63558 :     L_frameTCX = st->hTcxDec->L_frameTCX; /*Q0*/
     205       63558 :     move16();
     206             : 
     207             :     /*TBE*/
     208       63558 :     delay_tdbwe = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); /*Q0*/
     209       63558 :     move16();
     210       63558 :     delay_dft_dec = NS2SA_FX2( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); /*Q0*/
     211       63558 :     move16();
     212       63558 :     delay_dft_dec_lb = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS ); /*Q0*/
     213       63558 :     move16();
     214             : 
     215             :     /* TCX/ACELP/HQ-CORE->TCX */
     216       63558 :     tmps = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ FB*/ /*Q0*/
     217       63558 :     move16();
     218       63558 :     delay_comp = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), DELAY_BWE_TOTAL_NS ); /*cross-fading size @ LB*/ /*Q0*/
     219       63558 :     move16();
     220             : 
     221       63558 :     calc_inv = W_shl( 1, 31 );
     222             : 
     223             :     // Memory Tables //////////////////////////////////////////////////////////////////////////////
     224       63558 :     Word32 mem_len_inv_tbl[] = { 85899345, 42949672, 28633115, 21474836, 17179869, 14316557 };                                                          /*Q31*/
     225       63558 :     Word32 delay_comp_inv_tbl[] = { 2147483647, 306783378, 153391689, 97612893, 74051160, 58040098, 48806446, 42107522, 36398027, 32537631, 29020049 }; /*Q31*/
     226             :     ///////////////////////////////////////////////////////////////////////////////////////////////
     227             : 
     228       63558 :     test();
     229       63558 :     test();
     230       63558 :     IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) )
     231             :     {
     232         293 :         L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     233         293 :         L_lerp_fx_q11( hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     234             :     }
     235             : 
     236       63558 :     test();
     237       63558 :     test();
     238       63558 :     IF( ( st->prev_bfi != 0 ) && EQ_16( ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) )
     239             :     {
     240             :         /* last_core needed FOR correctly decoding ACELP->TCX/HQ switching frames in ivas_core_dec().
     241             :            In the following steps the decoder needs to consider IF the core was changed due to a lost frame to apply the correct transition */
     242         877 :         st->last_core = st->last_core_bfi;
     243         877 :         move16();
     244             :     }
     245             : 
     246             : 
     247       63558 :     test();
     248       63558 :     test();
     249       63558 :     test();
     250       63558 :     test();
     251       63558 :     test();
     252       63558 :     IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) )
     253             :     {
     254       17532 :         test();
     255       17532 :         test();
     256       17532 :         test();
     257       17532 :         test();
     258       17532 :         test();
     259       17532 :         test();
     260       17532 :         IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */
     261             :         {
     262             :             /* In case of a TCX to ACELP switch next frame */
     263       16293 :             Copy32( &output_fx[st->L_frame - NS2SA( ( st->L_frame * FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/
     264             : 
     265             :             /* BPF */
     266       16293 :             test();
     267       16293 :             test();
     268       16293 :             IF( st->p_bpf_noise_buf_32 && NE_16( st->core, HQ_CORE ) )
     269             :             {
     270       15192 :                 Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/
     271       15192 :                 stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 2, 0, q, q_DFT );
     272             :             }
     273             :             /* st->p_bpf_noise_buf not updated FOR HQ core -> skip analysis and set input memory to zero */
     274        1101 :             ELSE IF( st->p_bpf_noise_buf_32 && EQ_16( st->core, HQ_CORE ) )
     275             :             {
     276        1101 :                 set32_fx( hCPE->input_mem_BPF_fx[0], 0, STEREO_DFT32MS_OVL_16k );
     277             :             }
     278             : 
     279             :             /* TCX */
     280       16293 :             stereo_dft_dec_analyze_fx( hCPE, synth_fx, DFT_fx, 0, L_frameTCX, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT );
     281             :         }
     282        1239 :         ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */
     283             :         {
     284        1239 :             test();
     285        1239 :             IF( LE_32( st->last_core_brate, SID_2k40 ) && LE_16( st->element_mode, IVAS_SCE ) )
     286           2 :             {
     287           2 :                 Word16 mem_len = NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /*Q0*/
     288           2 :                 move16();
     289           2 :                 Word32 mem_len_inv = mem_len_inv_tbl[( mem_len / 25 ) - 1];
     290           2 :                 move32();
     291           2 :                 Word16 qmem_len = norm_l( mem_len );
     292           2 :                 Word32 mem_len_fx = L_shl( mem_len, qmem_len );
     293         302 :                 FOR( i = 0; i < mem_len; i++ )
     294             :                 {
     295         300 :                     hCPE->input_mem_fx[0][i] = Mpy_32_32( hCPE->input_mem_fx[0][i], L_sub( mem_len_fx, L_shl( i, qmem_len ) ) ); /*Q11 + qmem_len - 31*/
     296         300 :                     move32();
     297         300 :                     hCPE->input_mem_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_fx[0][i], mem_len_inv ), sub( Q31, qmem_len ) ); /*Q11*/
     298         300 :                     move32();
     299             :                 }
     300             : 
     301             :                 /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */
     302         224 :                 FOR( i = 0; i < delay_tdbwe; i++ )
     303             :                 {
     304         444 :                     hCPE->input_mem_fx[0][( ( NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] =
     305         222 :                         L_add( hCPE->input_mem_fx[0][NS2SA( ( ( L_frameTCX * FRAMES_PER_SEC ) - STEREO_DFT32MS_OVL_NS ) + delay_tdbwe, i )], hb_synth_fx[i] ); /*Q11*/
     306         222 :                     move32();
     307             :                 }
     308             :             }
     309             :             ELSE
     310             :             {
     311             :                 /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */
     312       99176 :                 FOR( i = 0; i < delay_tdbwe; i++ )
     313             :                 {
     314       97939 :                     hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = hb_synth_fx[i]; /*Q11*/
     315       97939 :                     move32();
     316             :                 }
     317             :             }
     318             : 
     319             :             /* cross-fading between (delayed) TBE and FB-TCX over 2.3125ms */
     320        1239 :             Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/
     321        1239 :             Word16 qtmps = norm_l( tmps );
     322        1239 :             Word32 tmps_fx = L_shl( tmps, qtmps );
     323        1239 :             Word32 tmps_inv = (Word32) ( calc_inv / tmps );
     324       99400 :             FOR( i = 0; i < tmps; i++ )
     325             :             {
     326       98161 :                 synth_tmp_fx[i] = L_add( Mpy_32_32( hb_synth_fx[( i + delay_tdbwe )], L_sub( tmps_fx, L_shl( i, qtmps ) ) ), Mpy_32_32( synth_fx[i], L_shl( i, qtmps ) ) ); /*q + qtmps - 31*/
     327       98161 :                 move32();
     328       98161 :                 synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], tmps_inv ), sub( 31, qtmps ) ); /*q*/
     329       98161 :                 move32();
     330             :             }
     331             : 
     332             :             /* FB-TCX */
     333        1239 :             stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, L_frameTCX, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT );
     334             : 
     335        1239 :             IF( st->tcxonly == 0 )
     336             :             {
     337        1239 :                 IF( EQ_16( hCPE->hStereoDft->hConfig->res_pred_mode, STEREO_DFT_RESPRED_ESF ) )
     338             :                 {
     339         774 :                     Copy32( output_fx, tcx_core_buf_fx, L_FRAME16k ); /*q*/
     340             :                 }
     341             :                 /* fading-out LB-TCX/ACELP */
     342        1239 :                 Word16 qdelay_comp = norm_l( delay_comp );
     343        1239 :                 Word32 delay_comp_inv = delay_comp_inv_tbl[( delay_comp / 7 )]; /*Q31*/
     344        1239 :                 move32();
     345        1239 :                 Word32 delay_comp_fx = L_shl( delay_comp, qdelay_comp );
     346       43882 :                 FOR( i = 0; i < delay_comp; i++ )
     347             :                 {
     348       42643 :                     output_fx[i] = Mpy_32_32( output_fx[i], L_sub( delay_comp_fx, L_shl( i, qdelay_comp ) ) ); /*q + qdelay_comp - 31*/
     349       42643 :                     move32();
     350       42643 :                     output_fx[i] = L_shl( Mpy_32_32( output_fx[i], delay_comp_inv ), sub( Q31, qdelay_comp ) ); /*q*/
     351       42643 :                     move32();
     352             :                 }
     353             : 
     354             :                 /* In case of TCX frames, output LB TCX is zeroed out until the end but in case of an TCX->ACELP switch, this memory is needed, hence it is backed up */
     355             :                 /* Unlike the case when DFT32MS is disabled, there is only 1 DFT analysis window, hence in the TCX frame we don't want to do a DFT analysis FOR LB TCX
     356             :                 but in a potential ACELP frame, we want the memories of the LB TCX FOR the last OLA samples so that HB analysis can be skipped */
     357        1239 :                 Copy32( &output_fx[st->L_frame - NS2SA_FX2( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/
     358             : 
     359             :                 /*zero the rest FOR avoiding adding contribution except the last samples which are not considered in DFT analysis (potentially used in next ACELP frame)*/
     360        1239 :                 IF( GT_32( st->last_core_brate, SID_2k40 ) )
     361             :                 {
     362      312376 :                     FOR( ; i < st->L_frame; i++ )
     363             :                     {
     364      311198 :                         output_fx[i] = 0;
     365      311198 :                         move32();
     366             :                     }
     367             : 
     368        1178 :                     stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB_ADD, 1, 0, q, q_DFT );
     369             : 
     370             :                     /* BPF */
     371        1178 :                     IF( st->p_bpf_noise_buf_32 )
     372             :                     {
     373        1178 :                         set32_fx( hCPE->input_mem_BPF_fx[0], 0, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     374             :                     }
     375             :                 }
     376             :             }
     377             :         }
     378             :     }
     379             :     ELSE /* ACELP core */
     380             :     {
     381       46026 :         test();
     382       46026 :         test();
     383       46026 :         test();
     384       46026 :         IF( LE_32( st->core_brate, SID_2k40 ) && !sba_dirac_stereo_dtx_flag )
     385             :         {
     386       10351 :             set32_fx( hCPE->input_mem_fx[0], 0, NS2SA_FX2( L_mult0( st->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     387       10351 :             set32_fx( hCPE->input_mem_LB_fx[0], 0, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     388             : 
     389             :             /* CNG generated in ivas_cpe_dec() */
     390             :         }
     391       35675 :         ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */
     392             :         {
     393        1529 :             IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) )
     394             :             {
     395             :                 /* In case of a TCX to ACELP switch, retrieve the LB-TCX memories FOR the first STEREO_DFT32MS_OVL_NS NS of OLA */
     396        1088 :                 L_lerp_fx_q11( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     397             :             }
     398             : 
     399        1529 :             IF( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) )
     400           3 :             {
     401             :                 Word16 nZeros;
     402           3 :                 nZeros = (Word16) ( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/
     403           3 :                 move16();
     404           3 :                 delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); /*Q0*/
     405           3 :                 move16();
     406             : 
     407           3 :                 Copy32( &st->hHQ_core->old_out_fx32[nZeros - ( delay_comp + NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*Q11*/
     408           3 :                 Copy32( synth_fx, synth_tmp_fx, output_frame );                                                                                                                                                                                     /*q*/
     409             : 
     410             :                 Word16 mem_len;
     411           3 :                 mem_len = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /*Q0*/
     412           3 :                 move16();
     413             : 
     414           3 :                 Word16 qmem_len = norm_l( mem_len );
     415           3 :                 Word32 mem_len_fx = L_shl( mem_len, qmem_len );
     416           3 :                 Word32 mem_len_inv = (Word32) ( calc_inv / tmps );
     417           3 :                 move32();
     418         153 :                 FOR( i = 0; i < mem_len; i++ )
     419             :                 {
     420         150 :                     hCPE->input_mem_LB_fx[0][i] = Mpy_32_32( hCPE->input_mem_LB_fx[0][i], L_sub( mem_len_fx, L_shl( i, qmem_len ) ) ); /*Q11 + qmem_len - 31*/
     421         150 :                     move32();
     422         150 :                     hCPE->input_mem_LB_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][i], mem_len_inv ), sub( Q31, qmem_len ) ); /*Q11*/
     423         150 :                     move32();
     424             :                 }
     425           3 :                 set32_fx( output_fx, 0, st->L_frame );
     426             : 
     427           3 :                 stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT );
     428             : 
     429             :                 /* BPF */
     430           3 :                 IF( st->p_bpf_noise_buf_32 )
     431             :                 {
     432           3 :                     Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/
     433           3 :                     stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT );
     434             :                 }
     435             :             }
     436             :             ELSE
     437             :             {
     438             :                 /* ACELP */
     439       42560 :                 FOR( i = 0; i < ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ); i++ )
     440             :                 {
     441       41034 :                     hCPE->input_mem_LB_fx[0][i] = 0;
     442       41034 :                     move32();
     443             :                 }
     444             :                 /* ACELP fading-in*/
     445        1526 :                 Word16 qdelay_dft_dec_lb = norm_l( delay_dft_dec_lb );
     446        1526 :                 Word32 delay_dft_dec_lb_inv = (Word32) ( calc_inv / delay_dft_dec_lb );
     447       28882 :                 FOR( i = 0; i < delay_dft_dec_lb; i++ )
     448             :                 {
     449       54712 :                     hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] =
     450       27356 :                         Mpy_32_32( hCPE->input_mem_LB_fx[0][( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i], L_shl( i, qdelay_dft_dec_lb ) ); /*Q11 + qdelay_dft_dec_lb -31*/
     451       27356 :                     move32();
     452       54712 :                     hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] =
     453       27356 :                         L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); /*Q11*/
     454       27356 :                     move32();
     455             :                 }
     456        1526 :                 stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT );
     457             : 
     458             :                 /* BPF */
     459        1526 :                 IF( st->p_bpf_noise_buf_32 )
     460             :                 {
     461        1085 :                     Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/
     462        1085 :                     stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT );
     463             :                 }
     464             : 
     465             :                 /* Fading-in TD-BWE, Fading-out FB-TCX*/
     466        1526 :                 Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/
     467        1526 :                 IF( NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
     468             :                 {
     469        1061 :                     Word16 qdelay_dft_dec = norm_l( delay_dft_dec );
     470        1061 :                     Word32 delay_dft_dec_inv = (Word32) ( calc_inv / delay_dft_dec );
     471        1061 :                     Word32 delay_dft_dec_fx = L_shl( delay_dft_dec, qdelay_dft_dec );
     472       47241 :                     FOR( i = 0; i < delay_dft_dec; i++ ) /* 1.25 ms of hb_synth fade-in and TCX fade-out */
     473             :                     {
     474      138540 :                         hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec ) + i )] = L_add(
     475       46180 :                             Mpy_32_32( hb_synth_fx[( ( delay_tdbwe - delay_dft_dec ) + i )], L_shl( i, qdelay_dft_dec ) ),
     476       46180 :                             Mpy_32_32( hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec ) + i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ) ); /*Q11 + qdelay_dft_dec - 31*/
     477       46180 :                         move32();
     478       46180 :                         hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec ) + i )] = L_shl(
     479       46180 :                             Mpy_32_32( hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec ) + i )], delay_dft_dec_inv ),
     480       46180 :                             sub( Q31, qdelay_dft_dec ) ); /*Q11*/
     481       46180 :                         move32();
     482             :                     }
     483       47241 :                     FOR( i = 0; i < delay_dft_dec; i++ ) /* 1.25 ms of hb_synth fade out. ICBWE fade in performed in time domain here */
     484             :                     {
     485       46180 :                         synth_tmp_fx[i] = Mpy_32_32( hb_synth_fx[( ( delay_tdbwe - delay_dft_dec ) + i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ); /*q + qdelay_dft_dec - 31*/
     486       46180 :                         move32();
     487       46180 :                         synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], delay_dft_dec_inv ), sub( Q31, qdelay_dft_dec ) ); /*q*/
     488       46180 :                         move32();
     489             :                     }
     490             : 
     491      693761 :                     FOR( ; i < output_frame; i++ )
     492             :                     {
     493      692700 :                         synth_tmp_fx[i] = 0;
     494      692700 :                         move32();
     495             :                     }
     496             :                 }
     497             :             }
     498             : 
     499             : 
     500        1529 :             IF( sba_dirac_stereo_dtx_flag )
     501             :             {
     502           3 :                 stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 0, 0, q, q_DFT );
     503             :             }
     504        1526 :             ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
     505             :             {
     506         465 :                 stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_HB_ADD, 1, 0, q, q_DFT );
     507             :             }
     508             :             ELSE
     509             :             {
     510        1061 :                 stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 1, 0, q, q_DFT );
     511             :             }
     512             :         }
     513             :         ELSE /* ACELP -> ACELP */
     514             :         {
     515       34146 :             test();
     516       34146 :             test();
     517       34146 :             test();
     518       34146 :             test();
     519       34146 :             IF( sba_dirac_stereo_dtx_flag && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) )
     520             :             {
     521          88 :                 set32_fx( output_fx, 0, st->L_frame );
     522             :             }
     523             :             /* this needs an indication FOR sba2stereo in general */
     524       34058 :             ELSE IF( EQ_16( hCPE->element_mode, IVAS_SCE ) && LE_32( st->last_core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) )
     525             :             {
     526           0 :                 L_lerp_fx_q11( hCPE->input_mem_fx[0], hCPE->input_mem_LB_fx[0], NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
     527             :             }
     528             : 
     529             :             /* ACELP synthesis @ internal sampling rate */
     530             : 
     531       34146 :             stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT );
     532             : 
     533             :             /* BPF */
     534       34146 :             IF( st->p_bpf_noise_buf_32 )
     535             :             {
     536       31917 :                 Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); /*q*/
     537       31917 :                 stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 0, 0, q, q_DFT );
     538             :             }
     539             : 
     540             :             /* BWE */
     541       34146 :             test();
     542       34146 :             test();
     543       34146 :             test();
     544       34146 :             test();
     545       34146 :             IF( sba_dirac_stereo_dtx_flag && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) )
     546             :             {
     547          88 :                 stereo_dft_dec_analyze_fx( hCPE, synth_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 0, 0, q, q_DFT );
     548             :             }
     549       34058 :             ELSE IF( NE_16( st->extl, -1 ) || ( ( st->bws_cnt > 0 ) && EQ_16( st->core, ACELP_CORE ) ) )
     550             :             {
     551       29457 :                 stereo_dft_dec_analyze_fx( hCPE, hb_synth_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 2, negate( delay_tdbwe ), q, q_DFT );
     552             :             }
     553             :         }
     554             :     }
     555             : 
     556             :     /*----------------------------------------------------------------*
     557             :      * enhanced stereo filling: allpass filter
     558             :      *----------------------------------------------------------------*/
     559             : 
     560       63558 :     IF( EQ_16( hCPE->hStereoDft->hConfig->res_pred_mode, STEREO_DFT_RESPRED_ESF ) )
     561             :     {
     562       32164 :         IF( EQ_32( st->sr_core, INT_FS_12k8 ) )
     563             :         {
     564       19754 :             ap_fade_len = STEREO_DFT_ALLPASS_FADELEN_12k8;
     565       19754 :             move16();
     566       19754 :             ap_fade_len_inv = 67108864; /*1/32 in Q31*/
     567       19754 :             move32();
     568             :         }
     569             :         ELSE
     570             :         {
     571       12410 :             ap_fade_len = STEREO_DFT_ALLPASS_FADELEN_16k;
     572       12410 :             move16();
     573       12410 :             ap_fade_len_inv = 53687091; /*1/40 in Q31*/
     574       12410 :             move32();
     575             :         }
     576             : 
     577       32164 :         qap_fade_len = norm_l( ap_fade_len );
     578       32164 :         ap_fade_len_fx = L_shl( ap_fade_len, qap_fade_len );
     579             : 
     580       32164 :         test();
     581       32164 :         test();
     582       32164 :         test();
     583       32164 :         test();
     584       32164 :         test();
     585       32164 :         IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) )
     586       11208 :         {
     587       11208 :             Word16 numZeros = (Word16) ( NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ) ); /*Q0*/
     588             :             Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )];
     589             : 
     590       11208 :             Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/
     591       11208 :             hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx;
     592       11208 :             move16();
     593             : 
     594       11208 :             test();
     595       11208 :             test();
     596       11208 :             test();
     597       11208 :             test();
     598       11208 :             test();
     599       11208 :             IF( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) && !st->tcxonly )
     600             :             {
     601         774 :                 Copy32( tcx_core_buf_fx, pAp_input_fx, st->L_frame ); /*q*/
     602             :             }
     603             :             ELSE
     604             :             {
     605       10434 :                 Copy32( output_fx, pAp_input_fx, st->L_frame ); /*q*/
     606             :             }
     607             : 
     608       11208 :             IF( EQ_16( st->last_core, ACELP_CORE ) && EQ_16( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) && !st->tcxonly ) /* ACELP -> TCX/HQ-Core */
     609             :             {
     610         774 :                 Copy32( tcx_core_buf_fx, tmp_fade_fx, ap_fade_len ); /*q*/
     611       28702 :                 FOR( i = 0; i < ap_fade_len; i++ )
     612             :                 {
     613       27928 :                     pAp_input_fx[i] = L_add(
     614             :                         Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ),
     615             :                         Mpy_32_32( tmp_fade_fx[i], L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ) ); /*q + qap_fade_len - 31*/
     616       27928 :                     move32();
     617       27928 :                     pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); /*q*/
     618       27928 :                     move32();
     619             :                 }
     620             :             }
     621             :         }
     622             :         ELSE
     623             :         {
     624       20956 :             Copy32( output_fx, pAp_input_fx, st->L_frame ); /*q*/
     625       20956 :             IF( NE_16( st->last_core, ACELP_CORE ) )        /* TCX/HQ-Core -> ACELP */
     626             :             {
     627        1011 :                 Word16 shift = sub( hCPE->hStereoDft->q_ap_fade_mem_fx, q_DFT[0] );
     628       36027 :                 FOR( i = 0; i < ap_fade_len; i++ )
     629             :                 {
     630       70032 :                     pAp_input_fx[i] = L_add(
     631             :                         Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ),
     632       35016 :                         Mpy_32_32( L_shr( hCPE->hStereoDft->ap_fade_mem_fx[i], shift ), L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ) ); /*q + qap_fade_len - 31*/
     633       35016 :                     move32();
     634       35016 :                     pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); /*q*/
     635       35016 :                     move32();
     636             :                 }
     637             :             }
     638             :         }
     639       32164 :         predelay = NS2SA_FX2( st->sr_core, DELAY_BWE_TOTAL_NS ); /*Q0*/
     640       32164 :         move16();
     641             : 
     642             :         /* apply predelay to have same overall filter delay FOR all cases */
     643             : 
     644       32164 :         delay_signal_q_adj_fx( pAp_input_fx, st->L_frame, hCPE->hStereoDft->ap_delay_mem_fx, predelay, *q, hCPE->hStereoDft->q_ap_delay_mem_fx );
     645             : 
     646             :         /* input zeroes FOR transient frames */
     647       32164 :         IF( hCPE->hStereoDft->attackPresent )
     648             :         {
     649         941 :             IF( hCPE->hStereoDft->ap_wasTransient )
     650             :             {
     651          73 :                 set32_fx( pAp_input_fx, 0, ap_fade_len );
     652             :             }
     653             :             ELSE
     654             :             {
     655       31076 :                 FOR( i = 0; i < ap_fade_len; i++ )
     656             :                 {
     657       30208 :                     pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ); /*q + qap_fade_len - 31*/
     658       30208 :                     move32();
     659       30208 :                     pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); /*q*/
     660       30208 :                     move32();
     661             :                 }
     662             :             }
     663         941 :             set32_fx( pAp_input_fx + ap_fade_len, 0, st->L_frame - ap_fade_len );
     664         941 :             hCPE->hStereoDft->ap_wasTransient = 1;
     665         941 :             move16();
     666             :         }
     667       31223 :         ELSE IF( hCPE->hStereoDft->ap_wasTransient )
     668             :         {
     669       30994 :             FOR( i = 0; i < ap_fade_len; i++ )
     670             :             {
     671       30128 :                 pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ); /*q + qap_fade_len - 31*/
     672       30128 :                 move32();
     673       30128 :                 pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); /*q*/
     674       30128 :                 move32();
     675             :             }
     676         866 :             hCPE->hStereoDft->ap_wasTransient = 0;
     677         866 :             move16();
     678             :         }
     679             : 
     680             :         /* apply 5-stage allpass, each stage consisting of a nested allpass pair */
     681       32164 :         filter_with_allpass_fx( pAp_input_fx, pAp_input_fx, st->L_frame, &hCPE->hStereoDft->ap1, *q );
     682       32164 :         filter_with_allpass_fx( pAp_input_fx, pAp_input_fx, st->L_frame, &hCPE->hStereoDft->ap2, *q );
     683       32164 :         filter_with_allpass_fx( pAp_input_fx, pAp_input_fx, st->L_frame, &hCPE->hStereoDft->ap3, *q );
     684             : 
     685             :         /* apply DFT to allpass-filtered signal */
     686       32164 :         stereo_dft_dec_analyze_fx( hCPE, pAp_input_fx, DFT_fx, 1, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT );
     687       32164 :         hCPE->hStereoDft->q_ap_delay_mem_fx = *q;
     688       32164 :         move16();
     689             :     }
     690             : 
     691       63558 :     IF( EQ_16( st->core, ACELP_CORE ) )
     692             :     {
     693       46053 :         IF( !use_cldfb_for_dft ) /* Skip this FOR DFT Stereo mono output at non-residual bitrates */
     694             :         {
     695       31319 :             L_lerp_fx_q11( output_fx, synth_fx, output_frame, hCPE->hCoreCoder[0]->L_frame ); /* Dirty resampling, but should be good enough FOR ECU analysis */
     696             :         }
     697       46053 :         test();
     698       46053 :         test();
     699       46053 :         test();
     700       46053 :         test();
     701       46053 :         test();
     702       46053 :         IF( !use_cldfb_for_dft || ( ( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && EQ_16( st->cng_type, LP_CNG ) && EQ_16( st->extl, SWB_CNG ) && EQ_16( hCPE->nchan_out, 1 ) ) )
     703             :         {
     704       32118 :             v_add_fx( synth_fx, hb_synth_fx, synth_fx, output_frame ); /* Use one channel TD-BWE FOR ECU analysis buffer */ /*q*/
     705             :         }
     706             :     }
     707             : 
     708             : 
     709       63558 :     return;
     710             : }

Generated by: LCOV version 1.14