LCOV - code coverage report
Current view: top level - lib_com - ivas_lfe_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 33 55 60.0 %
Date: 2025-05-03 01:55:50 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             : #include "ivas_stat_com.h"
      37             : #include "prot_fx.h"
      38             : #include "rom_com.h"
      39             : #include "ivas_rom_com.h"
      40             : #include "cnst.h"
      41             : #include <assert.h>
      42             : #include "wmc_auto.h"
      43             : #include "ivas_prot_fx.h"
      44             : #include "ivas_rom_com_fx.h"
      45             : 
      46             : 
      47             : /*-----------------------------------------------------------------------------------------*
      48             :  * Function ivas_lfe_lpf_select_filt_coeff()
      49             :  *
      50             :  * Selects LFE filter coeff based on config.
      51             :  *-----------------------------------------------------------------------------------------*/
      52          81 : void ivas_lfe_lpf_select_filt_coeff_fx(
      53             :     const Word32 sampling_rate,     /* i  : sampling rate          */
      54             :     const Word16 order,             /* i  : filter order           */
      55             :     const Word32 **ppFilt_coeff_fx, /* o  : filter coefficients    */
      56             :     const Word16 **ppFilt_coeff_e   /* o  : exponents of filter coefficients        */
      57             : )
      58             : {
      59          81 :     SWITCH( order )
      60             :     {
      61           0 :         case IVAS_FILTER_ORDER_2:
      62             :             SWITCH( sampling_rate )
      63             :             {
      64           0 :                 case 16000:
      65           0 :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_16k_fx; // Q30
      66           0 :                     BREAK;
      67           0 :                 case 32000:
      68           0 :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_32k_fx; // Q30
      69           0 :                     BREAK;
      70           0 :                 case 48000:
      71           0 :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_48k_fx; // Q30
      72           0 :                     BREAK;
      73           0 :                 default:
      74           0 :                     BREAK;
      75             :             }
      76           0 :             BREAK;
      77          81 :         case IVAS_FILTER_ORDER_4:
      78             :             SWITCH( sampling_rate )
      79             :             {
      80           0 :                 case 16000:
      81           0 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_16k_sos_fx; // Q31-ivas_lpf_4_butter_16k_sos_e
      82           0 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_16k_sos_e;
      83           0 :                     BREAK;
      84           1 :                 case 32000:
      85           1 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_32k_sos_fx; // Q31-ivas_lpf_4_butter_32k_sos_e
      86           1 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_32k_sos_e;
      87           1 :                     BREAK;
      88          80 :                 case 48000:
      89          80 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_48k_sos_fx; // Q31-ivas_lpf_4_butter_48k_sos_e
      90          80 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_48k_sos_e;
      91          80 :                     BREAK;
      92           0 :                 default:
      93           0 :                     BREAK;
      94             :             }
      95          81 :             BREAK;
      96           0 :         default:
      97           0 :             assert( !"Unsupported LFE Filter order" );
      98             :     }
      99             : 
     100          81 :     return;
     101             : }
     102             : 
     103             : 
     104             : /*-----------------------------------------------------------------------------------------*
     105             :  * Function ivas_lfe_window_init()
     106             :  *
     107             :  * Initialize LFE window
     108             :  *-----------------------------------------------------------------------------------------*/
     109             : 
     110         639 : void ivas_lfe_window_init_fx(
     111             :     LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle           */
     112             :     const Word32 sampling_rate,   /* i  : sampling rate               */
     113             :     const Word16 frame_len        /* i  : frame length in samples     */
     114             : )
     115             : {
     116             :     /* Set window coefficients */
     117         639 :     IF( EQ_32( sampling_rate, 48000 ) )
     118             :     {
     119         508 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_48k_fx; // Q31
     120             :     }
     121         131 :     ELSE IF( EQ_32( sampling_rate, 32000 ) )
     122             :     {
     123          64 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_32k_fx; // Q31
     124             :     }
     125          67 :     ELSE IF( EQ_32( sampling_rate, 16000 ) )
     126             :     {
     127          67 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_16k_fx; // Q31
     128             :     }
     129             :     ELSE
     130             :     {
     131           0 :         assert( !"8kHz LFE Window not supported" );
     132             :     }
     133             : 
     134             :     /* 10ms stride, MDCT will be done in two iterations */
     135         639 :     hLFEWindow->dct_len = shr( frame_len, 1 );
     136         639 :     move16();
     137             : 
     138             :     /* 8ms of latency */
     139         639 :     hLFEWindow->fade_len = NS2SA_FX2( sampling_rate, IVAS_LFE_FADE_NS );
     140         639 :     hLFEWindow->zero_pad_len = ( mult( IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub( hLFEWindow->dct_len, hLFEWindow->fade_len ) ) );
     141         639 :     hLFEWindow->full_len = add( add( hLFEWindow->zero_pad_len, hLFEWindow->fade_len ), hLFEWindow->dct_len );
     142         639 :     move16();
     143         639 :     move16();
     144         639 :     move16();
     145             : 
     146         639 :     move16();
     147         639 :     move16();
     148         639 :     move16();
     149         639 :     move16();
     150             : 
     151         639 :     return;
     152             : }

Generated by: LCOV version 1.14