LCOV - code coverage report
Current view: top level - lib_enc - diffcod_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 43b7b28dcb1471ff5d355252c4b8f37ee7ecc268 Lines: 45 67 67.2 %
Date: 2025-11-02 02:02:47 Functions: 2 2 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"        /* Compilation switches                   */
       8             : #include "rom_com.h"     /* Static table prototypes                */
       9             : #include "prot_fx.h"     /* Function prototypes                    */
      10             : #include "prot_fx_enc.h" /* Function prototypes                    */
      11             : 
      12             : 
      13             : /*--------------------------------------------------------------------------*/
      14             : /*  Function  diffcod                                                       */
      15             : /*  ~~~~~~~~~~~~~~~~~                                                       */
      16             : /*                                                                          */
      17             : /*  Differential coding for indices of quantized norms                      */
      18             : /*--------------------------------------------------------------------------*/
      19             : 
      20        9660 : void diffcod_fx(
      21             :     const Word16 N, /* i  : number of sub-vectors      Q0*/
      22             :     Word16 *y,      /* i/o: indices of quantized norms Q0*/
      23             :     Word16 *difidx  /* o  : differential code          Q0*/
      24             : )
      25             : {
      26             :     Word16 i, k, r;
      27             : 
      28      265309 :     FOR( i = N - 1; i > 0; i-- )
      29             :     {
      30      255649 :         r = sub( i, 1 );
      31      255649 :         move16();
      32      255649 :         k = sub( y[i], y[r] );
      33      255649 :         move16();
      34      255649 :         if ( LT_16( k, -15 ) )
      35             :         {
      36          16 :             y[r] = add( y[i], 15 );
      37          16 :             move16();
      38             :         }
      39             :     }
      40             : 
      41      265309 :     FOR( i = 1; i < N; i++ )
      42             :     {
      43      255649 :         r = sub( i, 1 );
      44      255649 :         move16();
      45      255649 :         k = sub( y[i], y[r] );
      46      255649 :         move16();
      47      255649 :         IF( GT_16( k, 16 ) )
      48             :         {
      49           0 :             k = 16;
      50           0 :             move16();
      51           0 :             y[i] = add( y[r], 16 );
      52           0 :             move16();
      53             :         }
      54      255649 :         difidx[r] = add( k, 15 );
      55      255649 :         move16();
      56             :     }
      57             : 
      58        9660 :     return;
      59             : }
      60             : 
      61             : 
      62             : /*--------------------------------------------------------------------------
      63             :  * diffcod_lrmdct()
      64             :  *
      65             :  * Differential coding for indices of quantized norms
      66             :  *--------------------------------------------------------------------------*/
      67             : 
      68           1 : void diffcod_lrmdct_fx(
      69             :     const Word16 N,           /* i  : number of sub-vectors       Q0*/
      70             :     const Word16 be_ref,      /* i  : band energy reference       Q0*/
      71             :     Word16 *y,                /* i/o: indices of quantized norms  Q0*/
      72             :     Word16 *difidx,           /* o  : differential code           Q0*/
      73             :     const Word16 is_transient /* i  : transient flag              Q0*/
      74             : )
      75             : {
      76             :     Word16 i, m, r;
      77             :     Word16 k;
      78             :     Word16 thr_l, thr_h;
      79             : 
      80           1 :     IF( is_transient )
      81             :     {
      82           1 :         thr_l = -15;
      83           1 :         move16();
      84           1 :         thr_h = 16;
      85           1 :         move16();
      86             :     }
      87             :     ELSE
      88             :     {
      89           0 :         thr_l = -32;
      90           0 :         move16();
      91           0 :         thr_h = 31;
      92           0 :         move16();
      93             :     }
      94             : 
      95           1 :     difidx[0] = sub( y[0], be_ref );
      96           1 :     move16();
      97           1 :     IF( GT_16( difidx[0], thr_h ) )
      98             :     {
      99           0 :         difidx[0] = thr_h;
     100           0 :         move16();
     101           0 :         y[0] = add( be_ref, thr_h );
     102           0 :         move16();
     103             :     }
     104             : 
     105           1 :     IF( LT_16( difidx[0], thr_l ) )
     106             :     {
     107           0 :         difidx[0] = thr_l;
     108           0 :         move16();
     109           0 :         y[0] = add( be_ref, thr_l );
     110           0 :         move16();
     111             :     }
     112             : 
     113           1 :     m = sub( N, 1 );
     114           1 :     move16();
     115          32 :     FOR( i = m; i > 0; i-- )
     116             :     {
     117          31 :         r = sub( i, 1 );
     118          31 :         move16();
     119          31 :         k = sub( y[i], y[r] );
     120          31 :         move16();
     121          31 :         if ( LT_16( k, thr_l ) )
     122             :         {
     123           0 :             y[r] = sub( y[i], thr_l );
     124           0 :             move16();
     125             :         }
     126             :     }
     127             : 
     128          32 :     FOR( i = 1; i < N; i++ )
     129             :     {
     130          31 :         r = sub( i, 1 );
     131          31 :         move16();
     132          31 :         k = sub( y[i], y[r] );
     133          31 :         move16();
     134          31 :         IF( GT_16( k, thr_h ) )
     135             :         {
     136           0 :             k = thr_h;
     137           0 :             move16();
     138           0 :             y[i] = add( y[r], thr_h );
     139           0 :             move16();
     140             :         }
     141          31 :         difidx[i] = k;
     142          31 :         move16();
     143             :     }
     144             : 
     145           1 :     return;
     146             : }

Generated by: LCOV version 1.14