LCOV - code coverage report
Current view: top level - lib_dec - FEC_pitch_estim_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 4c82f1d24d39d0296b18d775f18a006f4c7d024b Lines: 41 41 100.0 %
Date: 2025-05-17 01:59:02 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : #include <stdint.h>
       5             : #include "options.h" /* Compilation switches                   */
       6             : #include "cnst.h"    /* Common constants                       */
       7             : #include "prot_fx.h" /* Function prototypes                    */
       8             : #include "stl.h"
       9             : 
      10             : 
      11             : /*========================================================================*/
      12             : /* FUNCTION : FEC_pitch_estim_fx()                                                                                */
      13             : /*------------------------------------------------------------------------*/
      14             : /* PURPOSE :  Estimation of pitch for FEC                                                                 */
      15             : /*                                                                                                                                                */
      16             : /*------------------------------------------------------------------------*/
      17             : /* INPUT ARGUMENTS :                                                                                                      */
      18             : /* _ (Word16) st_fx->Opt_AMR_WB: flag indicating AMR-WB IO mode                */
      19             : /* _ (Word16) st_fx->L_frame_fx:  length of the frame                                          */
      20             : /* _ (Word16) st_fx->clas_dec: frame classification                                            */
      21             : /* _ (Word16) st_fx->last_good: last good clas information                     */
      22             : /* _ (Word16[])  pitch    : pitch values for each subframe          Q6    */
      23             : /* _ (Word16[])  old_pitch_buf:pitch values for each subframe           Q6    */
      24             : /*------------------------------------------------------------------------*/
      25             : /* INPUT/OUTPUT ARGUMENTS :                                                                                               */
      26             : /*------------------------------------------------------------------------*/
      27             : /* OUTPUT ARGUMENTS :                                                                                                     */
      28             : /*------------------------------------------------------------------------*/
      29             : 
      30             : /* _ (Word16[]) st_fx->bfi_pitch       : initial synthesis filter states   */
      31             : /* _ (Word16) st_fx->bfi_pitch_frame: LP filter E of last                 */
      32             : /* _ (Word16) st_fx->upd_cnt_fx: update counter                           */
      33             : /*------------------------------------------------------------------------*/
      34             : /* RETURN ARGUMENTS :                                                                                                     */
      35             : /* _ None                                                                                                                                 */
      36             : /*========================================================================*/
      37      140126 : void FEC_pitch_estim_fx(
      38             :     const Word16 Opt_AMR_WB,      /* i  : flag indicating AMR-WB IO mode             */
      39             :     const Word16 last_core,       /* i  : last core                                  */
      40             :     const Word16 L_frame,         /* i  : length of the frame                        */
      41             :     const Word16 clas,            /* i  : current frame classification               */
      42             :     const Word16 last_good,       /* i  : last good clas information                 */
      43             :     const Word16 pitch_buf[],     /* i  : Floating pitch   for each subframe        Q6 */
      44             :     const Word32 old_pitch_buf[], /* i  : buffer of old subframe pitch values 15Q16  */
      45             :     Word16 *bfi_pitch,            /* i/o: update of the estimated pitch for FEC      Q6*/
      46             :     Word16 *bfi_pitch_frame,      /* o  : frame length when pitch was updated        */
      47             :     Word16 *upd_cnt               /* i/o: update counter                             */
      48             :     ,
      49             :     const Word16 coder_type, /* i  : coder_type                                 */
      50             :     Word16 element_mode      /* i  : element mode                                  */
      51             : )
      52             : {
      53             :     Word16 tmp, tmp1, tmp2, tmp3;
      54             :     Word16 tmp16k1, tmp16k2;
      55             : 
      56      140126 :     tmp = mult_r( pitch_buf[1], 22938 );                                                  /*Q6( 0.7f * pitch_buf[1] 0.7 in Q15)*/
      57      140126 :     tmp1 = shl( tmp, 1 );                                                                 /*Q6 (1.4f * pitch_buf[1])*/
      58      140126 :     tmp2 = round_fx( L_shl( Mpy_32_16_1( old_pitch_buf[2 * NB_SUBFR - 1], 22938 ), 6 ) ); /*Q6 (0.7f * old_pitch_buf[2*NB_SUBFR-1])*/
      59      140126 :     tmp3 = shl_sat( tmp2, 1 );                                                            /*Q6 (1.4f * old_pitch_buf[2*NB_SUBFR-1])*/
      60             : 
      61      140126 :     tmp16k1 = round_fx( L_shl( Mpy_32_16_1( old_pitch_buf[2 * NB_SUBFR16k - 1], 22938 ), 6 ) ); /*Q6 0.7f * old_pitch_buf[2*NB_SUBFR16k-1]*/
      62      140126 :     tmp16k2 = shl_sat( tmp16k1, 1 );                                                            /*Q6 1.4f * old_pitch_buf[2*NB_SUBFR16k-1]*/
      63             : 
      64      140126 :     test();
      65      140126 :     test();
      66      140126 :     test();
      67      140126 :     test();
      68      140126 :     test();
      69      140126 :     IF( ( ( element_mode == EVS_MONO ) && EQ_16( last_core, HQ_CORE ) ) || ( element_mode != EVS_MONO && ( EQ_16( last_core, HQ_CORE ) || EQ_16( last_core, TCX_20_CORE ) || EQ_16( last_core, TCX_10_CORE ) ) ) )
      70             :     {
      71        6019 :         *bfi_pitch = pitch_buf[sub( shr( L_frame, 6 ), 1 )];
      72        6019 :         move16();
      73        6019 :         *bfi_pitch_frame = L_frame;
      74        6019 :         move16();
      75        6019 :         *upd_cnt = MAX_UPD_CNT;
      76        6019 :         move16();
      77             :     }
      78             : 
      79      140126 :     test();
      80      140126 :     test();
      81      140126 :     test();
      82      140126 :     IF( ( EQ_16( clas, VOICED_CLAS ) && GE_16( last_good, VOICED_TRANSITION ) ) || ( Opt_AMR_WB && EQ_16( clas, VOICED_CLAS ) ) )
      83             :     {
      84       66969 :         test();
      85       66969 :         test();
      86       66969 :         test();
      87       66969 :         test();
      88       66969 :         test();
      89       66969 :         test();
      90       66969 :         test();
      91       66969 :         test();
      92       66969 :         test();
      93       66969 :         test();
      94       66969 :         IF( ( ( LT_16( pitch_buf[3], tmp1 ) ) && ( GT_16( pitch_buf[3], tmp ) ) &&
      95             :               ( LT_16( pitch_buf[1], tmp3 ) ) && ( GT_16( pitch_buf[1], tmp2 ) ) &&
      96             :               ( EQ_16( L_frame, L_FRAME ) ) ) ||
      97             :             ( ( LT_16( pitch_buf[3], tmp1 ) ) && ( GT_16( pitch_buf[3], tmp ) ) &&
      98             :               ( LT_16( pitch_buf[1], tmp16k2 ) ) && ( GT_16( pitch_buf[1], tmp16k1 ) ) &&
      99             :               ( EQ_16( L_frame, L_FRAME16k ) ) ) ||
     100             :             ( EQ_16( coder_type, TRANSITION ) ) )
     101             :         {
     102       59746 :             *bfi_pitch = pitch_buf[sub( shr( L_frame, 6 ), 1 )];
     103       59746 :             move16();
     104       59746 :             *bfi_pitch_frame = L_frame;
     105       59746 :             move16();
     106       59746 :             *upd_cnt = 0;
     107       59746 :             move16();
     108             :         }
     109             :     }
     110      140126 : }

Generated by: LCOV version 1.14