LCOV - code coverage report
Current view: top level - lib_com - lag_wind.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 41 48 85.4 %
Date: 2025-05-23 08:37:30 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     2761571 : 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     2761571 :     assert( 0 <= strength && strength <= NUM_LAGW_STRENGTHS );
      73             : 
      74     2761571 :     switch ( sr_core )
      75             :     {
      76           0 :         case 8000:
      77           0 :             assert( m <= 16 );
      78           0 :             assert( strength == LAGW_STRONG );
      79           0 :             wnd = lag_window_8k;
      80           0 :             break;
      81     2307668 :         case 12800:
      82     2307668 :             assert( m <= 16 );
      83     2307668 :             wnd = lag_window_12k8[strength];
      84     2307668 :             break;
      85      334261 :         case 16000:
      86      334261 :             assert( m <= 16 );
      87      334261 :             wnd = lag_window_16k[strength];
      88      334261 :             break;
      89       10070 :         case 24000:
      90             :         case 25600:
      91       10070 :             assert( m <= 16 );
      92       10070 :             wnd = lag_window_25k6[strength];
      93       10070 :             break;
      94      104553 :         case 32000:
      95      104553 :             assert( m <= 16 );
      96      104553 :             wnd = lag_window_32k[strength];
      97      104553 :             break;
      98        5019 :         case 48000:
      99        5019 :             assert( m <= 16 );
     100        5019 :             assert( strength == LAGW_STRONG );
     101        5019 :             wnd = lag_window_48k;
     102        5019 :             break;
     103           0 :         default:
     104           0 :             assert( !"Lag window not implemented for this sampling rate" );
     105             :             return;
     106             :     }
     107             : 
     108    49708278 :     for ( i = 0; i <= m; ++i )
     109             :     {
     110    46946707 :         r[i] *= wnd[i];
     111             :     }
     112             : 
     113     2761571 :     return;
     114             : }
     115             : 
     116             : /*-------------------------------------------------------------*
     117             :  * procedure adapt_lag_wind()
     118             :  *
     119             :  *
     120             :  *-------------------------------------------------------------*/
     121             : 
     122     2748353 : 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     2748353 :     pitch_lag = (int16_t) Top;
     135     2748353 :     pitch_gain = (float) Tnc;
     136             : 
     137     2748353 :     if ( pitch_lag < 80 )
     138             :     {
     139     1665929 :         if ( pitch_gain > kLagWinThGain1 )
     140             :         {
     141     1051769 :             strength = LAGW_STRONG;
     142             :         }
     143             :         else
     144             :         {
     145      614160 :             strength = LAGW_MEDIUM;
     146             :         }
     147             :     }
     148     1082424 :     else if ( pitch_lag < 160 )
     149             :     {
     150      844859 :         if ( pitch_gain > kLagWinThGain2 )
     151             :         {
     152      828964 :             strength = LAGW_MEDIUM;
     153             :         }
     154             :         else
     155             :         {
     156       15895 :             strength = LAGW_WEAK;
     157             :         }
     158             :     }
     159             :     else
     160             :     {
     161      237565 :         strength = LAGW_WEAK;
     162             :     }
     163             : 
     164     2748353 :     lag_wind( r, m, sr_core, strength );
     165             : 
     166     2748353 :     return;
     167             : }

Generated by: LCOV version 1.14