LCOV - code coverage report
Current view: top level - lib_com - pred_lt4_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 574a190e3c6896c6c4ed10d7f23649709a0c4347 Lines: 77 77 100.0 %
Date: 2025-06-27 02:59:36 Functions: 3 3 100.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" /* Compilation switches                   */
       7             : #include "cnst.h"    /* Common constants                       */
       8             : #include "rom_com.h" /* Static table prototypes                */
       9             : #include "prot_fx.h" /* Function prototypes                    */
      10             : 
      11             : 
      12             : /*-------------------------------------------------------------------*
      13             :  * Function  pred_lt4:                                               *
      14             :  *           ~~~~~~~~~                                               *
      15             :  *-------------------------------------------------------------------*
      16             :  * Compute the result of long term prediction with fractional       *
      17             :  * interpolation of resolution 1/4.                                  *
      18             :  *                                                                   *
      19             :  * On return exc[0..L_subfr-1] contains the interpolated signal      *
      20             :  *   (adaptive codebook excitation)                                  *
      21             :  *-------------------------------------------------------------------*/
      22             : 
      23     2285523 : void pred_lt4_ivas_fx(
      24             :     const Word16 excI[],   /* in : excitation buffer       Q_exc*/
      25             :     Word16 excO[],         /* out: excitation buffer       Q_exc*/
      26             :     const Word16 T0,       /* input : integer pitch lag    Q0*/
      27             :     Word16 frac,           /* input : fraction of lag      Q0*/
      28             :     const Word16 L_subfr,  /* input : subframe size        Q0*/
      29             :     const Word32 *win,     /* i  : interpolation window    Q31*/
      30             :     const Word16 nb_coef,  /* i  : nb of filter coef       Q0*/
      31             :     const Word16 up_sample /* i  : up_sample               Q0*/
      32             : )
      33             : {
      34             :     Word16 i, j;
      35             :     Word32 s;
      36             :     const Word16 *x0, *x1, *x2;
      37             :     const Word32 *c1, *c2;
      38             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
      39     2285523 :     Flag Overflow = 0;
      40     2285523 :     move32();
      41             : #endif
      42     2285523 :     x0 = &excI[-T0];
      43             : 
      44     2285523 :     frac = negate( frac );
      45             : 
      46     2285523 :     IF( frac < 0 )
      47             :     {
      48     1643011 :         frac = add( frac, up_sample ); /* Q0 */
      49     1643011 :         x0--;
      50             :     }
      51             : 
      52   154617733 :     FOR( j = 0; j < L_subfr; j++ )
      53             :     {
      54   152332210 :         x1 = x0++;                       /* Q_exc */
      55   152332210 :         x2 = x1 + 1;                     /* Q_exc */
      56   152332210 :         c1 = ( &win[frac] );             /* Q14 */
      57   152332210 :         c2 = ( &win[up_sample - frac] ); /* Q14 */
      58             : 
      59             :         {
      60   152332210 :             Word64 s64 = 0;
      61   152332210 :             move64();
      62  1697784530 :             FOR( i = 0; i < nb_coef; i++ )
      63             :             {
      64             :                 /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
      65  1545452320 :                 s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */
      66  1545452320 :                 s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */
      67             : 
      68  1545452320 :                 c1 += up_sample;
      69  1545452320 :                 c2 += up_sample;
      70             :             }
      71   152332210 :             s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */
      72             :         }
      73             : 
      74   152332210 :         excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
      75   152332210 :         move16();
      76             :     }
      77     2285523 :     return;
      78             : }
      79             : 
      80       26884 : void pred_lt4(
      81             :     const Word16 excI[],   /* in : excitation buffer       Q_exc*/
      82             :     Word16 excO[],         /* out: excitation buffer       Q_exc*/
      83             :     const Word16 T0,       /* input : integer pitch lag    Q0*/
      84             :     Word16 frac,           /* input : fraction of lag      Q0*/
      85             :     const Word16 L_subfr,  /* input : subframe size        Q0*/
      86             :     const Word16 *win,     /* i  : interpolation window    Q14*/
      87             :     const Word16 nb_coef,  /* i  : nb of filter coef       Q0*/
      88             :     const Word16 up_sample /* i  : up_sample               Q0*/
      89             : )
      90             : {
      91             :     Word16 i, j;
      92             :     Word32 s;
      93             :     const Word16 *x0, *x1, *x2, *c1, *c2;
      94             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
      95       26884 :     Flag Overflow = 0;
      96       26884 :     move32();
      97             : #endif
      98       26884 :     x0 = &excI[-T0];
      99             : 
     100             : 
     101       26884 :     frac = negate( frac );
     102             : 
     103       26884 :     IF( frac < 0 )
     104             :     {
     105       18295 :         frac = add( frac, up_sample ); /* Q0 */
     106       18295 :         x0--;
     107             :     }
     108             : 
     109     1767358 :     FOR( j = 0; j < L_subfr; j++ )
     110             :     {
     111     1740474 :         x1 = x0++;                       /* Q_exc */
     112     1740474 :         x2 = x1 + 1;                     /* Q_exc */
     113     1740474 :         c1 = ( &win[frac] );             /* Q14 */
     114     1740474 :         c2 = ( &win[up_sample - frac] ); /* Q14 */
     115             : 
     116             :         {
     117     1740474 :             Word64 s64 = 0;
     118     1740474 :             move64();
     119    23538616 :             FOR( i = 0; i < nb_coef; i++ )
     120             :             {
     121             :                 /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
     122    21798142 :                 s64 = W_mac0_16_16( s64, ( *x1-- ), ( *c1 ) ); /* Q_exc + Q14 */
     123    21798142 :                 s64 = W_mac0_16_16( s64, ( *x2++ ), ( *c2 ) ); /* Q_exc + Q14 */
     124             : 
     125    21798142 :                 c1 += up_sample;
     126    21798142 :                 c2 += up_sample;
     127             :             }
     128     1740474 :             s = W_sat_l( s64 ); /* Q_exc + Q14 */
     129             :         }
     130             : #if ( INTERP_EXP != -1 )
     131     1740474 :         s = L_shl_o( s, INTERP_EXP + 1, &Overflow ); /* Q_exc + Q15 */
     132             : #endif
     133             : 
     134     1740474 :         excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
     135     1740474 :         move16();
     136             :     }
     137       26884 :     return;
     138             : }
     139             : 
     140             : 
     141             : /*======================================================================*/
     142             : /* FUNCTION : pred_lt4_tc_fx() */
     143             : /*-----------------------------------------------------------------------*/
     144             : /* PURPOSE :   * adapt. search of the second impulse in the same subframe (when appears) */
     145             : /* On return, exc[0..L_subfr-1] contains the interpolated signal         */
     146             : /*   (adaptive codebook excitation)                                      */
     147             : /*                                                                       */
     148             : /*-----------------------------------------------------------------------*/
     149             : /*  INPUT ARGUMENTS :                                                    */
     150             : /* _ (Word16 []) exc  : excitation buffer             Q0                 */
     151             : /* _ (Word16) L_subfr : subframe size                 Q0                 */
     152             : /* _ (Word16 ) T0 : integer pitch lag                 Q0                 */
     153             : /* _ (Word16 ) frac : fraction of lag                 Q0                 */
     154             : /* _ (Word16 ) imp_pos : glottal impulse position     Q0                 */
     155             : /* _ (Word16 *) win : Interpolation window used       Q14                */
     156             : /*-----------------------------------------------------------------------*/
     157             : /* OUTPUT ARGUMENTS :                                                    */
     158             : /* _ (Word16 []) exc  : output excitation buffer      Q0                 */
     159             : /*-----------------------------------------------------------------------*/
     160             : /* INPUT OUTPUT ARGUMENTS                                                */
     161             : /* NONE                                                                                                                                  */
     162             : /*-----------------------------------------------------------------------*/
     163             : /* RETURN ARGUMENTS :                                                    */
     164             : /* NONE                                                                  */
     165             : /*=======================================================================*/
     166       26912 : void pred_lt4_tc_fx(
     167             :     Word16 exc[],         /* i/o: excitation buffer        Q0*/
     168             :     const Word16 T0,      /* i  : integer pitch lag        Q0*/
     169             :     Word16 frac,          /* i:   fraction of lag          Q0*/
     170             :     const Word16 *win,    /* i  : interpolation window     Q14*/
     171             :     const Word16 imp_pos, /* i  : glottal impulse position Q0*/
     172             :     const Word16 i_subfr  /* i  : subframe index           Q0*/
     173             : )
     174             : {
     175             :     Word16 i, j, k, l;
     176             :     const Word16 *x0;
     177             :     Word16 excO[L_SUBFR + 1];
     178             :     Word32 L_sum;
     179             :     Word16 excI[2 * L_SUBFR];
     180             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     181       26912 :     Flag Overflow = 0;
     182       26912 :     move32();
     183             : #endif
     184       26912 :     Copy( exc + sub( i_subfr, L_SUBFR ), excI, L_SUBFR * 2 ); /* Q0 */
     185             : 
     186       26912 :     test();
     187       26912 :     IF( LT_16( add( T0, sub( imp_pos, L_IMPULSE2 ) ), L_SUBFR ) && LT_16( T0, L_SUBFR ) )
     188             :     {
     189        4197 :         set16_fx( &excI[L_SUBFR - T0], 0, T0 );
     190        4197 :         set16_fx( excO, 0, L_SUBFR + 1 );
     191        4197 :         x0 = excI + ( L_SUBFR - ( L_INTERPOL2 - 1 ) );
     192             : 
     193        4197 :         IF( frac > 0 )
     194             :         {
     195        2070 :             frac = sub( frac, UP_SAMP ); /* Q0 */
     196        2070 :             x0--;
     197             :         }
     198             : 
     199        4197 :         l = add( UP_SAMP - 1, frac ); /* Q0 */
     200       80688 :         FOR( j = T0; j < L_SUBFR + 1; j++ )
     201             :         {
     202       76491 :             k = l;
     203       76491 :             move16();
     204       76491 :             L_sum = L_mult( x0[0], win[k] ); /* Q15 */
     205     2447712 :             FOR( i = 1; i < 2 * L_INTERPOL2; i++ )
     206             :             {
     207             :                 /*
     208             :                  * Here, additions with UP_SAMP are not counted
     209             :                  ki* because, the window could easily be modified
     210             :                  * so that the values needed are contiguous.
     211             :                  */
     212     2371221 :                 k += UP_SAMP;
     213     2371221 :                 L_sum = L_mac( L_sum, x0[i], win[k] ); /* Q15 */
     214             :             }
     215       76491 :             L_sum = L_shl_o( L_sum, 1, &Overflow );   /* Q16 */
     216       76491 :             excO[j] = round_fx_o( L_sum, &Overflow ); /* Q0 */
     217       76491 :             move16();
     218             : 
     219       76491 :             x0++;
     220             :         }
     221       76491 :         FOR( i = T0; i < L_SUBFR; i++ )
     222             :         {
     223       72294 :             exc[i + i_subfr] = add_o( exc[i + i_subfr], mult_r( PIT_SHARP_fx, excO[i] ), &Overflow ); /* Q0 */
     224       72294 :             move16();
     225             :         }
     226             :     }
     227             : 
     228       26912 :     return;
     229             : }

Generated by: LCOV version 1.14