LCOV - code coverage report
Current view: top level - lib_com - nelp.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 6baab0c613aa6c7100498ed7b93676aa8198a493 Lines: 42 42 100.0 %
Date: 2025-05-29 08:28:55 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : /*====================================================================================
      34             :     EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
      35             :   ====================================================================================*/
      36             : 
      37             : #include <stdint.h>
      38             : #include "options.h"
      39             : #include <math.h>
      40             : #include "rom_com.h"
      41             : #include "prot.h"
      42             : #include "wmc_auto.h"
      43             : 
      44             : /*-------------------------------------------------------------------*
      45             :  * dequantize_uvg()
      46             :  *
      47             :  * Dequantize unvoiced gains
      48             :  *--------------------------------------------------------------------*/
      49             : 
      50         636 : void dequantize_uvg(
      51             :     int16_t iG1,         /* i  : gain 1 index      */
      52             :     int16_t *iG2,        /* i  : gain 2 index      */
      53             :     float *G,            /* o  : quantized gain    */
      54             :     const int16_t bwidth /* i  : audio bandwidth   */
      55             : )
      56             : {
      57             :     int16_t i, k;
      58         636 :     const float( *UVG1CB )[2] = NULL;
      59         636 :     const float( *UVG2CB1 )[5] = NULL;
      60         636 :     const float( *UVG2CB2 )[5] = NULL;
      61             : 
      62         636 :     if ( bwidth == NB )
      63             :     {
      64         328 :         UVG1CB = UVG1CB_NB;
      65         328 :         UVG2CB1 = UVG2CB1_NB;
      66         328 :         UVG2CB2 = UVG2CB2_NB;
      67             :     }
      68             : 
      69         308 :     else if ( bwidth == WB || bwidth == SWB )
      70             :     {
      71         308 :         UVG1CB = UVG1CB_WB;
      72         308 :         UVG2CB1 = UVG2CB1_WB;
      73         308 :         UVG2CB2 = UVG2CB2_WB;
      74             :     }
      75             : 
      76        1908 :     for ( i = 0; i < 2; i++ )
      77             :     {
      78        7632 :         for ( k = 0; k < 5; k++ )
      79             :         {
      80        6360 :             if ( i == 0 )
      81             :             {
      82        3180 :                 G[i * 5 + k] = (float) pow( 10.0, UVG1CB[iG1][i] ) * UVG2CB1[iG2[i]][k];
      83             :             }
      84        3180 :             else if ( i == 1 )
      85             :             {
      86        3180 :                 G[i * 5 + k] = (float) pow( 10.0, UVG1CB[iG1][i] ) * UVG2CB2[iG2[i]][k];
      87             :             }
      88             :         }
      89             :     }
      90             : 
      91         636 :     return;
      92             : }
      93             : 
      94             : /*-------------------------------------------------------------------*
      95             :  * generate_nelp_excitation()
      96             :  *
      97             :  * Generate excitation for NELP coding.
      98             :  *--------------------------------------------------------------------*/
      99             : 
     100         636 : void generate_nelp_excitation(
     101             :     int16_t *seed, /* i/o: random number seed    */
     102             :     float *Gains,  /* i  : excitation gains      */
     103             :     float *output, /* o  : excitation output     */
     104             :     float gain_fac /* i  : gain factor           */
     105             : )
     106             : {
     107             :     int16_t i, len, j;
     108             :     float tmp[31], tmp1[31], tmpf;
     109             :     int16_t k1, k2, I[31], tmpi;
     110             : 
     111        6996 :     for ( i = 0; i < 10; i++ )
     112             :     {
     113        6360 :         if ( i == 9 )
     114             :         {
     115         636 :             len = 31;
     116             :         }
     117             :         else
     118             :         {
     119        5724 :             len = 25;
     120             :         }
     121             : 
     122      169176 :         for ( j = 0; j < len; j++ )
     123             :         {
     124      162816 :             tmp[j] = ( ( *seed ) = (int16_t) ( 521 * ( *seed ) + 259 ) ) / PCM16_TO_FLT_FAC;
     125      162816 :             tmp1[j] = ABSVAL( tmp[j] );
     126      162816 :             I[j] = j;
     127             :         }
     128      162816 :         for ( k1 = 0; k1 < len - 1; k1++ )
     129             :         {
     130     2169396 :             for ( k2 = k1 + 1; k2 < len; k2++ )
     131             :             {
     132     2012940 :                 if ( tmp1[k2] > tmp1[k1] )
     133             :                 {
     134     1011200 :                     tmpi = I[k2];
     135     1011200 :                     tmpf = tmp1[k2];
     136     1011200 :                     tmp1[k2] = tmp1[k1];
     137     1011200 :                     I[k2] = I[k1];
     138     1011200 :                     tmp1[k1] = tmpf;
     139     1011200 :                     I[k1] = tmpi;
     140             :                 }
     141             :             }
     142             :         }
     143             : 
     144             :         /*using a factor of 1.37 to compensate for the ~ 2.5 ( or 2.73) dB diff between this scheme and EVS-UV */
     145       45792 :         for ( j = 0; j < (int16_t) rint_new( len / 4.0f ); j++ )
     146             :         {
     147       39432 :             output[i * 25 + I[j]] = (float) ( Gains[i] * sqrt( 3.0f ) * tmp[I[j]] * gain_fac );
     148             :         }
     149      129744 :         for ( ; j < len; j++ )
     150             :         {
     151      123384 :             output[i * 25 + I[j]] = 0;
     152             :         }
     153             :     }
     154             : 
     155         636 :     return;
     156             : }

Generated by: LCOV version 1.14