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

Generated by: LCOV version 1.14