LCOV - code coverage report
Current view: top level - lib_enc - enc_gen_voic_rf_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3ea8505de0a48ae0f5675c28be980f7a28fcc88e Lines: 71 237 30.0 %
Date: 2025-05-31 01:58:07 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : #include <stdint.h>
       6             : #include "options.h"
       7             : #include "cnst.h"
       8             : #include "rom_com_fx.h"
       9             : #include "stl.h"
      10             : #include "rom_basop_util.h"
      11             : #include "rom_com.h"     /* Common constants                       */
      12             : #include "prot_fx.h"     /* Function prototypes                    */
      13             : #include "prot_fx_enc.h" /* Function prototypes                    */
      14             : #include "basop_util.h"  /* Function prototypes                    */
      15             : 
      16             : 
      17      172920 : void reset_rf_indices_fx(
      18             :     Encoder_State *st /* i: state structure - contains partial RF indices */
      19             : )
      20             : {
      21      172920 :     RF_ENC_HANDLE hRF = st->hRF;
      22             :     Word16 i, j;
      23      172920 :     if ( hRF != NULL )
      24             :     {
      25        2483 :         hRF->rf_frame_type = 0; /* since this function is called every frame this will happen even for a SID frame, hence treating it as GSC frame, i.e no RF encoding */
      26        2483 :         hRF->rf_mem_w0 = 0;
      27        2483 :         move16();
      28        2483 :         st->rf_target_bits_write = 0;
      29        2483 :         move16();
      30        2483 :         set16_fx( hRF->rf_clip_var, 0, 6 );
      31        2483 :         hRF->rf_tilt_code = 0;
      32        2483 :         move16();
      33        2483 :         set16_fx( hRF->rf_mem_syn2, 0, M );
      34        2483 :         hRF->rf_dm_fx.prev_state = 0;
      35        2483 :         move16();
      36        2483 :         hRF->rf_dm_fx.prev_gain_code = 0;
      37        2483 :         move32();
      38             : 
      39       17381 :         FOR( i = 0; i < 6; i++ )
      40             :         {
      41       14898 :             hRF->rf_dm_fx.prev_gain_pit[i] = 0;
      42       14898 :             move16();
      43             :         }
      44             : 
      45        2483 :         hRF->rf_gc_threshold = 0;
      46        2483 :         move32();
      47        2483 :         set16_fx( hRF->rf_tilt_buf, 0, NB_SUBFR16k );
      48             : 
      49        2483 :         hRF->rf_target_bits = 0;
      50        2483 :         move16();
      51        2483 :         hRF->rf_tcxltp_pitch_int_past = st->L_frame; /* Q0 */
      52        2483 :         move16();
      53        2483 :         hRF->rf_last_tns_active = 0;
      54        2483 :         move16();
      55        2483 :         hRF->rf_second_last_tns_active = 0;
      56        2483 :         move16();
      57        2483 :         hRF->rf_second_last_core = 0;
      58        2483 :         move16();
      59             : 
      60       24830 :         FOR( i = 0; i < MAX_RF_FEC_OFFSET; i++ )
      61             :         {
      62       22347 :             hRF->rf_indx_frametype[i] = RF_NO_DATA;
      63       22347 :             move16(); /* rf_mode: 1, rf_frame_type: 3, and fec_offset: 2 */
      64       22347 :             hRF->rf_targetbits_buff[i] = 6;
      65       22347 :             move16();
      66       22347 :             hRF->rf_indx_lsf[i][0] = 0;
      67       22347 :             move16();
      68       22347 :             hRF->rf_indx_lsf[i][1] = 0;
      69       22347 :             move16();
      70       22347 :             hRF->rf_indx_lsf[i][2] = 0;
      71       22347 :             move16();
      72       22347 :             hRF->rf_indx_EsPred[i] = 0;
      73       22347 :             move16();
      74       22347 :             hRF->rf_indx_nelp_fid[i] = 0;
      75       22347 :             move16();
      76       22347 :             hRF->rf_indx_nelp_iG1[i] = 0;
      77       22347 :             move16();
      78       22347 :             hRF->rf_indx_nelp_iG2[i][0] = 0;
      79       22347 :             move16();
      80       22347 :             hRF->rf_indx_nelp_iG2[i][1] = 0;
      81       22347 :             move16();
      82             : 
      83      134082 :             FOR( j = 0; j < NB_SUBFR16k; j++ )
      84             :             {
      85      111735 :                 hRF->rf_indx_ltfMode[i][j] = 0;
      86      111735 :                 move16();
      87      111735 :                 hRF->rf_indx_pitch[i][j] = 0;
      88      111735 :                 move16();
      89      111735 :                 hRF->rf_indx_fcb[i][j] = 0;
      90      111735 :                 move16();
      91      111735 :                 hRF->rf_indx_gain[i][j] = 0;
      92      111735 :                 move16();
      93             :             }
      94             : 
      95       22347 :             hRF->rf_clas[i] = UNVOICED_CLAS;
      96       22347 :             move16();
      97       22347 :             hRF->rf_gain_tcx[i] = 0;
      98       22347 :             move16();
      99       22347 :             hRF->rf_tcxltp_param[i] = 0;
     100       22347 :             move16();
     101             : 
     102       22347 :             hRF->rf_indx_tbeGainFr[i] = 0;
     103       22347 :             move16();
     104             :         }
     105             :     }
     106             : 
     107      172920 :     return;
     108             : }
     109             : 
     110             : 
     111             : /*-------------------------------------------------------------------*
     112             :  * coder_acelp_rf_fx()
     113             :  *
     114             :  * Encode excitation signal (partial redundancy)
     115             :  *-------------------------------------------------------------------*/
     116           0 : void coder_acelp_rf_fx(
     117             :     ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/
     118             :     const Word16 coder_type, /* input: coding type                                              Q0*/
     119             :     const Word16 A[],        /* input: coefficients 4xAz[M+1]                   Q12*/
     120             :     const Word16 Aq[],       /* input: coefficients 4xAz_q[M+1]                 Q12*/
     121             :     Word16 speech[],         /* input: speech[-M..lg]                                   Q_new-1*/
     122             :     const Word16 voicing[],  /* input: open-loop LTP gain                               Q15*/
     123             :     const Word16 T_op[],     /* input: open-loop LTP lag                                Q0*/
     124             :     Word16 stab_fac,         /* Q15 */
     125             :     Encoder_State *st,
     126             :     Word16 target_bits,         /* i/o : coder memory state                             Q0*/
     127             :     const Word16 rf_frame_type, /* i  : rf_frame_type                                   Q0*/
     128             :     Word16 *exc_rf,             /* i/o: pointer to RF excitation    Q_new*/
     129             :     Word16 *syn_rf,             /* i/o: pointer to RF synthesis     Q_new-1*/
     130             :     Word16 Q_new,
     131             :     Word16 shift )
     132             : {
     133             :     Word16 i, j, i_subfr, j_subfr;
     134             :     Word16 T0, T0_min, T0_min_frac, T0_max, T0_max_frac, T0_res;
     135             :     Word16 T0_frac;
     136             :     Word16 tmp2;
     137             :     Word16 gain_pit, voice_fac;
     138             :     Word32 gain_code, Ltmp, Ltmp2;
     139             :     ACELP_CbkCorr g_corr;
     140             :     const Word16 *p_A, *p_Aq;
     141             :     Word16 h1[L_SUBFR]; /* weighted impulse response of LP */
     142             :     Word16 code[L_SUBFR];
     143             :     Word16 xn_exp;
     144             :     Word16 Q_xn;
     145             :     Word16 Q_new_p5;
     146             :     Word16 cn[L_SUBFR];
     147             :     Word16 xn[L_SUBFR];
     148             :     Word16 y1[L_SUBFR]; /* Filtered adaptive excitation       */
     149             :     Word16 y2[L_SUBFR]; /* Filtered adaptive excitation       */
     150             :     Word16 res_save;
     151             :     Word16 exc_nelp[L_FRAME];
     152             :     Word16 exc2[L_SUBFR];
     153             :     Word16 syn2[L_DIV_MAX];
     154             :     Word16 gain_inov;
     155             :     Word32 past_gcode;
     156             :     Word16 L_frame;
     157             :     Word16 clip_gain;
     158             :     Word32 gain_code2;
     159             :     Word16 code2[L_SUBFR];
     160             :     Word16 y22[L_SUBFR]; /* Filtered adaptive excitation */
     161             :     Word32 gain_code_vect[2];
     162             :     Word16 *prm_rf;
     163             :     Word16 Es_pred_rf;
     164             :     Word16 nSubfr;
     165             :     Word16 prev_gain_pit;
     166             :     Word16 rf_coder_type;
     167             :     Word16 lp_select;
     168             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     169           0 :     Flag Overflow = 0;
     170           0 :     move32();
     171             : #endif
     172             : 
     173           0 :     RF_ENC_HANDLE hRF = st->hRF;
     174             : 
     175             :     /* to avoid compilation warnings */
     176           0 :     past_gcode = 0;
     177           0 :     gain_inov = 0;
     178           0 :     T0 = 0;
     179           0 :     T0_frac = 0;
     180           0 :     T0_res = 0;
     181           0 :     gain_pit = 0;
     182           0 :     gain_code = 0;
     183           0 :     voice_fac = 0;
     184           0 :     prev_gain_pit = 0;
     185           0 :     Es_pred_rf = 0;
     186           0 :     move32();
     187           0 :     move32();
     188           0 :     move16();
     189           0 :     move16();
     190           0 :     move16();
     191           0 :     move16();
     192           0 :     move16();
     193           0 :     move16();
     194           0 :     move16();
     195             : 
     196           0 :     set16_fx( code, 0, L_SUBFR );
     197             : 
     198             :     /*-----------------------------------------------------------------------*
     199             :      * Configure ACELP partial copy                                           *
     200             :      *------------------------------------------------------------------------*/
     201           0 :     tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr ); /* Q0 */
     202             : 
     203             :     /* Init Framing parameters */
     204           0 :     L_frame = st->L_frame; /* Q0 */
     205           0 :     move16();
     206             :     /*------------------------------------------------------------------------*
     207             :      * Initialize buffers                                                     *
     208             :      *------------------------------------------------------------------------*/
     209             : 
     210             :     /* Rescale ACELP memories, which were not scaled yet*/
     211           0 :     xn_exp = sub( sub( 15 + 1, Q_new ), shift );
     212           0 :     Q_xn = add( sub( Q_new, 1 ), shift );
     213           0 :     Q_new_p5 = add( Q_new, 5 );
     214             : 
     215             :     /* Reset phase dispersion */
     216           0 :     IF( GT_16( st->last_core, ACELP_CORE ) )
     217             :     {
     218           0 :         hRF->rf_dm_fx.prev_gain_code = 0;
     219           0 :         set16_fx( hRF->rf_dm_fx.prev_gain_pit, 0, 6 );
     220           0 :         hRF->rf_dm_fx.prev_state = 0;
     221             :     }
     222             : 
     223             :     /* calculate residual */
     224           0 :     calc_residu_fx( st, speech, exc_rf, Aq );
     225             : 
     226             :     /*------------------------------------------------------------------------*
     227             :      * Find and quantize mean_ener_code for gain quantizer                    *
     228             :      *------------------------------------------------------------------------*/
     229             : 
     230           0 :     Es_pred_rf = 0;
     231           0 :     move16();
     232             : 
     233           0 :     test();
     234           0 :     IF( acelp_cfg->nrg_mode > 0 && NE_16( rf_frame_type, RF_NELP ) )
     235             :     {
     236           0 :         Es_pred_enc_fx( &Es_pred_rf, &hRF->rf_indx_EsPred[0], L_frame, exc_rf, voicing,
     237           0 :                         acelp_cfg->nrg_bits, extract_l( GT_16( acelp_cfg->nrg_mode, 1 ) ), Q_new );
     238             :     }
     239             : 
     240             :     /*------------------------------------------------------------------------*
     241             :      *          Loop for every subframe in the analysis frame                 *
     242             :      *------------------------------------------------------------------------*
     243             :      *  To find the pitch and innovation parameters. The subframe size is     *
     244             :      *  L_SUBFR and the loop is repeated L_FRAME_PLUS/L_SUBFR   *
     245             :      *  times.                                                                *
     246             :      *     - compute impulse response of weighted synthesis filter (h1[])     *
     247             :      *     - compute the target signal for pitch search                       *
     248             :      *     - find the closed-loop pitch parameters                            *
     249             :      *     - encode the pitch delay                                           *
     250             :      *     - update the impulse response h1[] by including fixed-gain pitch   *
     251             :      *     - find target vector for codebook search                           *
     252             :      *     - correlation between target vector and impulse response           *
     253             :      *     - codebook search                                                  *
     254             :      *     - encode codebook address                                          *
     255             :      *     - VQ of pitch and codebook gains                                   *
     256             :      *     - find synthesis speech                                            *
     257             :      *     - update states of weighting filter                                *
     258             :      *------------------------------------------------------------------------*/
     259           0 :     p_A = A;
     260           0 :     p_Aq = Aq;
     261             : 
     262           0 :     res_save = exc_rf[0];
     263           0 :     nSubfr = 0;
     264           0 :     j_subfr = 0;
     265             : 
     266           0 :     FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
     267             :     {
     268             : 
     269           0 :         IF( NE_16( rf_frame_type, RF_NELP ) )
     270             :         {
     271             :             /* Restore exc[i_subfr] and save next exc[L_SUBFR+i_subfr] */
     272           0 :             move16();
     273           0 :             move16();
     274           0 :             exc_rf[i_subfr] = res_save;
     275           0 :             res_save = exc_rf[L_SUBFR + i_subfr];
     276             : 
     277             :             /*--------------------------------------------------------------------------*
     278             :              * Find target for pitch search (xn[]), target for innovation search (cn[]) *
     279             :              * and impulse response of the weighted synthesis filter (h1[]).            *
     280             :              *--------------------------------------------------------------------------*/
     281           0 :             find_targets_fx( speech, &syn_rf[i_subfr - M], i_subfr, &( hRF->rf_mem_w0 ), p_Aq,
     282           0 :                              exc_rf, L_SUBFR, p_A, st->preemph_fac, xn, cn, h1 );
     283             : 
     284             :             /*---------------------------------------------------------------*
     285             :              * Compute impulse response, h1[], of weighted synthesis filter  *
     286             :              *---------------------------------------------------------------*/
     287           0 :             Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* Q13+1-shift */
     288             : 
     289             :             /* scaling of xn[] to limit dynamic at 12 bits */
     290           0 :             Scale_sig( xn, L_SUBFR, shift ); /* Q_new + shift */
     291             :         }
     292             : 
     293             : 
     294             :         /*-----------------------------------------------------------------*
     295             :          * Gain clipping test to avoid unstable synthesis on frame erasure
     296             :          * or in case of floating point encoder & fixed p. decoder
     297             :          *-----------------------------------------------------------------*/
     298             :         /* full frame nelp partial copy encoding */
     299           0 :         IF( EQ_16( rf_frame_type, RF_NELP ) )
     300             :         {
     301           0 :             IF( i_subfr == 0 )
     302             :             {
     303           0 :                 nelp_encoder_fx( st, exc_rf, exc_nelp, &Q_new, 0 );
     304             :             }
     305           0 :             Copy( &exc_nelp[i_subfr], exc2, L_SUBFR );   /* Q_new */
     306           0 :             Copy( &exc_nelp[i_subfr], exc_rf, L_SUBFR ); /* Q_new */
     307             :         }
     308             :         ELSE
     309             :         {
     310           0 :             clip_gain = Mode2_gp_clip_fx( voicing, i_subfr, coder_type, xn, hRF->rf_clip_var, L_SUBFR, Q_xn ); // Q0
     311             : 
     312             :             /*-----------------------------------------------------------------*
     313             :              * - find unity gain pitch excitation (adaptive codebook entry)    *
     314             :              *   with fractional interpolation.                                *
     315             :              * - find filtered pitch exc. y1[]=exc[] convolved with h1[])      *
     316             :              * - compute pitch gain1                                           *
     317             :              *-----------------------------------------------------------------*/
     318           0 :             if ( acelp_cfg->gains_mode[i_subfr / L_SUBFR] == 0 )
     319             :             {
     320           0 :                 gain_pit = prev_gain_pit;
     321           0 :                 move16();
     322             :             }
     323             : 
     324           0 :             IF( acelp_cfg->ltp_bits != 0 )
     325             :             {
     326           0 :                 prm_rf = &hRF->rf_indx_pitch[0][nSubfr]; /* Q0 */
     327             : 
     328             :                 /* Adaptive Codebook (GC and VC) */
     329           0 :                 Mode2_pit_encode_fx( acelp_cfg->ltp_mode, i_subfr, &prm_rf, &exc_rf[i_subfr],
     330             :                                      T_op, &T0_min, &T0_min_frac, &T0_max, &T0_max_frac, &T0,
     331           0 :                                      &T0_frac, &T0_res, h1, xn, st->pit_min, st->pit_fr1, st->pit_fr1b,
     332           0 :                                      st->pit_fr2, st->pit_max, st->pit_res_max );
     333             : 
     334             :                 /* find ACB excitation */
     335           0 :                 rf_coder_type = 100;
     336           0 :                 move16();
     337           0 :                 if ( acelp_cfg->gains_mode[i_subfr / L_SUBFR] > 0 )
     338             :                 {
     339           0 :                     rf_coder_type = acelp_cfg->gains_mode[i_subfr / L_SUBFR]; /* Q0 */
     340           0 :                     move16();
     341             :                 }
     342             : 
     343           0 :                 E_ACELP_adaptive_codebook( exc_rf, T0, T0_frac, T0_res, st->pit_res_max, acelp_cfg->ltf_mode,
     344             :                                            i_subfr, L_SUBFR, L_frame, h1, clip_gain, xn, y1, &g_corr, &prm_rf,
     345           0 :                                            &gain_pit, xn_exp, st->rf_mode, rf_coder_type, &lp_select );
     346             : 
     347             : 
     348           0 :                 if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
     349             :                 {
     350           0 :                     hRF->rf_indx_ltfMode[0][nSubfr] = lp_select; /* Q0 */
     351           0 :                     move16();
     352             :                 }
     353             :             }
     354           0 :             ELSE IF( acelp_cfg->ltp_bits == 0 )
     355             :             {
     356             :                 /* No adaptive codebook (UC) */
     357           0 :                 gain_pit = 0;
     358           0 :                 g_corr.xy1 = 0;
     359           0 :                 g_corr.xy1_e = 0;
     360           0 :                 g_corr.y1y1 = 0x4000; /* set to 0x4000 instead of 0 to avoid assert failue in gain_enc : assert(coeff0 >= 0x4000) */
     361           0 :                 g_corr.y1y1_e = 0;
     362           0 :                 set16_fx( y1, 0, L_SUBFR );
     363           0 :                 set16_fx( exc_rf + i_subfr, 0, L_SUBFR );
     364           0 :                 T0 = L_SUBFR;
     365           0 :                 T0_frac = 0;
     366           0 :                 T0_res = 1;
     367           0 :                 move16();
     368           0 :                 move16();
     369           0 :                 move16();
     370           0 :                 move16();
     371           0 :                 move16();
     372           0 :                 move16();
     373           0 :                 move16();
     374           0 :                 move16();
     375             :             }
     376             : 
     377             : 
     378             :             /*----------------------------------------------------------------------*
     379             :              *                 Encode the algebraic innovation                      *
     380             :              *----------------------------------------------------------------------*/
     381           0 :             IF( acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR] >= 0 )
     382             :             {
     383           0 :                 prm_rf = &hRF->rf_indx_fcb[0][nSubfr];
     384             : 
     385           0 :                 E_ACELP_innovative_codebook_fx( exc_rf, T0, T0_frac, T0_res, gain_pit, hRF->rf_tilt_code,
     386           0 :                                                 acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, (Word8) st->acelp_autocorr,
     387           0 :                                                 &prm_rf, code, shift, st->L_frame, st->last_L_frame, st->total_brate );
     388             :             }
     389             :             ELSE
     390             :             {
     391           0 :                 set16_fx( code, 0, L_SUBFR );
     392           0 :                 set16_fx( y2, 0, L_SUBFR );
     393             :             }
     394             : 
     395           0 :             IF( LT_16( i_subfr, sub( L_frame, L_SUBFR ) ) )
     396             :             {
     397           0 :                 E_ACELP_xy2_corr( xn, y1, y2, &g_corr, L_SUBFR, Q_xn );
     398             : 
     399           0 :                 g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 );             /* -18 (y2*y2: Q9*Q9) */
     400           0 :                 g_corr.xy2_e = sub( g_corr.xy2_e, add( Q_xn, 9 ) );   /* -(Q_xn+9) (xn: Q_xn y2: Q9) */
     401           0 :                 g_corr.y1y2_e = sub( g_corr.y1y2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (y1: Q_xn y2: Q9) */
     402           0 :                 g_corr.xx_e = sub( g_corr.xx_e, add( Q_xn, Q_xn ) );  /* -(Q_xn+Q_xn) (xn: Q_xn) */
     403             : 
     404             :                 /*----------------------------------------------------------------------*
     405             :                  *                 Add Gaussian excitation                              *
     406             :                  *----------------------------------------------------------------------*/
     407           0 :                 gain_code2 = L_deposit_l( 0 );
     408           0 :                 set16_fx( code2, 0, L_SUBFR );
     409           0 :                 set16_fx( y22, 0, L_SUBFR );
     410             : 
     411             :                 /*----------------------------------------------------------*
     412             :                  *  - Compute the fixed codebook gain                       *
     413             :                  *  - quantize fixed codebook gain                          *
     414             :                  *----------------------------------------------------------*/
     415           0 :                 IF( acelp_cfg->gains_mode[i_subfr / L_SUBFR] != 0 )
     416             :                 {
     417           0 :                     prm_rf = &hRF->rf_indx_gain[0][nSubfr]; /* Q0 */
     418             : 
     419           0 :                     encode_acelp_gains_fx( code, acelp_cfg->gains_mode[j_subfr], Es_pred_rf,
     420             :                                            clip_gain, &g_corr, &gain_pit, &gain_code, &prm_rf, &past_gcode,
     421           0 :                                            &gain_inov, L_SUBFR, code2, &gain_code2, st->flag_noisy_speech_snr );
     422             :                 }
     423             : 
     424             : 
     425           0 :                 gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, hRF->rf_clip_var );
     426             : 
     427           0 :                 gain_code_vect[0] = gain_code;
     428           0 :                 move32();
     429           0 :                 gain_code_vect[1] = gain_code;
     430           0 :                 move32();
     431             : 
     432             :                 /*----------------------------------------------------------*
     433             :                  * - voice factor (for pitch enhancement)                   *
     434             :                  *----------------------------------------------------------*/
     435           0 :                 E_UTIL_voice_factor( exc_rf, i_subfr, code, gain_pit, gain_code,
     436           0 :                                      &voice_fac, &( hRF->rf_tilt_code ), L_SUBFR, acelp_cfg->voice_tilt, Q_new, shift );
     437             : 
     438             : 
     439             :                 /*-----------------------------------------------------------------*
     440             :                  * Update memory of the weighting filter
     441             :                  *-----------------------------------------------------------------*/
     442             :                 /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
     443           0 :                 Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] );             /* Q10 */
     444           0 :                 Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow );            /* Q15 + Q_xn */
     445           0 :                 Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */
     446             :                 /* Add Gaussian contribution*/
     447           0 :                 Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] );                                                          /* Q10 */
     448           0 :                 Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow );                                                          /* Q15 + Q_xn */
     449           0 :                 Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );                                                                     /* Q15 + Q_xn */
     450           0 :                 hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */
     451           0 :                 move16();
     452           0 :                 hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/
     453             : 
     454             : 
     455             :                 /*-------------------------------------------------------*
     456             :                  * - Find the total excitation.                          *
     457             :                  *-------------------------------------------------------*/
     458             : 
     459           0 :                 tmp2 = shr( L_SUBFR, 1 );
     460           0 :                 FOR( j = 0; j < 2; j++ )
     461             :                 {
     462           0 :                     FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ )
     463             :                     {
     464             :                         /* code in Q9, gain_pit in Q14; exc Q_new */
     465           0 :                         Ltmp = Mpy_32_16_1( gain_code2, code2[i] );                       /* Q10 */
     466           0 :                         Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow );                      /* Q15 + Q_new */
     467           0 :                         Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */
     468           0 :                         exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */
     469           0 :                         move16();
     470           0 :                         Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] );   /* Q10 */
     471           0 :                         Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow );       /* Q15 + Q_new */
     472           0 :                         Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow );            /* Q15 + Q_new */
     473           0 :                         Ltmp = L_shl_o( Ltmp, 1, &Overflow );                /* saturation can occur here   Q16 + Q_new*/
     474           0 :                         exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */
     475           0 :                         move16();
     476             :                     }
     477           0 :                     tmp2 = L_SUBFR;
     478           0 :                     move16();
     479             :                 }
     480             : 
     481             : 
     482             :                 /*---------------------------------------------------------*
     483             :                  * Enhance the excitation                                  *
     484             :                  *---------------------------------------------------------*/
     485           0 :                 E_UTIL_enhancer( voice_fac, stab_fac, past_gcode, gain_inov,
     486             :                                  &hRF->rf_gc_threshold, code, exc2, gain_pit, &hRF->rf_dm_fx.prev_gain_code,
     487           0 :                                  hRF->rf_dm_fx.prev_gain_pit, &hRF->rf_dm_fx.prev_state, coder_type,
     488           0 :                                  acelp_cfg->fixed_cdk_index[j_subfr], L_SUBFR, L_frame, Q_new );
     489             :             }
     490             :         }
     491             : 
     492           0 :         test();
     493           0 :         IF( LT_16( i_subfr, sub( L_frame, L_SUBFR ) ) || NE_16( rf_frame_type, RF_NELP ) )
     494             :         {
     495             : 
     496             :             /*----------------------------------------------------------*
     497             :              * - compute the synthesis speech                           *
     498             :              *----------------------------------------------------------*/
     499             : 
     500           0 :             E_UTIL_synthesis( 1, p_Aq, exc2, &syn2[i_subfr], L_SUBFR, hRF->rf_mem_syn2, 1, M );
     501             : 
     502           0 :             E_UTIL_synthesis( 1, p_Aq, &exc_rf[i_subfr], &syn_rf[i_subfr], L_SUBFR, &syn_rf[i_subfr - M], 0, M );
     503             : 
     504             :             /*----------------------------------------------------------*
     505             :              * Update                                                   *
     506             :              *----------------------------------------------------------*/
     507           0 :             p_A += ( M + 1 );
     508           0 :             p_Aq += ( M + 1 );
     509           0 :             nSubfr++;
     510             : 
     511           0 :             st->gain_code[j_subfr] = gain_code; /* Q16 */
     512           0 :             j_subfr = add( j_subfr, 1 );
     513             : 
     514             :             /* copy current gain for next subframe use, in case there is no explicit encoding */
     515           0 :             prev_gain_pit = gain_pit;
     516           0 :             move16();
     517             :         }
     518             : 
     519             : 
     520             :     } /* end of subframe loop */
     521             : 
     522             : 
     523           0 :     return;
     524             : }

Generated by: LCOV version 1.14