LCOV - code coverage report
Current view: top level - lib_com - ivas_lfe_com.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 26 31 83.9 %
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             : #include <stdint.h>
      34             : #include "math.h"
      35             : #include "options.h"
      36             : #ifdef DEBUGGING
      37             : #include "debug.h"
      38             : #endif
      39             : #include "ivas_stat_com.h"
      40             : #include "prot.h"
      41             : #include "ivas_prot.h"
      42             : #include "rom_com.h"
      43             : #include "ivas_rom_com.h"
      44             : #include "cnst.h"
      45             : #include <assert.h>
      46             : #include "wmc_auto.h"
      47             : 
      48             : 
      49             : /*-----------------------------------------------------------------------------------------*
      50             :  * Function ivas_lfe_lpf_select_filt_coeff()
      51             :  *
      52             :  * Selects LFE filter coeff based on config.
      53             :  *-----------------------------------------------------------------------------------------*/
      54             : 
      55         370 : void ivas_lfe_lpf_select_filt_coeff(
      56             :     const int32_t sampling_rate, /* i  : sampling rate          */
      57             :     const int16_t order,         /* i  : filter order           */
      58             :     const float **ppFilt_coeff   /* o  : filter coefficients    */
      59             : )
      60             : {
      61         370 :     switch ( order )
      62             :     {
      63         370 :         case IVAS_FILTER_ORDER_4:
      64             :             switch ( sampling_rate )
      65             :             {
      66         117 :                 case 16000:
      67         117 :                     *ppFilt_coeff = ivas_lpf_4_butter_16k_sos;
      68         117 :                     break;
      69           1 :                 case 32000:
      70           1 :                     *ppFilt_coeff = ivas_lpf_4_butter_32k_sos;
      71           1 :                     break;
      72         252 :                 case 48000:
      73         252 :                     *ppFilt_coeff = ivas_lpf_4_butter_48k_sos;
      74         252 :                     break;
      75           0 :                 default:
      76           0 :                     break;
      77             :             }
      78         370 :             break;
      79           0 :         default:
      80           0 :             assert( !"Unsupported LFE Filter order" );
      81             :     }
      82             : 
      83         370 :     return;
      84             : }
      85             : 
      86             : 
      87             : /*-----------------------------------------------------------------------------------------*
      88             :  * Function ivas_lfe_window_init()
      89             :  *
      90             :  * Initialize LFE window
      91             :  *-----------------------------------------------------------------------------------------*/
      92             : 
      93        1423 : void ivas_lfe_window_init(
      94             :     LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle           */
      95             :     const int32_t sampling_rate,  /* i  : sampling rate               */
      96             :     const int16_t frame_len       /* i  : frame length in samples     */
      97             : )
      98             : {
      99             :     /* Set window coefficients */
     100        1423 :     if ( sampling_rate == 48000 )
     101             :     {
     102        1117 :         hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_48k;
     103             :     }
     104         306 :     else if ( sampling_rate == 32000 )
     105             :     {
     106          96 :         hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_32k;
     107             :     }
     108         210 :     else if ( sampling_rate == 16000 )
     109             :     {
     110         210 :         hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_16k;
     111             :     }
     112             :     else
     113             :     {
     114           0 :         assert( !"8kHz LFE Window not supported" );
     115             :     }
     116             : 
     117             :     /* 10ms stride, MDCT will be done in two iterations */
     118        1423 :     hLFEWindow->dct_len = frame_len >> 1;
     119             : 
     120             :     /* 8ms of latency */
     121        1423 :     hLFEWindow->fade_len = NS2SA( sampling_rate, IVAS_LFE_FADE_NS );
     122        1423 :     hLFEWindow->zero_pad_len = (int16_t) ( IVAS_ZERO_PAD_LEN_MULT_FAC * ( hLFEWindow->dct_len - hLFEWindow->fade_len ) );
     123        1423 :     hLFEWindow->full_len = hLFEWindow->zero_pad_len + hLFEWindow->fade_len + hLFEWindow->dct_len;
     124             : 
     125        1423 :     return;
     126             : }

Generated by: LCOV version 1.14