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

Generated by: LCOV version 1.14