LCOV - code coverage report
Current view: top level - lib_dec - dec_LPD_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 4c82f1d24d39d0296b18d775f18a006f4c7d024b Lines: 249 465 53.5 %
Date: 2025-05-17 01:59:02 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         342 :                     int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
     560             :                 }
     561             :                 ELSE
     562             :                 {
     563         268 :                     int_lsp_fx( L_frame, &lsp[0], &lsp[M], Aq, M, interpol_frac_fx, 0 );
     564         268 :                     int_lsp_fx( L_frame, st->old_lsp_q_cng, st->lsp_q_cng, st->Aq_cng, M, interpol_frac_fx, 0 );
     565             :                 }
     566             :             }
     567             :         }
     568             : 
     569         610 :         test();
     570         610 :         IF( bfi != 0 && ( st->last_core != ACELP_CORE ) )
     571             :         {
     572             :             /* PLC: [TCX: TD PLC] */
     573           0 :             con_tcx_fx( st, &synthFB[0] );
     574           0 :             lerp( synthFB, synth, st->L_frame, hTcxDec->L_frameTCX );
     575           0 :             st->con_tcx = 1;
     576           0 :             move16();
     577           0 :             set16_fx( st->mem_pitch_gain + 2, round_fx( L_shl( st->Mode2_lp_gainp, 1 ) ), st->nb_subfr );
     578             :         }
     579             :         ELSE
     580             :         {
     581             :             /* ACELP decoder */
     582         610 :             IF( hBWE_TD != NULL )
     583             :             {
     584         610 :                 IF( EQ_16( st->L_frame, L_FRAME ) )
     585             :                 {
     586           0 :                     Copy( Aq + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
     587             :                 }
     588             :                 ELSE
     589             :                 {
     590         610 :                     Copy( Aq + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
     591             :                 }
     592             :             }
     593         610 :             IF( bfi != 0 )
     594             :             {
     595             :                 /* PLC: [ACELP: general]
     596             :                  * PLC: Use the ACELP like concealment */
     597           0 :                 con_acelp_fx( Aq, st->core_ext_mode, &synth[0], pitch, pit_gain, st->stab_fac_fx, st,
     598           0 :                               &st->Q_exc, &st->Q_syn, /*Q format of st->mem_syn*/ pitch_buf, voice_factors, ptr_bwe_exc );
     599             : 
     600           0 :                 Copy( &st->mem_pitch_gain[2], &st->mem_pitch_gain[st->nb_subfr + 2], st->nb_subfr );
     601           0 :                 set16_fx( &st->mem_pitch_gain[2], 0, st->nb_subfr );
     602             :             }
     603             :             ELSE
     604             :             {
     605         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 );
     606             : 
     607         610 :                 IF( st->flagGuidedAcelp > 0 )
     608             :                 {
     609         306 :                     st->guidedT0 = s_max( s_min( add( st->T0_4th, st->guidedT0 ), NBPSF_PIT_MAX ), PIT_MIN_16k );
     610         306 :                     move16();
     611             :                 }
     612             : 
     613        3660 :                 FOR( i = 0; i < st->nb_subfr; i++ )
     614             :                 {
     615        3050 :                     move16();
     616        3050 :                     move16();
     617        3050 :                     st->mem_pitch_gain[2 + ( 2 * st->nb_subfr - 1 ) - i] = st->mem_pitch_gain[( ( 2 + ( st->nb_subfr - 1 ) ) - i )];
     618        3050 :                     st->mem_pitch_gain[2 + ( st->nb_subfr - 1 ) - i] = pit_gain[i];
     619             :                 }
     620             :             }
     621             :         }
     622             : 
     623             : 
     624             :         /* LPC for ACELP/BBWE */
     625         610 :         test();
     626         610 :         test();
     627         610 :         IF( st->narrowBand || ( EQ_32( st->sr_core, INT_FS_12k8 ) ) || ( EQ_32( st->sr_core, INT_FS_16k ) ) )
     628             :         {
     629         610 :             Copy( Aq, st->mem_Aq, nb_subfr * ( M + 1 ) );
     630             :         }
     631             : 
     632             :         /* PLC: [TCX: Tonal Concealment] */
     633             :         /* Signal that this frame is not TCX */
     634         610 :         TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, 0, 0, 0, 0 );
     635             : 
     636         610 :         IF( bfi == 0 )
     637             :         {
     638         610 :             st->second_last_tns_active = st->last_tns_active;
     639         610 :             move16();
     640         610 :             st->last_tns_active = 0;
     641         610 :             move16();
     642         610 :             hTcxDec->tcxltp_last_gain_unmodified = 0;
     643         610 :             move16();
     644             :         }
     645             :     }
     646             : 
     647             : 
     648             :     /*--------------------------------------------------------------------------------*
     649             :      * TCX20
     650             :      *--------------------------------------------------------------------------------*/
     651             : 
     652        1248 :     IF( EQ_16( st->core, TCX_20_CORE ) )
     653             :     {
     654             :         /* Set pointer to parameters */
     655         638 :         prm = param;
     656             : 
     657             :         /* Stability Factor */
     658         638 :         IF( bfi == 0 )
     659             :         {
     660         638 :             IF( st->tcxonly != 0 )
     661             :             {
     662           0 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[M], &lsf[0], 0, L_FRAME );
     663           0 :                 move16();
     664             :             }
     665             :             ELSE
     666             :             {
     667         638 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[M], &lsf[0], 0, st->L_frame );
     668         638 :                 move16();
     669             :             }
     670             :         }
     671             : 
     672         638 :         IF( hTcxDec->enableTcxLpc )
     673             :         {
     674             :             /* Convert quantized xSP to A */
     675           0 :             E_LPC_f_lsp_a_conversion( &lsp[M], Aq, M );
     676             :         }
     677             :         ELSE
     678             :         {
     679         638 :             IF( st->tcxonly == 0 )
     680             :             {
     681         638 :                 test();
     682         638 :                 test();
     683         638 :                 test();
     684         638 :                 IF( ( bfi == 0 ) && ( st->prev_bfi != 0 ) && ( st->safety_net == 0 ) && ( st->rate_switching_reset != 0 ) )
     685             :                 {
     686             :                     /* diffuse LPC power on rate switching*/
     687           0 :                     RecLpcSpecPowDiffuseLc( &lsp[M], &lsp[0], &lsf[M], st, 0 );
     688           0 :                     int_lsp_fx( L_frame, &lsp[0], &lsp[M], Aq, M, interpol_frac_fx, 0 );
     689           0 :                     Copy( &lsf[M], xsfnew_uw, M );
     690             :                 }
     691             :                 ELSE
     692             :                 {
     693             :                     /* LPC Interpolation for TCX */
     694         638 :                     E_LPC_int_lpc_tcx( &lsp[0], &lsp[M], Aq );
     695             :                 }
     696             :             }
     697             :             ELSE
     698             :             {
     699           0 :                 E_LPC_f_lsp_a_conversion( &lsp[M], Aq, M );
     700             :             }
     701             :         }
     702             : 
     703         638 :         test();
     704         638 :         IF( bfi == 0 && hTcxDec->tcx_lpc_shaped_ari != 0 )
     705             :         {
     706           0 :             E_LPC_f_lsp_a_conversion( lspind, Aind, M );
     707             :         }
     708             :         /* TCX decoder */
     709         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 );
     710             :     }
     711             : 
     712             :     /*--------------------------------------------------------------------------------*
     713             :      * TCX10
     714             :      *--------------------------------------------------------------------------------*/
     715             : 
     716        1248 :     IF( EQ_16( st->core, TCX_10_CORE ) )
     717             :     {
     718           0 :         FOR( k = 0; k < 2; k++ )
     719             :         {
     720             : 
     721             :             /* Set pointer to parameters */
     722           0 :             prm = param + ( k * DEC_NPRM_DIV );
     723             : 
     724             :             /* Stability Factor */
     725           0 :             IF( bfi == 0 )
     726             :             {
     727           0 :                 st->stab_fac_fx = lsf_stab_fx( &lsf[( ( k + 1 ) ) * M], &lsf[k * M], 0, L_FRAME );
     728           0 :                 move16();
     729             :             }
     730             : 
     731           0 :             E_LPC_f_lsp_a_conversion( &lsp[( ( k + 1 ) ) * M], Aq, M );
     732             : 
     733             :             /* TCX decoder */
     734             : 
     735           0 :             IGFDecRestoreTCX10SubFrameData( st->hIGFDec, k );
     736           0 :             decoder_tcx_fx( st->hTcxCfg, prm, Aq, Aind, shr( L_frame, 1 ), shr( L_frameTCX, 1 ),
     737           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 );
     738             :         }
     739             :     }
     740             : 
     741             : 
     742        1248 :     test();
     743        1248 :     IF( EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, TCX_20_CORE ) )
     744             :     {
     745         638 :         test();
     746         638 :         test();
     747         638 :         IF( st->enablePlcWaveadjust ||                 /* bfi      */
     748             :             ( GE_32( st->last_total_brate, HQ_48k ) && /* recovery */
     749             :               EQ_16( st->last_codec_mode, MODE2 ) ) )
     750             :         {
     751             :             /* waveform adjustment */
     752           0 :             concealment_signal_tuning_fx( st, bfi, synthFB, past_core_mode );
     753             : 
     754           0 :             test();
     755           0 :             test();
     756           0 :             test();
     757           0 :             IF( ( bfi || st->prev_bfi ) && st->hPlcInfo->Pitch_fx && ( ( st->hPlcInfo->concealment_method == TCX_NONTONAL ) ) )
     758             :             {
     759           0 :                 lerp( synthFB, synth, L_frame, L_frameTCX );
     760           0 :                 test();
     761           0 :                 if ( !bfi && st->prev_bfi )
     762             :                 {
     763           0 :                     st->hPlcInfo->Pitch_fx = 0;
     764           0 :                     move16();
     765             :                 }
     766             :             }
     767             :         }
     768             : 
     769         638 :         IF( !bfi )
     770             :         {
     771         638 :             TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX );
     772             :         }
     773         638 :         decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi );
     774         638 :         IF( EQ_16( st->core, TCX_20_CORE ) )
     775             :         {
     776             :             /* LPC Interpolation for BWE/post-processing */
     777         638 :             test();
     778         638 :             test();
     779         638 :             IF( st->narrowBand || ( EQ_32( st->sr_core, INT_FS_12k8 ) ) || ( EQ_32( st->sr_core, INT_FS_16k ) ) )
     780             :             {
     781         638 :                 int_lsp_fx( L_frame, st->lspold_uw, xspnew_uw, Aq, M, interpol_frac_fx, 0 );
     782         638 :                 Copy( Aq, st->mem_Aq, imult1616( nb_subfr, ( M + 1 ) ) );
     783             :             }
     784             :         }
     785             :     }
     786             : 
     787             :     /* PLC: [Common: Classification] */
     788             : 
     789        1248 :     IF( LE_32( st->sr_core, INT_FS_16k ) )
     790             :     {
     791        1248 :         test();
     792        1248 :         test();
     793        1248 :         test();
     794        1248 :         IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || ( st->tcxonly && st->bfi ) )
     795             :         {
     796             :             Word16 pitch_C[NB_SUBFR16k];
     797             :             Word16 core_ext_mode, LTP_Gain;
     798             : 
     799         638 :             set16_fx( pitch_C, shl( round_fx( st->old_fpitch ), 6 ), NB_SUBFR16k );
     800             : 
     801         638 :             core_ext_mode = GENERIC;
     802         638 :             move16();
     803         638 :             if ( st->tcxonly == 0 )
     804             :             {
     805         638 :                 core_ext_mode = st->core_ext_mode;
     806         638 :                 move16();
     807             :             }
     808             : 
     809         638 :             LTP_Gain = -32768 /*-1.0f Q15*/;
     810         638 :             move16();
     811         638 :             if ( hTcxLtpDec->tcxltp )
     812             :             {
     813         638 :                 LTP_Gain = hTcxDec->tcxltp_last_gain_unmodified;
     814         638 :                 move16();
     815             :             }
     816             : 
     817             : 
     818         638 :             FEC_clas_estim_fx(
     819             :                 st,
     820             :                 /*Opt_AMR_WB*/ 0, /*A*/
     821         638 :                 st->L_frame,
     822             :                 &( st->clas_dec ),
     823             :                 core_ext_mode,
     824             :                 pitch_C,
     825             :                 synth,
     826             :                 &st->lp_ener_FER_fx,
     827             :                 /**decision_hyst*/ NULL,   /* i/o: hysteresis of the music/speech decision          */
     828             :                 /**UV_cnt*/ NULL,          /* i/o: number of consecutive frames classified as       */
     829             :                 /**LT_UV_cnt*/ NULL,       /* i/o: long term consecutive frames classified as UV    */
     830             :                 /**Last_ener*/ NULL,       /* i/o: last_energy frame                                */
     831             :                 /**locattack*/ NULL,       /* i/o: detection of attack (mainly to localized speech burst) */
     832             :                 /**lt_diff_etot*/ NULL,    /* i/o: long-term total energy variation                 */
     833             :                 /**amr_io_class*/ NULL,    /* i/o: classification for AMR-WB IO mode                */
     834             :                 0,                         /* i  : Synthesis scaling                                */
     835             :                 /**class_para*/ NULL,      /* o  : classification para. fmerit1                     */
     836         638 :                 st->mem_syn_clas_estim_fx, /* i/o: memory of the synthesis signal for frame class estimation */
     837             :                 &st->classifier_Q_mem_syn, /* i/o: exponent for memory of synthesis signal for frame class estimation */
     838             :                 LTP_Gain,                  /* i  : means LTP Gain                                   */
     839             :                 1 /*CLASSIFIER_TCX*/,      /* i  : signal classifier mode                           */
     840             :                 bfi,                       /* i  : bad frame indicator                              */
     841             :                 st->last_core_brate,       /* i  : bitrate of previous frame                        */
     842             :                 -1 );
     843             :         }
     844             :     }
     845             : 
     846             :     /*--------------------------------------------------------------------------------*
     847             :      * Updates
     848             :      *--------------------------------------------------------------------------------*/
     849             : 
     850        1248 :     test();
     851        1248 :     IF( bfi && st->last_core_bfi != ACELP_CORE )
     852             :     {
     853             :         /* Update FEC_scale_syn parameters */
     854           0 :         IF( hTcxLtpDec->tcxltp_gain == 0 )
     855             :         {
     856           0 :             frame_ener_fx( L_frame, UNVOICED_CLAS, synth, shr( L_frame, 1 ), &st->enr_old_fx, L_frame, 0, 0, 0 );
     857             :         }
     858             :         ELSE
     859             :         {
     860             :             Word16 pitch_Q0;
     861           0 :             pitch_Q0 = round_fx( st->old_fpitch );
     862           0 :             frame_ener_fx( L_frame, st->clas_dec, synth, pitch_Q0, &st->enr_old_fx, L_frame, 0, 0, 0 );
     863             :         }
     864             :     }
     865             : 
     866             : 
     867        1248 :     test();
     868        1248 :     test();
     869        1248 :     IF( !bfi && GE_16( st->clas_dec, VOICED_TRANSITION ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
     870             :     {
     871             :         Word16 offset;
     872             : 
     873         967 :         IF( EQ_16( st->core, ACELP_CORE ) )
     874             :         {
     875         489 :             offset = sub( st->nb_subfr, 1 );
     876         489 :             offset = imult1616( offset, add( M, 1 ) );
     877             :         }
     878             :         ELSE
     879             :         {
     880         478 :             offset = 0;
     881         478 :             move16();
     882             :         }
     883             :         /* use latest LPC set */
     884         967 :         st->old_enr_LP = Enr_1_Az_fx( Aq + offset, L_SUBFR ); /*Q3*/
     885         967 :         move16();
     886             :     }
     887             : 
     888             : 
     889             :     /* Update */
     890        1248 :     Copy( synth_buf + L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len );
     891             : 
     892        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 ) );
     893        1248 :     Copy( synth_bufFB + L_frameTCX, hTcxDec->old_synthFB_fx, hTcxDec->old_synth_lenFB );
     894        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 ) );
     895             : 
     896        1248 :     Copy( &xspnew_uw[imult1616( sub( st->numlpc, 1 ), M )], st->lspold_uw, M );
     897        1248 :     Copy( &xsfnew_uw[imult1616( sub( st->numlpc, 1 ), M )], st->lsfold_uw, M );
     898             : 
     899        1248 :     IF( bfi )
     900             :     {
     901           0 :         Copy( st->lspold_uw, st->lsp_old_fx, M ); /* for recovery */
     902           0 :         Copy( st->lsfold_uw, st->lsf_old_fx, M ); /* for recovery */
     903             :     }
     904             :     ELSE
     905             :     {
     906        1248 :         Copy( &lsp[st->numlpc * M], st->lsp_old_fx, M );
     907        1248 :         Copy( &lsf[st->numlpc * M], st->lsf_old_fx, M );
     908             :     }
     909        1248 :     Copy( st->lsp_q_cng, st->old_lsp_q_cng, M );
     910        1248 :     Copy( st->lsf_q_cng, st->old_lsf_q_cng, M );
     911             : 
     912             :     /* Update LP_CNG parameters */
     913        1248 :     test();
     914        1248 :     IF( st->tcxonly == 0 && st->hTdCngDec != NULL )
     915             :     {
     916             :         /* update CNG parameters in active frames */
     917        1248 :         test();
     918        1248 :         test();
     919        1248 :         IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc != 0 && st->core != ACELP_CORE )
     920           0 :         {
     921             :             Word16 buf[L_LP], res[L_FRAME], A[M + 1], Qexc, r_l[M + 1], r_h[M + 1], lsptmp[M], Q_r, tmp;
     922             : 
     923           0 :             assert( st->L_frame == L_FRAME );
     924           0 :             Copy( synth + L_FRAME - L_LP, buf, L_LP );
     925           0 :             tmp = synth[L_FRAME - L_LP - 1];
     926           0 :             move16();
     927           0 :             Qexc = E_UTIL_f_preemph3( buf, st->preemph_fac, L_LP, &tmp, 1 );
     928           0 :             autocorr_fx( buf, M, r_h, r_l, &Q_r, L_LP, Assym_window_W16fx, 0, 0 );
     929           0 :             lag_wind( r_h, r_l, M, INT_FS_FX, LAGW_WEAK );
     930           0 :             E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL );
     931           0 :             E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M );
     932           0 :             Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 );
     933           0 :             cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr,
     934           0 :                                st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
     935           0 :                                Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
     936             :         }
     937             :         ELSE
     938             :         {
     939        1248 :             cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame,
     940        1248 :                                st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx,
     941        1248 :                                &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC,
     942        1248 :                                st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
     943             :         }
     944             : 
     945             :         /* Set 16k LSP flag for CNG buffer */
     946        1248 :         st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
     947        1248 :         move16();
     948        1248 :         IF( EQ_16( st->L_frame, L_FRAME ) )
     949             :         {
     950         264 :             st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
     951         264 :             move16();
     952             :         }
     953             :     }
     954             : 
     955        1248 :     move16();
     956        1248 :     st->last_is_cng = 0;
     957             : 
     958             :     /* Postfiltering */
     959        1248 :     post_decoder( st, synth_buf, pit_gain, pitch, signal_out, bpf_noise_buf );
     960             : 
     961        1248 :     IF( signal_outFB )
     962             :     {
     963        1248 :         Copy( synthFB, signal_outFB, L_frameTCX );
     964             :     }
     965             : 
     966        1248 :     IF( st->enablePlcWaveadjust )
     967             :     {
     968           0 :         if ( !bfi )
     969             :         {
     970           0 :             st->hPlcInfo->nbLostCmpt = 0;
     971           0 :             move16();
     972             :         }
     973             : 
     974           0 :         IF( st->core == 0 )
     975             :         {
     976           0 :             set_state( st->hPlcInfo->Transient, st->core, MAX_POST_LEN );
     977             :         }
     978             :     }
     979             : 
     980             : 
     981        1248 :     return;
     982             : }

Generated by: LCOV version 1.14