LCOV - code coverage report
Current view: top level - lib_com - pred_lt4_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 6c320724ac154bae0b720af82641e0df71ffdfc7 Lines: 77 77 100.0 %
Date: 2025-07-01 04:22:09 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      532845 : 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      532845 :     Flag Overflow = 0;
      40      532845 :     move32();
      41             : #endif
      42      532845 :     x0 = &excI[-T0];
      43             : 
      44      532845 :     frac = negate( frac );
      45             : 
      46      532845 :     IF( frac < 0 )
      47             :     {
      48      385098 :         frac = add( frac, up_sample ); /* Q0 */
      49      385098 :         x0--;
      50             :     }
      51             : 
      52    37923065 :     FOR( j = 0; j < L_subfr; j++ )
      53             :     {
      54    37390220 :         x1 = x0++;                       /* Q_exc */
      55    37390220 :         x2 = x1 + 1;                     /* Q_exc */
      56    37390220 :         c1 = ( &win[frac] );             /* Q14 */
      57    37390220 :         c2 = ( &win[up_sample - frac] ); /* Q14 */
      58             : 
      59             :         {
      60    37390220 :             Word64 s64 = 0;
      61    37390220 :             move64();
      62   635633740 :             FOR( i = 0; i < nb_coef; i++ )
      63             :             {
      64             :                 /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
      65   598243520 :                 s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */
      66   598243520 :                 s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */
      67             : 
      68   598243520 :                 c1 += up_sample;
      69   598243520 :                 c2 += up_sample;
      70             :             }
      71    37390220 :             s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */
      72             :         }
      73             : 
      74    37390220 :         excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
      75    37390220 :         move16();
      76             :     }
      77      532845 :     return;
      78             : }
      79             : 
      80        9224 : 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        9224 :     Flag Overflow = 0;
      96        9224 :     move32();
      97             : #endif
      98        9224 :     x0 = &excI[-T0];
      99             : 
     100             : 
     101        9224 :     frac = negate( frac );
     102             : 
     103        9224 :     IF( frac < 0 )
     104             :     {
     105        6106 :         frac = add( frac, up_sample ); /* Q0 */
     106        6106 :         x0--;
     107             :     }
     108             : 
     109      609552 :     FOR( j = 0; j < L_subfr; j++ )
     110             :     {
     111      600328 :         x1 = x0++;                       /* Q_exc */
     112      600328 :         x2 = x1 + 1;                     /* Q_exc */
     113      600328 :         c1 = ( &win[frac] );             /* Q14 */
     114      600328 :         c2 = ( &win[up_sample - frac] ); /* Q14 */
     115             : 
     116             :         {
     117      600328 :             Word64 s64 = 0;
     118      600328 :             move64();
     119    10403826 :             FOR( i = 0; i < nb_coef; i++ )
     120             :             {
     121             :                 /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
     122     9803498 :                 s64 = W_mac0_16_16( s64, ( *x1-- ), ( *c1 ) ); /* Q_exc + Q14 */
     123     9803498 :                 s64 = W_mac0_16_16( s64, ( *x2++ ), ( *c2 ) ); /* Q_exc + Q14 */
     124             : 
     125     9803498 :                 c1 += up_sample;
     126     9803498 :                 c2 += up_sample;
     127             :             }
     128      600328 :             s = W_sat_l( s64 ); /* Q_exc + Q14 */
     129             :         }
     130             : #if ( INTERP_EXP != -1 )
     131      600328 :         s = L_shl_o( s, INTERP_EXP + 1, &Overflow ); /* Q_exc + Q15 */
     132             : #endif
     133             : 
     134      600328 :         excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
     135      600328 :         move16();
     136             :     }
     137        9224 :     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       12668 : 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       12668 :     Flag Overflow = 0;
     182       12668 :     move32();
     183             : #endif
     184       12668 :     Copy( exc + sub( i_subfr, L_SUBFR ), excI, L_SUBFR * 2 ); /* Q0 */
     185             : 
     186       12668 :     test();
     187       12668 :     IF( LT_16( add( T0, sub( imp_pos, L_IMPULSE2 ) ), L_SUBFR ) && LT_16( T0, L_SUBFR ) )
     188             :     {
     189        1951 :         set16_fx( &excI[L_SUBFR - T0], 0, T0 );
     190        1951 :         set16_fx( excO, 0, L_SUBFR + 1 );
     191        1951 :         x0 = excI + ( L_SUBFR - ( L_INTERPOL2 - 1 ) );
     192             : 
     193        1951 :         IF( frac > 0 )
     194             :         {
     195         939 :             frac = sub( frac, UP_SAMP ); /* Q0 */
     196         939 :             x0--;
     197             :         }
     198             : 
     199        1951 :         l = add( UP_SAMP - 1, frac ); /* Q0 */
     200       37469 :         FOR( j = T0; j < L_SUBFR + 1; j++ )
     201             :         {
     202       35518 :             k = l;
     203       35518 :             move16();
     204       35518 :             L_sum = L_mult( x0[0], win[k] ); /* Q15 */
     205     1136576 :             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     1101058 :                 k += UP_SAMP;
     213     1101058 :                 L_sum = L_mac( L_sum, x0[i], win[k] ); /* Q15 */
     214             :             }
     215       35518 :             L_sum = L_shl_o( L_sum, 1, &Overflow );   /* Q16 */
     216       35518 :             excO[j] = round_fx_o( L_sum, &Overflow ); /* Q0 */
     217       35518 :             move16();
     218             : 
     219       35518 :             x0++;
     220             :         }
     221       35518 :         FOR( i = T0; i < L_SUBFR; i++ )
     222             :         {
     223       33567 :             exc[i + i_subfr] = add_o( exc[i + i_subfr], mult_r( PIT_SHARP_fx, excO[i] ), &Overflow ); /* Q0 */
     224       33567 :             move16();
     225             :         }
     226             :     }
     227             : 
     228       12668 :     return;
     229             : }

Generated by: LCOV version 1.14