LCOV - code coverage report
Current view: top level - lib_dec - dec2t32_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 4c82f1d24d39d0296b18d775f18a006f4c7d024b Lines: 32 34 94.1 %
Date: 2025-05-17 01:59:02 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"    /* Common constants                       */
       7             : #include "prot_fx.h" /* Function prototypes                    */
       8             : 
       9             : 
      10             : /*==========================================================================*/
      11             : /* FUNCTION      : void dec_acelp_2t32_fx ()                                                            */
      12             : /*--------------------------------------------------------------------------*/
      13             : /* PURPOSE       :                                                              */
      14             : /*      * 12 bits algebraic codebook decoder.                                                                   */
      15             : /*  * 2 track x 32 positions per track = 64 samples.                                            */
      16             : /*  * 12 bits --> 2 pulses in a frame of 64 samples.                                         */
      17             : /*  * All pulses can have two (2) possible amplitudes: +1 or -1.                        */
      18             : /*  * Each pulse can have 32 possible positions.                                                        */
      19             : /*  * See cod2t32.c for more details of the algebraic code.                                     */
      20             : /*--------------------------------------------------------------------------*/
      21             : /* INPUT ARGUMENTS  :                                                                                                           */
      22             : /* _Word16 i_subfr,   i  : subframe index                                   */
      23             : /*--------------------------------------------------------------------------*/
      24             : /* OUTPUT ARGUMENTS :                                                                                                           */
      25             : /* _Word16 code[]     o  : algebraic (fixed) codebook excitation Q12        */
      26             : /*--------------------------------------------------------------------------*/
      27             : /* INPUT/OUTPUT ARGUMENTS :                                                                                                     */
      28             : /*--------------------------------------------------------------------------*/
      29             : /* RETURN ARGUMENTS :                                                                                                           */
      30             : /*                                       _ None                                                                                                 */
      31             : /*--------------------------------------------------------------------------*/
      32             : /* CALLED FROM :                                                                                                                        */
      33             : /*==========================================================================*/
      34             : 
      35       19441 : void dec_acelp_2t32_fx(
      36             :     Decoder_State *st_fx, /* i/o: decoder state structure */
      37             :     Word16 code[]         /* o:   algebraic (fixed) codebook excitation */
      38             : )
      39             : {
      40             : 
      41             :     Word16 index, i0, i1;
      42             : 
      43       19441 :     index = (Word16) get_next_indice_fx( st_fx, 12 );
      44       19441 :     move16();
      45             : 
      46       19441 :     set16_fx( code, 0, L_SUBFR );
      47             : 
      48             :     /*------------------------------------------------------------------------------------------*
      49             :      * decode the positions and signs of pulses and build the codeword
      50             :      *------------------------------------------------------------------------------------------*/
      51             : 
      52       19441 :     i0 = shl( s_and( shr( index, 6 ), NB_POS_FCB_2T - 1 ), 1 );
      53             : 
      54       19441 :     i1 = add( shl( s_and( index, NB_POS_FCB_2T - 1 ), 1 ), 1 );
      55             : 
      56             : 
      57       19441 :     code[i0] = -512;
      58       19441 :     move16();
      59       19441 :     IF( s_and( index, 0x800 ) == 0 )
      60             :     {
      61        9747 :         code[i0] = 512;
      62        9747 :         move16();
      63             :     }
      64             : 
      65       19441 :     code[i1] = -512;
      66       19441 :     move16();
      67       19441 :     IF( s_and( index, 0x20 ) == 0 )
      68             :     {
      69        9832 :         code[i1] = 512;
      70        9832 :         move16();
      71             :     }
      72       19441 : }
      73             : 
      74             : /*==========================================================================*/
      75             : /* FUNCTION      : void dec_acelp_1t64_fx ()                                                            */
      76             : /*--------------------------------------------------------------------------*/
      77             : /* PURPOSE       :       * 7 bits algebraic codebook.                                                   */
      78             : /*  * 1 track x 64 positions per track = 64 samples.                                            */
      79             : /*  * The pulse can have 64 possible positions and two (2) possible amplitudes: +1 or -1.*/
      80             : /*--------------------------------------------------------------------------*/
      81             : /* INPUT ARGUMENTS  :                                                                                                           */
      82             : /* _Word16 i_subfr,   i  : subframe index                                   */
      83             : /*--------------------------------------------------------------------------*/
      84             : /* OUTPUT ARGUMENTS :                                                                                                           */
      85             : /* _Word16 code[]     o  : algebraic (fixed) codebook excitation Q12        */
      86             : /*--------------------------------------------------------------------------*/
      87             : /* INPUT/OUTPUT ARGUMENTS :                                                                                                     */
      88             : /*--------------------------------------------------------------------------*/
      89             : /* RETURN ARGUMENTS :                                                                                                           */
      90             : /*                                       _ None                                                                                                 */
      91             : /*--------------------------------------------------------------------------*/
      92             : /* CALLED FROM :                                                                                                                        */
      93             : /*==========================================================================*/
      94         367 : void dec_acelp_1t64_fx(
      95             :     Decoder_State *st_fx, /* i/o: decoder state structure */
      96             :     Word16 code[],        /* o:   algebraic (fixed) codebook excitation Q12*/
      97             :     const Word16 L_subfr  /* i  : sub frame lenght*/
      98             : 
      99             : )
     100             : {
     101             :     Word16 pos, sgn;
     102             : 
     103             :     /*-----------------------------------------------------------------*
     104             :      * decode the positions and signs of pulses and build the codeword
     105             :      *-----------------------------------------------------------------*/
     106         367 :     IF( EQ_16( L_subfr, L_SUBFR ) )
     107             :     {
     108         367 :         pos = (Word16) get_next_indice_fx( st_fx, 7 );
     109         367 :         move16();
     110             :     }
     111             :     ELSE /* L_subfr == 2*L_SUBFR */
     112             :     {
     113           0 :         pos = (Word16) get_next_indice_fx( st_fx, 8 );
     114           0 :         move16();
     115             :     }
     116             : 
     117         367 :     sgn = -512;
     118         367 :     move16();
     119         367 :     IF( GE_16( pos, L_subfr ) )
     120             :     {
     121         159 :         pos = sub( pos, L_subfr );
     122         159 :         move16();
     123         159 :         sgn = 512;
     124         159 :         move16();
     125             :     }
     126         367 :     set16_fx( code, 0, L_subfr );
     127         367 :     code[pos] = sgn;
     128         367 :     move16();
     129         367 :     return;
     130             : }

Generated by: LCOV version 1.14