LCOV - code coverage report
Current view: top level - lib_dec - dec_LPD_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 249 465 53.5 %
Date: 2025-05-03 01:55:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : 
       6             : #include <assert.h>
       7             : #include <stdint.h>
       8             : #include "options.h"
       9             : #include "prot_fx.h"
      10             : #include "basop_util.h"
      11             : #include "rom_com.h"
      12             : 
      13             : /* #if defined(_WIN32) && (_MSC_VER <= 1200)  /\* disable global optimizations to overcome an internal compiler error *\/ */
      14             : #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) /* disable global optimizations to overcome an internal compiler error */
      15             : #pragma optimize( "g", off )
      16             : #endif
      17             : 
      18             : /*-------------------------------------------------------------------*
      19             :  * decoder_LPD_fx()
      20             :  *
      21             :  * Core decoder MODE2
      22             :  *--------------------------------------------------------------------*/
      23             : 
      24        1248 : void decoder_LPD_fx(
      25             :     Word16 signal_out[],   /* output: signal with LPD delay (7 subfrs) */
      26             :     Word16 signal_outFB[], /* o  : synthesis @output_FS                */
      27             :     Word16 *total_nbbits,  /* i/o:    number of bits / decoded bits    */
      28             :     Decoder_State *st,     /* i/o: decoder memory state pointer        */
      29             :     Word16 *bpf_noise_buf, /* i/o: BPF noise buffer                  Q0  */
      30             :     Word16 bfi,            /* i  : BFI flag                            */
      31             :     Word16 *bitsRead,      /* o  : number of read bits                 */
      32             :     Word16 param[],        /* o  : buffer of parameters                */
      33             :     Word16 *pitch_buf,     /* i/o: floating pitch values for each subfr Q6*/
      34             :     Word16 *voice_factors, /* o  : voicing factors                     Q15*/
      35             :     Word16 *ptr_bwe_exc    /* o  : excitation for SWB TBE              */
      36             : )
      37             : {
      38             :     Word16 *param_lpc;
      39             :     Word16 synth_buf[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
      40             :     Word16 *synth;
      41             :     Word16 synth_bufFB[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
      42             :     Word16 *synthFB;
      43             :     Word16 lsf[( NB_DIV + 1 ) * M], lsp[( NB_DIV + 1 ) * M], lspmid[M], lsfmid[M];
      44             :     Word16 Aq[( NB_SUBFR16k + 1 ) * ( M + 1 )]; /* Dyn RAM: it can be reduced by M+1 if insert branch for nb_subfr==5*/
      45             :     Word16 pitch[NB_SUBFR16k];
      46             :     Word16 pit_gain[NB_SUBFR16k];
      47             :     Word16 i, k, *prm;
      48             :     Word16 L_frame, nb_subfr;
      49             :     Word16 L_frameTCX;
      50             :     Word16 Aind[M + 1], lspind[M];
      51             :     Word16 tmp_old[M + 1], tmp_new[M + 1], enr_old, enr_new;
      52             :     Word16 xspnew_uw[NB_DIV * M], xsfnew_uw[NB_DIV * M];
      53             :     Word16 const *xsfBase; /* base for differential XSF coding */
      54             :     Word16 past_core_mode;
      55             : 
      56             :     Word16 lsf_q_1st_rf[M], lsf_q_rf[M], lsp_q_rf[M];
      57             :     Word32 lsp_diff;
      58             :     Word16 LSF_Q_prediction;
      59             :     Word16 tcx_last_overlap_mode, tcx_current_overlap_mode;
      60             :     TD_BWE_DEC_HANDLE hBWE_TD;
      61             :     TCX_DEC_HANDLE hTcxDec;
      62             :     TCX_LTP_DEC_HANDLE hTcxLtpDec;
      63             : 
      64        1248 :     hBWE_TD = st->hBWE_TD;
      65        1248 :     hTcxLtpDec = st->hTcxLtpDec;
      66        1248 :     hTcxDec = st->hTcxDec;
      67             : 
      68        1248 :     st->core = 0; /* to avoid compilation warnings */
      69        1248 :     move16();
      70        1248 :     prm = NULL; /* to avoid compilation warnings */
      71             : 
      72             :     /*--------------------------------------------------------------------------------*
      73             :      * INIT
      74             :      *--------------------------------------------------------------------------------*/
      75             : 
      76        1248 :     enr_old = 0;
      77        1248 :     move16();
      78        1248 :     enr_new = 0;
      79        1248 :     move16();
      80             : 
      81        1248 :     LSF_Q_prediction = -1;
      82        1248 :     move16();
      83             : 
      84        1248 :     param_lpc = param + DEC_NPRM_DIV * NB_DIV;
      85             : 
      86        1248 :     past_core_mode = st->last_core_bfi;
      87        1248 :     move16();
      88             : 
      89        1248 :     test();
      90        1248 :     test();
      91        1248 :     if ( st->use_partial_copy && GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) )
      92             :     {
      93           0 :         bfi = st->bfi;
      94           0 :         move16();
      95             :     }
      96             : 
      97             :     /*Adjust bit per frame*/
      98        1248 :     IF( bfi == 0 )
      99             :     {
     100        1248 :         st->bits_frame_core = sub( st->bits_frame, bitsRead[0] );
     101        1248 :         move16();
     102             :     }
     103             : 
     104             :     /* Framing parameters */
     105        1248 :     L_frame = st->L_frame;
     106        1248 :     move16();
     107        1248 :     L_frameTCX = hTcxDec->L_frameTCX;
     108        1248 :     move16();
     109        1248 :     nb_subfr = st->nb_subfr;
     110        1248 :     move16();
     111             : 
     112             : 
     113             :     /* Initialize pointers */
     114        1248 :     synth = synth_buf + hTcxDec->old_synth_len;
     115             :     /*st->old_synth: Q_0*/
     116        1248 :     Copy( hTcxDec->old_synth, synth_buf, hTcxDec->old_synth_len );
     117        1248 :     set16_fx( synth, 0, L_FRAME_PLUS + M );
     118             : 
     119        1248 :     synthFB = synth_bufFB + hTcxDec->old_synth_lenFB;
     120        1248 :     Copy( hTcxDec->old_synthFB_fx, synth_bufFB, hTcxDec->old_synth_lenFB );
     121        1248 :     set16_fx( synthFB, 0, L_FRAME_PLUS + M );
     122             : 
     123             :     /*For post-processing (post-filtering+blind BWE)*/
     124        1248 :     IF( st->tcxonly == 0 )
     125             :     {
     126             :         /* for bass postfilter */
     127        1248 :         set16_fx( pitch, L_SUBFR, nb_subfr );
     128             : 
     129        1248 :         set16_fx( pit_gain, 0, nb_subfr );
     130             :     }
     131             : 
     132             :     /* PLC: [Common: Memory update]
     133             :      * PLC: Update the number of lost frames */
     134        1248 :     IF( bfi != 0 )
     135             :     {
     136           0 :         move16();
     137           0 :         st->nbLostCmpt = add( st->nbLostCmpt, 1 );
     138             :     }
     139             : 
     140             : 
     141             :     /*--------------------------------------------------------------------------------*
     142             :      * BITSTREAM DECODING
     143             :      *--------------------------------------------------------------------------------*/
     144             : 
     145        1248 :     IF( bfi == 0 )
     146             :     {
     147             :         /* PLC: [TCX: Tonal Concealment] */
     148        1248 :         st->second_last_core = st->last_core;
     149        1248 :         move16();
     150        1248 :         tcx_last_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode;
     151        1248 :         move16();
     152        1248 :         tcx_current_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode;
     153        1248 :         move16();
     154        1248 :         dec_prm_fx( &st->coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead );
     155        1248 :         test();
     156        1248 :         test();
     157        1248 :         IF( !st->rate_switching_init && EQ_16( ( st->last_codec_mode ), MODE2 ) && st->BER_detect )
     158             :         {
     159           0 :             st->coder_type = st->last_coder_type;
     160           0 :             move16();
     161           0 :             st->last_core = st->second_last_core;
     162           0 :             move16();
     163           0 :             st->hTcxCfg->tcx_last_overlap_mode = tcx_last_overlap_mode;
     164           0 :             move16();
     165           0 :             st->hTcxCfg->tcx_curr_overlap_mode = tcx_current_overlap_mode;
     166           0 :             move16();
     167           0 :             st->bfi = 1;
     168           0 :             move16();
     169           0 :             bfi = 1;
     170           0 :             move16();
     171           0 :             st->flagGuidedAcelp = 0;
     172           0 :             move16();
     173           0 :             st->nbLostCmpt = add( st->nbLostCmpt, 1 );
     174           0 :             move16();
     175           0 :             st->core_brate = st->last_core_brate;
     176           0 :             move16();
     177           0 :             st->core = GetPLCModeDecision_fx( st );
     178           0 :             move16();
     179             :         }
     180             :     }
     181             :     ELSE
     182             :     {
     183             : 
     184           0 :         test();
     185           0 :         test();
     186           0 :         IF( st->use_partial_copy && GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) )
     187             :         {
     188           0 :             dec_prm_fx( &st->coder_type, param, param_lpc, total_nbbits, st, L_frame, bitsRead );
     189             :         }
     190             : 
     191           0 :         if ( GT_16( st->nbLostCmpt, 1 ) )
     192             :         {
     193           0 :             st->flagGuidedAcelp = 0;
     194           0 :             move16();
     195             :         }
     196             :     }
     197             : 
     198             :     /* PLC: [Common: mode decision]
     199             :      * PLC: Decide which Concealment to use. Update pitch lags if needed */
     200        1248 :     IF( bfi != 0 )
     201             :     {
     202           0 :         st->core = GetPLCModeDecision_fx( st );
     203           0 :         move16();
     204             :     }
     205             : 
     206        1248 :     IF( bfi == 0 )
     207             :     {
     208        1248 :         IF( EQ_16( st->prev_bfi, 1 ) )
     209             :         {
     210           0 :             st->prev_nbLostCmpt = st->nbLostCmpt;
     211           0 :             move16();
     212             :         }
     213             :         ELSE
     214             :         {
     215        1248 :             st->prev_nbLostCmpt = 0;
     216        1248 :             move16();
     217             :         }
     218        1248 :         move16();
     219        1248 :         st->nbLostCmpt = 0;
     220             :     }
     221             : 
     222             :     /*--------------------------------------------------------------------------------*
     223             :      * LPC PARAMETERS
     224             :      *--------------------------------------------------------------------------------*/
     225             : 
     226        1248 :     test();
     227        1248 :     test();
     228        1248 :     test();
     229        1248 :     IF( ( bfi == 0 ) || ( bfi != 0 && st->use_partial_copy != 0 && EQ_16( st->rf_frame_type, RF_TCXFD ) ) )
     230             :     {
     231        1248 :         test();
     232        1248 :         test();
     233        1248 :         test();
     234        1248 :         test();
     235        1248 :         test();
     236        1248 :         test();
     237        1248 :         IF( EQ_16( st->use_partial_copy, 1 ) && ( LT_16( st->rf_frame_type, RF_TCXFD ) || GT_16( st->rf_frame_type, RF_TCXTD2 ) ) )
     238             :         {
     239           0 :             IF( EQ_16( (Word16) hTcxDec->envWeighted, 1 ) )
     240             :             {
     241           0 :                 Copy( st->lspold_uw, st->lsp_old_fx, M );
     242           0 :                 Copy( st->lsfold_uw, st->lsf_old_fx, M );
     243           0 :                 hTcxDec->envWeighted = 0;
     244           0 :                 move16();
     245             :             }
     246             : 
     247             :             /* first stage VQ, 8 bits; reuse TCX high rate codebook */
     248           0 :             set16_fx( lsf_q_1st_rf, 0, M );
     249           0 :             vlpc_1st_dec( param_lpc[0], lsf_q_1st_rf );
     250             : 
     251             :             /* second stage vq */
     252             :             /* quantized lsf from two stages  */
     253             :             /*v_add(lsf_q_1st_rf, lsf_q_diff_cb_8b_rf + M * param_lpc[1], lsf_q_rf, M);*/
     254           0 :             FOR( i = 0; i < M; i++ )
     255             :             {
     256           0 :                 Word16 tmp = lsf_q_diff_cb_8b_rf[i + M * param_lpc[1]]; /*tmp = unquantized lsf difference (2nd VQ) in Q6*/
     257           0 :                 tmp = shr( mult_r( tmp, 20972 ), 4 );                   /* bring tmp to Qx2.56 for addition */
     258           0 :                 lsf_q_rf[i] = add( lsf_q_1st_rf[i], tmp );
     259           0 :                 move16();
     260             :             }
     261             : 
     262           0 :             v_sort( lsf_q_rf, 0, M - 1 );
     263           0 :             reorder_lsf_fx( lsf_q_rf, LSF_GAP_FX, M, st->sr_core );
     264             : 
     265             :             /* current n-th ACELP frame and its corresponding partial copy  */
     266             :             /*lsf2lsp( lsf_q_rf, lsp_q_rf, M, st->sr_core );*/
     267           0 :             E_LPC_lsf_lsp_conversion( lsf_q_rf, lsp_q_rf, M );
     268             : 
     269             :             /* copy the old and current lsfs and lsps into the lsf[] and lsp[] buffer for interpolation  */
     270           0 :             Copy( st->lsf_old_fx, &lsf[0], M );
     271           0 :             Copy( st->lsp_old_fx, &lsp[0], M );
     272           0 :             Copy( lsf_q_rf, &lsf[M], M );
     273           0 :             Copy( lsp_q_rf, &lsp[M], M );
     274           0 :             lsp_diff = 0;
     275           0 :             move16();
     276           0 :             FOR( i = 0; i < M; i++ )
     277             :             {
     278           0 :                 lsp_diff = L_add( lsp_diff, (Word32) abs_s( sub( lsp[i + M], lsp[i] ) ) );
     279             :             }
     280             : 
     281           0 :             test();
     282           0 :             test();
     283           0 :             test();
     284           0 :             test();
     285           0 :             test();
     286           0 :             test();
     287           0 :             test();
     288           0 :             IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && LT_32( lsp_diff, 52428 ) && GT_32( lsp_diff, 3932 ) && EQ_16( st->next_coder_type, GENERIC ) && !st->prev_use_partial_copy && EQ_16( st->last_coder_type, UNVOICED ) && GE_16( st->rf_frame_type, RF_GENPRED ) )
     289             :             {
     290           0 :                 Copy( &lsp[0], &lsp[M], M );
     291             :             }
     292             : 
     293             :             /* update mem_MA and mem_AR memories  */
     294           0 :             lsf_update_memory( (Word16) st->narrowBand, &lsf[M], st->mem_MA_fx, st->mem_MA_fx, M );
     295           0 :             Copy( &lsf[M], st->mem_AR_fx, M );
     296             : 
     297           0 :             FOR( k = 0; k < st->numlpc; ++k )
     298             :             {
     299           0 :                 Copy( &lsp[( k + 1 ) * M], &xspnew_uw[k * M], M );
     300           0 :                 Copy( &lsf[( k + 1 ) * M], &xsfnew_uw[k * M], M );
     301             :             }
     302             :         }
     303        1248 :         ELSE IF( ( hTcxDec->enableTcxLpc != 0 && ( st->core != ACELP_CORE ) ) || ( bfi && st->use_partial_copy && EQ_16( st->rf_frame_type, RF_TCXFD ) ) )
     304           0 :         {
     305             :             Word16 tcx_lpc_cdk;
     306           0 :             test();
     307           0 :             test();
     308           0 :             IF( bfi && st->use_partial_copy && EQ_16( st->rf_frame_type, RF_TCXFD ) )
     309             :             {
     310           0 :                 tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC );
     311             :             }
     312             :             ELSE
     313             :             {
     314           0 :                 tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); /* inlined */
     315             :             }
     316             : 
     317           0 :             Copy( st->lsf_old_fx, &lsf[0], M );
     318           0 :             Copy( st->lsp_old_fx, &lsp[0], M );
     319             : 
     320           0 :             D_lsf_tcxlpc( param_lpc, &lsf[M], lspind, st->narrowBand, tcx_lpc_cdk, st->mem_MA_fx );
     321             : 
     322           0 :             E_LPC_lsf_lsp_conversion( &lsf[M], &lsp[M], M );
     323             : 
     324           0 :             lsf_update_memory( (Word16) st->narrowBand, &lsf[M], st->mem_MA_fx, st->mem_MA_fx, M );
     325           0 :             Copy( &lsf[M], st->mem_AR_fx, M );
     326             : 
     327           0 :             hTcxDec->envWeighted = 1;
     328           0 :             move16();
     329             : 
     330           0 :             E_LPC_lsp_unweight( &lsp[M], xspnew_uw, xsfnew_uw, st->inv_gamma, M );
     331             :         }
     332             :         ELSE
     333             :         {
     334             : 
     335        1248 :             IF( hTcxDec->envWeighted )
     336             :             {
     337           0 :                 Copy( st->lspold_uw, st->lsp_old_fx, M );
     338           0 :                 Copy( st->lsfold_uw, st->lsf_old_fx, M );
     339           0 :                 hTcxDec->envWeighted = 0;
     340           0 :                 move16();
     341             :             }
     342        1248 :             IF( EQ_16( st->core, TCX_20_CORE ) )
     343             :             {
     344         638 :                 lpc_unquantize_fx( st, lsf, lsp, M, param_lpc, lspmid, lsfmid, AUDIO, &LSF_Q_prediction );
     345             :             }
     346             :             ELSE
     347             :             {
     348         610 :                 lpc_unquantize_fx( st, lsf, lsp, M, param_lpc, lspmid, lsfmid, st->coder_type, &LSF_Q_prediction );
     349         610 :                 test();
     350         610 :                 test();
     351         610 :                 test();
     352         610 :                 test();
     353         610 :                 IF( EQ_16( st->prev_use_partial_copy, 1 ) && ( st->last_core == ACELP_CORE ) && ( st->core == ACELP_CORE ) && GE_16( st->prev_rf_frame_type, RF_GENPRED ) && EQ_16( st->coder_type, UNVOICED ) )
     354             :                 {
     355           0 :                     test();
     356           0 :                     IF( st->lpcQuantization && st->acelp_cfg.midLpc )
     357             :                     {
     358           0 :                         Copy( lspmid, &lsp[0], M );
     359           0 :                         Copy( &lsp[M], lspmid, M );
     360             :                     }
     361             :                 }
     362             :             }
     363             : 
     364        2496 :             FOR( k = 0; k < st->numlpc; ++k )
     365             :             {
     366        1248 :                 Copy( &lsp[( k + 1 ) * M], &xspnew_uw[k * M], M );
     367        1248 :                 Copy( &lsf[( k + 1 ) * M], &xsfnew_uw[k * M], M );
     368             :             }
     369             :         }
     370             : 
     371             :         /* PLC: [LPD: LPC concealment]
     372             :          * built the moving average for the LPC concealment */
     373             : 
     374        2496 :         FOR( k = 0; k < st->numlpc; k++ )
     375             :         {
     376       21216 :             FOR( i = 0; i < M; i++ )
     377             :             {
     378       19968 :                 move16();
     379       19968 :                 st->lsf_adaptive_mean_fx[i] = add( add( mult_r( st->lsfoldbfi1_fx[i], 10923 /*1.0f/3.0f Q15*/ ), mult_r( st->lsfoldbfi0_fx[i], 10923 /*1.0f/3.0f Q15*/ ) ), mult_r( xsfnew_uw[( k * M ) + i], 10923 /*1.0f/3.0f Q15*/ ) );
     380       19968 :                 move16();
     381       19968 :                 st->lsfoldbfi1_fx[i] = st->lsfoldbfi0_fx[i];
     382       19968 :                 move16();
     383       19968 :                 st->lsfoldbfi0_fx[i] = xsfnew_uw[( k * M ) + i];
     384             :             }
     385             :         }
     386             :     }
     387             :     ELSE
     388             :     {
     389             :         /* PLC: [LPD: LPC concealment]
     390             :          * Conceal the LPC from the lost frame */
     391           0 :         st->numlpc = 2;
     392           0 :         move16();
     393           0 :         test();
     394           0 :         if ( st->tcxonly == 0 || LT_16( st->core, TCX_10_CORE ) )
     395             :         {
     396           0 :             move16();
     397           0 :             st->numlpc = 1;
     398             :         }
     399           0 :         IF( EQ_16( st->nbLostCmpt, 1 ) )
     400             :         {
     401           0 :             Copy( st->lsf_old_fx, st->old_lsf_q_cng, M );
     402           0 :             Copy( st->lsp_old_fx, st->old_lsp_q_cng, M );
     403             :         }
     404           0 :         xsfBase = PlcGetLsfBase( st->lpcQuantization, (Word16) st->narrowBand, st->sr_core );
     405             : 
     406           0 :         dlpc_bfi( st->L_frame, xsfnew_uw, st->lsfold_uw, st->last_good, st->nbLostCmpt, st->mem_MA_fx, st->mem_AR_fx,
     407           0 :                   &( st->stab_fac_fx ), st->lsf_adaptive_mean_fx, st->numlpc, st->lsf_cng, (Word8) st->plcBackgroundNoiseUpdated, st->lsf_q_cng, st->old_lsf_q_cng, xsfBase, (Word8) st->tcxonly );
     408             : 
     409           0 :         hTcxDec->envWeighted = 0;
     410           0 :         move16();
     411             : 
     412           0 :         Copy( st->lspold_uw, lsp, M );
     413           0 :         Copy( st->lsfold_uw, lsf, M );
     414             : 
     415           0 :         FOR( k = 0; k < st->numlpc; k++ )
     416             :         {
     417           0 :             Copy( &xsfnew_uw[k * M], &lsf[( k + 1 ) * M], M );
     418             : 
     419           0 :             IF( st->tcxonly )
     420             :             {
     421           0 :                 E_LPC_lsf_lsp_conversion( &lsf[( k + 1 ) * M], &lsp[( k + 1 ) * M], M );
     422           0 :                 E_LPC_lsf_lsp_conversion( st->lsf_q_cng, st->lsp_q_cng, M );
     423             :             }
     424             :             ELSE
     425             :             {
     426           0 :                 lsf2lsp_fx( &lsf[( k + 1 ) * M], &lsp[( k + 1 ) * M], M, st->sr_core );
     427           0 :                 lsf2lsp_fx( st->lsf_q_cng, st->lsp_q_cng, M, st->sr_core );
     428             :             }
     429             : 
     430           0 :             Copy( &lsp[( k + 1 ) * M], &xspnew_uw[( k * M )], M );
     431             :         }
     432             :     }
     433             : 
     434             :     /*--------------------------------------------------------------*
     435             :      * Rate switching
     436             :      *---------------------------------------------------------------*/
     437        1248 :     IF( st->rate_switching_reset != 0 )
     438             :     {
     439          18 :         Copy( &( lsf[M] ), &( lsf[0] ), M );
     440          18 :         Copy( &( lsp[M] ), &( lsp[0] ), M );
     441          18 :         Copy( &( lsf[M] ), st->lsf_old_fx, M );
     442          18 :         Copy( &( lsp[M] ), st->lsp_old_fx, M );
     443          18 :         Copy( &( lsf[M] ), lsfmid, M );
     444          18 :         Copy( &( lsp[M] ), lspmid, M );
     445          18 :         E_LPC_f_lsp_a_conversion( st->lsp_old_fx, st->old_Aq_12_8_fx, M );
     446             :     }
     447             : 
     448             : 
     449        1248 :     IF( st->enablePlcWaveadjust )
     450             :     {
     451           0 :         if ( st->core == ACELP_CORE )
     452             :         {
     453           0 :             st->tonality_flag = 0;
     454           0 :             move16();
     455             :         }
     456           0 :         if ( bfi )
     457             :         {
     458           0 :             st->hPlcInfo->nbLostCmpt = add( st->hPlcInfo->nbLostCmpt, 1 );
     459           0 :             move16();
     460             :         }
     461             :     }
     462             : 
     463             :     /*--------------------------------------------------------------------------------*
     464             :      * ACELP
     465             :      *--------------------------------------------------------------------------------*/
     466        1248 :     test();
     467        1248 :     test();
     468        1248 :     test();
     469        1248 :     IF( ( st->prev_bfi != 0 ) && ( bfi == 0 ) && ( EQ_16( st->coder_type, VOICED ) ) && GT_16( st->prev_nbLostCmpt, 4 ) )
     470             :     {
     471           0 :         st->dec_glr_idx = 1;
     472           0 :         move16();
     473           0 :         st->reset_mem_AR = 1;
     474           0 :         move16();
     475             :     }
     476             : 
     477        1248 :     IF( st->core == ACELP_CORE )
     478             :     {
     479         610 :         IF( st->tcxonly == 0 )
     480             :         {
     481             :             /* Set pointer to parameters */
     482         610 :             prm = param;
     483             : 
     484             :             /* Stability Factor */
     485         610 :             IF( bfi == 0 )
     486             :             {
     487         610 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[M], &lsf[0], 0, st->L_frame );
     488         610 :                 move16();
     489             :             }
     490             : 
     491         610 :             test();
     492         610 :             IF( bfi == 0 && st->prev_bfi != 0 )
     493             :             {
     494             :                 /* check if LSP interpolation can be relaxed or if LPC power can be diffused*/
     495           0 :                 E_LPC_f_lsp_a_conversion( &lsp[0], tmp_old, M );
     496           0 :                 enr_old = Enr_1_Az_fx( tmp_old, 2 * L_SUBFR );
     497             : 
     498           0 :                 E_LPC_f_lsp_a_conversion( &lsp[M], tmp_new, M );
     499           0 :                 enr_new = Enr_1_Az_fx( tmp_new, 2 * L_SUBFR );
     500             :             }
     501             : 
     502         610 :             test();
     503         610 :             test();
     504         610 :             test();
     505         610 :             test();
     506         610 :             test();
     507         610 :             IF( ( bfi == 0 ) && ( ( EQ_16( st->dec_glr_idx, 1 ) ) || ( ( st->safety_net == 0 ) && ( shr( enr_new, 11 ) > 0 ) && ( GT_16( shr( enr_new, 1 ), enr_old ) ) ) ) && ( st->prev_bfi != 0 ) )
     508           0 :             {
     509           0 :                 Word16 reset_q = 0;
     510           0 :                 move16();
     511           0 :                 if ( EQ_16( st->dec_glr_idx, 1 ) )
     512             :                 {
     513           0 :                     reset_q = 1;
     514           0 :                     move16();
     515             :                 }
     516           0 :                 RecLpcSpecPowDiffuseLc( &lsp[M], &lsp[0], &lsf[M], st, reset_q );
     517             : 
     518           0 :                 int_lsp_fx( L_frame, &lsp[0], &lsp[M], Aq, M, interpol_frac_fx, 0 );
     519             : 
     520           0 :                 Copy( &lsf[M], xsfnew_uw, M );
     521             :             }
     522             :             ELSE
     523             :             {
     524             :                 /* LPC Interpolation for ACELP */
     525         610 :                 test();
     526         610 :                 IF( bfi == 0 && st->acelp_cfg.midLpc )
     527             :                 {
     528         342 :                     st->relax_prev_lsf_interp = 0;
     529         342 :                     move16();
     530         342 :                     IF( st->prev_bfi )
     531             :                     {
     532             :                         /* check if LSP interpolation can be relaxed */
     533           0 :                         IF( LT_16( enr_new, shr( enr_old, 2 ) ) )
     534             :                         {
     535           0 :                             st->relax_prev_lsf_interp = -1;
     536           0 :                             move16();
     537           0 :                             test();
     538           0 :                             test();
     539           0 :                             test();
     540           0 :                             test();
     541           0 :                             if ( ( st->clas_dec == UNVOICED_CLAS ) || EQ_16( st->clas_dec, SIN_ONSET ) || EQ_16( st->clas_dec, INACTIVE_CLAS ) || EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) )
     542             :                             {
     543           0 :                                 st->relax_prev_lsf_interp = 1;
     544           0 :                                 move16();
     545             :                             }
     546             :                         }
     547             :                     }
     548             : 
     549         342 :                     test();
     550         342 :                     test();
     551         342 :                     test();
     552         342 :                     test();
     553         342 :                     if ( st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && st->relax_prev_lsf_interp == 0 )
     554             :                     {
     555           0 :                         st->relax_prev_lsf_interp = 2;
     556           0 :                         move16();
     557             :                     }
     558             : 
     559             : #ifdef REMOVE_EVS_DUPLICATES
     560         342 :                     int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
     561             : #else
     562             :                     int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
     563             : #endif
     564             :                 }
     565             :                 ELSE
     566             :                 {
     567         268 :                     int_lsp_fx( L_frame, &lsp[0], &lsp[M], Aq, M, interpol_frac_fx, 0 );
     568         268 :                     int_lsp_fx( L_frame, st->old_lsp_q_cng, st->lsp_q_cng, st->Aq_cng, M, interpol_frac_fx, 0 );
     569             :                 }
     570             :             }
     571             :         }
     572             : 
     573         610 :         test();
     574         610 :         IF( bfi != 0 && ( st->last_core != ACELP_CORE ) )
     575             :         {
     576             :             /* PLC: [TCX: TD PLC] */
     577           0 :             con_tcx_fx( st, &synthFB[0] );
     578           0 :             lerp( synthFB, synth, st->L_frame, hTcxDec->L_frameTCX );
     579           0 :             st->con_tcx = 1;
     580           0 :             move16();
     581           0 :             set16_fx( st->mem_pitch_gain + 2, round_fx( L_shl( st->Mode2_lp_gainp, 1 ) ), st->nb_subfr );
     582             :         }
     583             :         ELSE
     584             :         {
     585             :             /* ACELP decoder */
     586         610 :             IF( hBWE_TD != NULL )
     587             :             {
     588         610 :                 IF( EQ_16( st->L_frame, L_FRAME ) )
     589             :                 {
     590           0 :                     Copy( Aq + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
     591             :                 }
     592             :                 ELSE
     593             :                 {
     594         610 :                     Copy( Aq + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
     595             :                 }
     596             :             }
     597         610 :             IF( bfi != 0 )
     598             :             {
     599             :                 /* PLC: [ACELP: general]
     600             :                  * PLC: Use the ACELP like concealment */
     601           0 :                 con_acelp_fx( Aq, st->core_ext_mode, &synth[0], pitch, pit_gain, st->stab_fac_fx, st,
     602           0 :                               &st->Q_exc, &st->Q_syn, /*Q format of st->mem_syn*/ pitch_buf, voice_factors, ptr_bwe_exc );
     603             : 
     604           0 :                 Copy( &st->mem_pitch_gain[2], &st->mem_pitch_gain[st->nb_subfr + 2], st->nb_subfr );
     605           0 :                 set16_fx( &st->mem_pitch_gain[2], 0, st->nb_subfr );
     606             :             }
     607             :             ELSE
     608             :             {
     609         610 :                 decoder_acelp_fx( st, prm, Aq, st->acelp_cfg, &synth[0], pitch, pit_gain, st->stab_fac_fx, pitch_buf, voice_factors, LSF_Q_prediction, ptr_bwe_exc );
     610             : 
     611         610 :                 IF( st->flagGuidedAcelp > 0 )
     612             :                 {
     613         306 :                     st->guidedT0 = s_max( s_min( add( st->T0_4th, st->guidedT0 ), NBPSF_PIT_MAX ), PIT_MIN_16k );
     614         306 :                     move16();
     615             :                 }
     616             : 
     617        3660 :                 FOR( i = 0; i < st->nb_subfr; i++ )
     618             :                 {
     619        3050 :                     move16();
     620        3050 :                     move16();
     621        3050 :                     st->mem_pitch_gain[2 + ( 2 * st->nb_subfr - 1 ) - i] = st->mem_pitch_gain[( ( 2 + ( st->nb_subfr - 1 ) ) - i )];
     622        3050 :                     st->mem_pitch_gain[2 + ( st->nb_subfr - 1 ) - i] = pit_gain[i];
     623             :                 }
     624             :             }
     625             :         }
     626             : 
     627             : 
     628             :         /* LPC for ACELP/BBWE */
     629         610 :         test();
     630         610 :         test();
     631         610 :         IF( st->narrowBand || ( EQ_32( st->sr_core, INT_FS_12k8 ) ) || ( EQ_32( st->sr_core, INT_FS_16k ) ) )
     632             :         {
     633         610 :             Copy( Aq, st->mem_Aq, nb_subfr * ( M + 1 ) );
     634             :         }
     635             : 
     636             :         /* PLC: [TCX: Tonal Concealment] */
     637             :         /* Signal that this frame is not TCX */
     638         610 :         TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, 0, 0, 0, 0 );
     639             : 
     640         610 :         IF( bfi == 0 )
     641             :         {
     642         610 :             st->second_last_tns_active = st->last_tns_active;
     643         610 :             move16();
     644         610 :             st->last_tns_active = 0;
     645         610 :             move16();
     646         610 :             hTcxDec->tcxltp_last_gain_unmodified = 0;
     647         610 :             move16();
     648             :         }
     649             :     }
     650             : 
     651             : 
     652             :     /*--------------------------------------------------------------------------------*
     653             :      * TCX20
     654             :      *--------------------------------------------------------------------------------*/
     655             : 
     656        1248 :     IF( EQ_16( st->core, TCX_20_CORE ) )
     657             :     {
     658             :         /* Set pointer to parameters */
     659         638 :         prm = param;
     660             : 
     661             :         /* Stability Factor */
     662         638 :         IF( bfi == 0 )
     663             :         {
     664         638 :             IF( st->tcxonly != 0 )
     665             :             {
     666           0 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[M], &lsf[0], 0, L_FRAME );
     667           0 :                 move16();
     668             :             }
     669             :             ELSE
     670             :             {
     671         638 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[M], &lsf[0], 0, st->L_frame );
     672         638 :                 move16();
     673             :             }
     674             :         }
     675             : 
     676         638 :         IF( hTcxDec->enableTcxLpc )
     677             :         {
     678             :             /* Convert quantized xSP to A */
     679           0 :             E_LPC_f_lsp_a_conversion( &lsp[M], Aq, M );
     680             :         }
     681             :         ELSE
     682             :         {
     683         638 :             IF( st->tcxonly == 0 )
     684             :             {
     685         638 :                 test();
     686         638 :                 test();
     687         638 :                 test();
     688         638 :                 IF( ( bfi == 0 ) && ( st->prev_bfi != 0 ) && ( st->safety_net == 0 ) && ( st->rate_switching_reset != 0 ) )
     689             :                 {
     690             :                     /* diffuse LPC power on rate switching*/
     691           0 :                     RecLpcSpecPowDiffuseLc( &lsp[M], &lsp[0], &lsf[M], st, 0 );
     692           0 :                     int_lsp_fx( L_frame, &lsp[0], &lsp[M], Aq, M, interpol_frac_fx, 0 );
     693           0 :                     Copy( &lsf[M], xsfnew_uw, M );
     694             :                 }
     695             :                 ELSE
     696             :                 {
     697             :                     /* LPC Interpolation for TCX */
     698         638 :                     E_LPC_int_lpc_tcx( &lsp[0], &lsp[M], Aq );
     699             :                 }
     700             :             }
     701             :             ELSE
     702             :             {
     703           0 :                 E_LPC_f_lsp_a_conversion( &lsp[M], Aq, M );
     704             :             }
     705             :         }
     706             : 
     707         638 :         test();
     708         638 :         IF( bfi == 0 && hTcxDec->tcx_lpc_shaped_ari != 0 )
     709             :         {
     710           0 :             E_LPC_f_lsp_a_conversion( lspind, Aind, M );
     711             :         }
     712             :         /* TCX decoder */
     713         638 :         decoder_tcx_fx( st->hTcxCfg, prm, Aq, Aind, L_frame, L_frameTCX, st->hTcxCfg->tcx_coded_lines, &synth[0], &synthFB[0], st, st->coder_type, bfi, 0, st->stab_fac_fx );
     714             :     }
     715             : 
     716             :     /*--------------------------------------------------------------------------------*
     717             :      * TCX10
     718             :      *--------------------------------------------------------------------------------*/
     719             : 
     720        1248 :     IF( EQ_16( st->core, TCX_10_CORE ) )
     721             :     {
     722           0 :         FOR( k = 0; k < 2; k++ )
     723             :         {
     724             : 
     725             :             /* Set pointer to parameters */
     726           0 :             prm = param + ( k * DEC_NPRM_DIV );
     727             : 
     728             :             /* Stability Factor */
     729           0 :             IF( bfi == 0 )
     730             :             {
     731           0 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[( ( k + 1 ) ) * M], &lsf[k * M], 0, L_FRAME );
     732           0 :                 move16();
     733             :             }
     734             : 
     735           0 :             E_LPC_f_lsp_a_conversion( &lsp[( ( k + 1 ) ) * M], Aq, M );
     736             : 
     737             :             /* TCX decoder */
     738             : 
     739           0 :             IGFDecRestoreTCX10SubFrameData( st->hIGFDec, k );
     740           0 :             decoder_tcx_fx( st->hTcxCfg, prm, Aq, Aind, shr( L_frame, 1 ), shr( L_frameTCX, 1 ),
     741           0 :                             shr( st->hTcxCfg->tcx_coded_lines, 1 ), &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], st, st->coder_type, bfi, k, st->stab_fac_fx );
     742             :         }
     743             :     }
     744             : 
     745             : 
     746        1248 :     test();
     747        1248 :     IF( EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, TCX_20_CORE ) )
     748             :     {
     749         638 :         test();
     750         638 :         test();
     751         638 :         IF( st->enablePlcWaveadjust ||                 /* bfi      */
     752             :             ( GE_32( st->last_total_brate, HQ_48k ) && /* recovery */
     753             :               EQ_16( st->last_codec_mode, MODE2 ) ) )
     754             :         {
     755             :             /* waveform adjustment */
     756           0 :             concealment_signal_tuning_fx( st, bfi, synthFB, past_core_mode );
     757             : 
     758           0 :             test();
     759           0 :             test();
     760           0 :             test();
     761           0 :             IF( ( bfi || st->prev_bfi ) && st->hPlcInfo->Pitch_fx && ( ( st->hPlcInfo->concealment_method == TCX_NONTONAL ) ) )
     762             :             {
     763           0 :                 lerp( synthFB, synth, L_frame, L_frameTCX );
     764           0 :                 test();
     765           0 :                 if ( !bfi && st->prev_bfi )
     766             :                 {
     767           0 :                     st->hPlcInfo->Pitch_fx = 0;
     768           0 :                     move16();
     769             :                 }
     770             :             }
     771             :         }
     772             : 
     773         638 :         IF( !bfi )
     774             :         {
     775         638 :             TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX );
     776             :         }
     777         638 :         decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi );
     778         638 :         IF( EQ_16( st->core, TCX_20_CORE ) )
     779             :         {
     780             :             /* LPC Interpolation for BWE/post-processing */
     781         638 :             test();
     782         638 :             test();
     783         638 :             IF( st->narrowBand || ( EQ_32( st->sr_core, INT_FS_12k8 ) ) || ( EQ_32( st->sr_core, INT_FS_16k ) ) )
     784             :             {
     785         638 :                 int_lsp_fx( L_frame, st->lspold_uw, xspnew_uw, Aq, M, interpol_frac_fx, 0 );
     786         638 :                 Copy( Aq, st->mem_Aq, imult1616( nb_subfr, ( M + 1 ) ) );
     787             :             }
     788             :         }
     789             :     }
     790             : 
     791             :     /* PLC: [Common: Classification] */
     792             : 
     793        1248 :     IF( LE_32( st->sr_core, INT_FS_16k ) )
     794             :     {
     795        1248 :         test();
     796        1248 :         test();
     797        1248 :         test();
     798        1248 :         IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || ( st->tcxonly && st->bfi ) )
     799             :         {
     800             :             Word16 pitch_C[NB_SUBFR16k];
     801             :             Word16 core_ext_mode, LTP_Gain;
     802             : 
     803         638 :             set16_fx( pitch_C, shl( round_fx( st->old_fpitch ), 6 ), NB_SUBFR16k );
     804             : 
     805         638 :             core_ext_mode = GENERIC;
     806         638 :             move16();
     807         638 :             if ( st->tcxonly == 0 )
     808             :             {
     809         638 :                 core_ext_mode = st->core_ext_mode;
     810         638 :                 move16();
     811             :             }
     812             : 
     813         638 :             LTP_Gain = -32768 /*-1.0f Q15*/;
     814         638 :             move16();
     815         638 :             if ( hTcxLtpDec->tcxltp )
     816             :             {
     817         638 :                 LTP_Gain = hTcxDec->tcxltp_last_gain_unmodified;
     818         638 :                 move16();
     819             :             }
     820             : 
     821             : 
     822         638 :             FEC_clas_estim_fx(
     823             :                 st,
     824             :                 /*Opt_AMR_WB*/ 0, /*A*/
     825         638 :                 st->L_frame,
     826             :                 &( st->clas_dec ),
     827             :                 core_ext_mode,
     828             :                 pitch_C,
     829             :                 synth,
     830             :                 &st->lp_ener_FER_fx,
     831             :                 /**decision_hyst*/ NULL,   /* i/o: hysteresis of the music/speech decision          */
     832             :                 /**UV_cnt*/ NULL,          /* i/o: number of consecutive frames classified as       */
     833             :                 /**LT_UV_cnt*/ NULL,       /* i/o: long term consecutive frames classified as UV    */
     834             :                 /**Last_ener*/ NULL,       /* i/o: last_energy frame                                */
     835             :                 /**locattack*/ NULL,       /* i/o: detection of attack (mainly to localized speech burst) */
     836             :                 /**lt_diff_etot*/ NULL,    /* i/o: long-term total energy variation                 */
     837             :                 /**amr_io_class*/ NULL,    /* i/o: classification for AMR-WB IO mode                */
     838             :                 0,                         /* i  : Synthesis scaling                                */
     839             :                 /**class_para*/ NULL,      /* o  : classification para. fmerit1                     */
     840         638 :                 st->mem_syn_clas_estim_fx, /* i/o: memory of the synthesis signal for frame class estimation */
     841             :                 &st->classifier_Q_mem_syn, /* i/o: exponent for memory of synthesis signal for frame class estimation */
     842             :                 LTP_Gain,                  /* i  : means LTP Gain                                   */
     843             :                 1 /*CLASSIFIER_TCX*/,      /* i  : signal classifier mode                           */
     844             :                 bfi,                       /* i  : bad frame indicator                              */
     845             :                 st->last_core_brate,       /* i  : bitrate of previous frame                        */
     846             :                 -1 );
     847             :         }
     848             :     }
     849             : 
     850             :     /*--------------------------------------------------------------------------------*
     851             :      * Updates
     852             :      *--------------------------------------------------------------------------------*/
     853             : 
     854        1248 :     test();
     855        1248 :     IF( bfi && st->last_core_bfi != ACELP_CORE )
     856             :     {
     857             :         /* Update FEC_scale_syn parameters */
     858           0 :         IF( hTcxLtpDec->tcxltp_gain == 0 )
     859             :         {
     860           0 :             frame_ener_fx( L_frame, UNVOICED_CLAS, synth, shr( L_frame, 1 ), &st->enr_old_fx, L_frame, 0, 0, 0 );
     861             :         }
     862             :         ELSE
     863             :         {
     864             :             Word16 pitch_Q0;
     865           0 :             pitch_Q0 = round_fx( st->old_fpitch );
     866           0 :             frame_ener_fx( L_frame, st->clas_dec, synth, pitch_Q0, &st->enr_old_fx, L_frame, 0, 0, 0 );
     867             :         }
     868             :     }
     869             : 
     870             : 
     871        1248 :     test();
     872        1248 :     test();
     873        1248 :     IF( !bfi && GE_16( st->clas_dec, VOICED_TRANSITION ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
     874             :     {
     875             :         Word16 offset;
     876             : 
     877         967 :         IF( EQ_16( st->core, ACELP_CORE ) )
     878             :         {
     879         489 :             offset = sub( st->nb_subfr, 1 );
     880         489 :             offset = imult1616( offset, add( M, 1 ) );
     881             :         }
     882             :         ELSE
     883             :         {
     884         478 :             offset = 0;
     885         478 :             move16();
     886             :         }
     887             :         /* use latest LPC set */
     888         967 :         st->old_enr_LP = Enr_1_Az_fx( Aq + offset, L_SUBFR ); /*Q3*/
     889         967 :         move16();
     890             :     }
     891             : 
     892             : 
     893             :     /* Update */
     894        1248 :     Copy( synth_buf + L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len );
     895             : 
     896        1248 :     Copy( hTcxDec->old_synthFB_fx + L_frameTCX - NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ), hTcxDec->synth_history_fx, NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) );
     897        1248 :     Copy( synth_bufFB + L_frameTCX, hTcxDec->old_synthFB_fx, hTcxDec->old_synth_lenFB );
     898        1248 :     Copy_Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + hTcxDec->old_synth_lenFB, NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( st->hHQ_core->Q_old_wtda ) );
     899             : 
     900        1248 :     Copy( &xspnew_uw[imult1616( sub( st->numlpc, 1 ), M )], st->lspold_uw, M );
     901        1248 :     Copy( &xsfnew_uw[imult1616( sub( st->numlpc, 1 ), M )], st->lsfold_uw, M );
     902             : 
     903        1248 :     IF( bfi )
     904             :     {
     905           0 :         Copy( st->lspold_uw, st->lsp_old_fx, M ); /* for recovery */
     906           0 :         Copy( st->lsfold_uw, st->lsf_old_fx, M ); /* for recovery */
     907             :     }
     908             :     ELSE
     909             :     {
     910        1248 :         Copy( &lsp[st->numlpc * M], st->lsp_old_fx, M );
     911        1248 :         Copy( &lsf[st->numlpc * M], st->lsf_old_fx, M );
     912             :     }
     913        1248 :     Copy( st->lsp_q_cng, st->old_lsp_q_cng, M );
     914        1248 :     Copy( st->lsf_q_cng, st->old_lsf_q_cng, M );
     915             : 
     916             :     /* Update LP_CNG parameters */
     917        1248 :     test();
     918        1248 :     IF( st->tcxonly == 0 && st->hTdCngDec != NULL )
     919             :     {
     920             :         /* update CNG parameters in active frames */
     921        1248 :         test();
     922        1248 :         test();
     923        1248 :         IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc != 0 && st->core != ACELP_CORE )
     924           0 :         {
     925             :             Word16 buf[L_LP], res[L_FRAME], A[M + 1], Qexc, r_l[M + 1], r_h[M + 1], lsptmp[M], Q_r, tmp;
     926             : 
     927           0 :             assert( st->L_frame == L_FRAME );
     928           0 :             Copy( synth + L_FRAME - L_LP, buf, L_LP );
     929           0 :             tmp = synth[L_FRAME - L_LP - 1];
     930           0 :             move16();
     931           0 :             Qexc = E_UTIL_f_preemph3( buf, st->preemph_fac, L_LP, &tmp, 1 );
     932           0 :             autocorr_fx( buf, M, r_h, r_l, &Q_r, L_LP, Assym_window_W16fx, 0, 0 );
     933           0 :             lag_wind( r_h, r_l, M, INT_FS_FX, LAGW_WEAK );
     934           0 :             E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL );
     935           0 :             E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M );
     936           0 :             Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 );
     937           0 :             cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr,
     938           0 :                                st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
     939           0 :                                Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
     940             :         }
     941             :         ELSE
     942             :         {
     943        1248 :             cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame,
     944        1248 :                                st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx,
     945        1248 :                                &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC,
     946        1248 :                                st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
     947             :         }
     948             : 
     949             :         /* Set 16k LSP flag for CNG buffer */
     950        1248 :         st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
     951        1248 :         move16();
     952        1248 :         IF( EQ_16( st->L_frame, L_FRAME ) )
     953             :         {
     954         264 :             st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
     955         264 :             move16();
     956             :         }
     957             :     }
     958             : 
     959        1248 :     move16();
     960        1248 :     st->last_is_cng = 0;
     961             : 
     962             :     /* Postfiltering */
     963        1248 :     post_decoder( st, synth_buf, pit_gain, pitch, signal_out, bpf_noise_buf );
     964             : 
     965        1248 :     IF( signal_outFB )
     966             :     {
     967        1248 :         Copy( synthFB, signal_outFB, L_frameTCX );
     968             :     }
     969             : 
     970        1248 :     IF( st->enablePlcWaveadjust )
     971             :     {
     972           0 :         if ( !bfi )
     973             :         {
     974           0 :             st->hPlcInfo->nbLostCmpt = 0;
     975           0 :             move16();
     976             :         }
     977             : 
     978           0 :         IF( st->core == 0 )
     979             :         {
     980           0 :             set_state( st->hPlcInfo->Transient, st->core, MAX_POST_LEN );
     981             :         }
     982             :     }
     983             : 
     984             : 
     985        1248 :     return;
     986             : }

Generated by: LCOV version 1.14