LCOV - code coverage report
Current view: top level - lib_com - lag_wind.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 6baab0c613aa6c7100498ed7b93676aa8198a493 Lines: 46 48 95.8 %
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 <assert.h>
      38             : #include <stdint.h>
      39             : #include "options.h"
      40             : #ifdef DEBUGGING
      41             : #include "debug.h"
      42             : #endif
      43             : #include "prot.h"
      44             : #include "cnst.h"
      45             : #include "rom_com.h"
      46             : #include "wmc_auto.h"
      47             : 
      48             : /*-------------------------------------------------------------------*
      49             :  * Local constants
      50             :  *-------------------------------------------------------------------*/
      51             : 
      52             : #define kLagWinThGain1 0.6f
      53             : #define kLagWinThGain2 0.3f
      54             : 
      55             : 
      56             : /*-------------------------------------------------------------*
      57             :  * procedure lag_wind()                                        *
      58             :  *           ~~~~~~~~~                                         *
      59             :  * lag windowing of the autocorrelations                       *
      60             :  *-------------------------------------------------------------*/
      61             : 
      62    37783310 : void lag_wind(
      63             :     float r[],             /* i/o: autocorrelations                       */
      64             :     const int16_t m,       /* i  : order of LP filter                     */
      65             :     const int32_t sr_core, /* i  : sampling rate                          */
      66             :     const int16_t strength /* i  : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
      67             : )
      68             : {
      69             :     int16_t i;
      70             :     const float *wnd;
      71             : 
      72    37783310 :     assert( 0 <= strength && strength <= NUM_LAGW_STRENGTHS );
      73             : 
      74    37783310 :     switch ( sr_core )
      75             :     {
      76        7730 :         case 8000:
      77        7730 :             assert( m <= 16 );
      78        7730 :             assert( strength == LAGW_STRONG );
      79        7730 :             wnd = lag_window_8k;
      80        7730 :             break;
      81    32424931 :         case 12800:
      82    32424931 :             assert( m <= 16 );
      83    32424931 :             wnd = lag_window_12k8[strength];
      84    32424931 :             break;
      85     4244919 :         case 16000:
      86     4244919 :             assert( m <= 16 );
      87     4244919 :             wnd = lag_window_16k[strength];
      88     4244919 :             break;
      89      101742 :         case 24000:
      90             :         case 25600:
      91      101742 :             assert( m <= 16 );
      92      101742 :             wnd = lag_window_25k6[strength];
      93      101742 :             break;
      94      895074 :         case 32000:
      95      895074 :             assert( m <= 16 );
      96      895074 :             wnd = lag_window_32k[strength];
      97      895074 :             break;
      98      108914 :         case 48000:
      99      108914 :             assert( m <= 16 );
     100      108914 :             assert( strength == LAGW_STRONG );
     101      108914 :             wnd = lag_window_48k;
     102      108914 :             break;
     103           0 :         default:
     104           0 :             assert( !"Lag window not implemented for this sampling rate" );
     105             :             return;
     106             :     }
     107             : 
     108   680099580 :     for ( i = 0; i <= m; ++i )
     109             :     {
     110   642316270 :         r[i] *= wnd[i];
     111             :     }
     112             : 
     113    37783310 :     return;
     114             : }
     115             : 
     116             : /*-------------------------------------------------------------*
     117             :  * procedure adapt_lag_wind()
     118             :  *
     119             :  *
     120             :  *-------------------------------------------------------------*/
     121             : 
     122    37447866 : void adapt_lag_wind(
     123             :     float r[],            /* i/o: autocorrelations                                       */
     124             :     const int16_t m,      /* i  : order of LP filter                                     */
     125             :     const int16_t Top,    /* i  : open loop pitch lags from curr. frame (or NULL if n/a) */
     126             :     const float Tnc,      /* i  : open loop pitch gains from curr. frame (NULL if n/a)   */
     127             :     const int32_t sr_core /* i  : core sampling rate                                     */
     128             : )
     129             : {
     130             :     int16_t strength;
     131             :     int16_t pitch_lag;
     132             :     float pitch_gain;
     133             : 
     134    37447866 :     pitch_lag = (int16_t) Top;
     135    37447866 :     pitch_gain = (float) Tnc;
     136             : 
     137    37447866 :     if ( pitch_lag < 80 )
     138             :     {
     139    22367442 :         if ( pitch_gain > kLagWinThGain1 )
     140             :         {
     141    11526381 :             strength = LAGW_STRONG;
     142             :         }
     143             :         else
     144             :         {
     145    10841061 :             strength = LAGW_MEDIUM;
     146             :         }
     147             :     }
     148    15080424 :     else if ( pitch_lag < 160 )
     149             :     {
     150    12028967 :         if ( pitch_gain > kLagWinThGain2 )
     151             :         {
     152    11303349 :             strength = LAGW_MEDIUM;
     153             :         }
     154             :         else
     155             :         {
     156      725618 :             strength = LAGW_WEAK;
     157             :         }
     158             :     }
     159             :     else
     160             :     {
     161     3051457 :         strength = LAGW_WEAK;
     162             :     }
     163             : 
     164    37447866 :     lag_wind( r, m, sr_core, strength );
     165             : 
     166    37447866 :     return;
     167             : }

Generated by: LCOV version 1.14