LCOV - code coverage report
Current view: top level - lib_com - hp50.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 33 37 89.2 %
Date: 2025-05-23 08:37:30 Functions: 1 1 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             : #ifdef DEBUGGING
      40             : #include "debug.h"
      41             : #endif
      42             : #include "prot.h"
      43             : #include "wmc_auto.h"
      44             : 
      45             : 
      46             : /*
      47             :  * hp20
      48             :  *
      49             :  * Function:
      50             :  *    2nd order high pass filter with nominal cut off frequency at 20 Hz.
      51             :  *
      52             :  * Returns:
      53             :  *    void
      54             :  */
      55             : 
      56     5061863 : void hp20(
      57             :     Float32 signal[],
      58             :     const Word16 lg,
      59             :     Float32 mem[],
      60             :     const Word32 Fs )
      61             : {
      62             :     Word16 i;
      63             :     Float32 x0, x1, x2, y0, y1, y2;
      64             :     Float32 a1, a2, b1, b2;
      65             : 
      66     5061863 :     y1 = mem[0];
      67     5061863 :     y2 = mem[1];
      68     5061863 :     x0 = mem[2];
      69     5061863 :     x1 = mem[3];
      70             : 
      71     5061863 :     if ( Fs == 8000 )
      72             :     {
      73             :         /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
      74             :            [b,a] = butter(2, 20.0/4000.0, 'high');
      75             :            b = [0.988954248067140  -1.977908496134280   0.988954248067140]
      76             :            a =[1.000000000000000  -1.977786483776764   0.978030508491796]*/
      77           0 :         a1 = 1.977786483776764f;
      78           0 :         a2 = -0.978030508491796f;
      79           0 :         b1 = -1.977908496134280f;
      80           0 :         b2 = 0.988954248067140f;
      81             :     }
      82     5061863 :     else if ( Fs == 16000 )
      83             :     {
      84             :         /* hp filter 20Hz at 3dB for 16000KHz sampling rate
      85             :            [b,a] = butter(2, 20.0/8000.0, 'high');
      86             :            b =[ 0.994461788958195  -1.988923577916390   0.994461788958195]
      87             :            a =[1.000000000000000  -1.988892905899653   0.988954249933127] */
      88      404529 :         a1 = 1.988892905899653f;
      89      404529 :         a2 = -0.988954249933127f;
      90      404529 :         b1 = -1.988923577916390f;
      91      404529 :         b2 = 0.994461788958195f;
      92             :     }
      93     4657334 :     else if ( Fs == 32000 )
      94             :     {
      95             :         /* hp filter 20Hz at 3dB for 32000KHz sampling rate
      96             :            [b,a] = butter(2, 20.0/16000.0, 'high');
      97             :            b =[0.997227049904470  -1.994454099808940   0.997227049904470]
      98             :            a =[1.000000000000000  -1.994446410541927   0.994461789075954]*/
      99     1127682 :         a1 = 1.994446410541927f;
     100     1127682 :         a2 = -0.994461789075954f;
     101     1127682 :         b1 = -1.994454099808940f;
     102     1127682 :         b2 = 0.997227049904470f;
     103             :     }
     104             :     else
     105             :     {
     106             :         /* hp filter 20Hz at 3dB for 48000KHz sampling rate
     107             :            [b,a] = butter(2, 20.0/24000.0, 'high');
     108             :            b =[ 0.998150511190452  -1.996301022380904   0.998150511190452]
     109             :            a =[1.000000000000000  -1.996297601769122   0.996304442992686]*/
     110     3529652 :         a1 = 1.996297601769122f;
     111     3529652 :         a2 = -0.996304442992686f;
     112     3529652 :         b1 = -1.996301022380904f;
     113     3529652 :         b2 = 0.998150511190452f;
     114             :     }
     115             : 
     116  4244693543 :     for ( i = 0; i < lg; i++ )
     117             :     {
     118  4239631680 :         x2 = x1;
     119  4239631680 :         x1 = x0;
     120  4239631680 :         x0 = signal[i];
     121  4239631680 :         y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 );
     122  4239631680 :         signal[i] = y0;
     123  4239631680 :         y2 = y1;
     124  4239631680 :         y1 = y0;
     125             :     }
     126             : 
     127     5061863 :     mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0;
     128     5061863 :     mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0;
     129     5061863 :     mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0;
     130     5061863 :     mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0;
     131             : 
     132     5061863 :     return;
     133             : }

Generated by: LCOV version 1.14