LCOV - code coverage report
Current view: top level - lib_com - ivas_lfe_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 633e3f2e309758d10805ef21e0436356fe719b7a Lines: 29 42 69.0 %
Date: 2025-08-23 01:22:27 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           8 : 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           8 :     SWITCH( order )
      60             :     {
      61             : 
      62             : #ifndef NONBE_FIX_MC_LFE_LPF
      63             :         case IVAS_FILTER_ORDER_2:
      64             :             SWITCH( sampling_rate )
      65             :             {
      66             :                 case 16000:
      67             :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_16k_fx; // Q30
      68             :                     BREAK;
      69             :                 case 32000:
      70             :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_32k_fx; // Q30
      71             :                     BREAK;
      72             :                 case 48000:
      73             :                     *ppFilt_coeff_fx = ivas_lpf_2_butter_48k_fx; // Q30
      74             :                     BREAK;
      75             :                 default:
      76             :                     BREAK;
      77             :             }
      78             :             BREAK;
      79             : #endif
      80           8 :         case IVAS_FILTER_ORDER_4:
      81             :             SWITCH( sampling_rate )
      82             :             {
      83           0 :                 case 16000:
      84           0 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_16k_sos_fx; // Q31-ivas_lpf_4_butter_16k_sos_e
      85           0 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_16k_sos_e;
      86           0 :                     BREAK;
      87           0 :                 case 32000:
      88           0 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_32k_sos_fx; // Q31-ivas_lpf_4_butter_32k_sos_e
      89           0 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_32k_sos_e;
      90           0 :                     BREAK;
      91           8 :                 case 48000:
      92           8 :                     *ppFilt_coeff_fx = ivas_lpf_4_butter_48k_sos_fx; // Q31-ivas_lpf_4_butter_48k_sos_e
      93           8 :                     *ppFilt_coeff_e = ivas_lpf_4_butter_48k_sos_e;
      94           8 :                     BREAK;
      95           0 :                 default:
      96           0 :                     BREAK;
      97             :             }
      98           8 :             BREAK;
      99           0 :         default:
     100           0 :             assert( !"Unsupported LFE Filter order" );
     101             :     }
     102             : 
     103           8 :     return;
     104             : }
     105             : 
     106             : 
     107             : /*-----------------------------------------------------------------------------------------*
     108             :  * Function ivas_lfe_window_init()
     109             :  *
     110             :  * Initialize LFE window
     111             :  *-----------------------------------------------------------------------------------------*/
     112             : 
     113         354 : void ivas_lfe_window_init_fx(
     114             :     LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle           */
     115             :     const Word32 sampling_rate,   /* i  : sampling rate               */
     116             :     const Word16 frame_len        /* i  : frame length in samples     */
     117             : )
     118             : {
     119             :     /* Set window coefficients */
     120         354 :     IF( EQ_32( sampling_rate, 48000 ) )
     121             :     {
     122         272 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_48k_fx; // Q31
     123             :     }
     124          82 :     ELSE IF( EQ_32( sampling_rate, 32000 ) )
     125             :     {
     126          12 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_32k_fx; // Q31
     127             :     }
     128          70 :     ELSE IF( EQ_32( sampling_rate, 16000 ) )
     129             :     {
     130          70 :         hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_16k_fx; // Q31
     131             :     }
     132             :     ELSE
     133             :     {
     134           0 :         assert( !"8kHz LFE Window not supported" );
     135             :     }
     136             : 
     137             :     /* 10ms stride, MDCT will be done in two iterations */
     138         354 :     hLFEWindow->dct_len = shr( frame_len, 1 );
     139         354 :     move16();
     140             : 
     141             :     /* 8ms of latency */
     142         354 :     hLFEWindow->fade_len = NS2SA_FX2( sampling_rate, IVAS_LFE_FADE_NS );
     143         354 :     hLFEWindow->zero_pad_len = ( mult( IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub( hLFEWindow->dct_len, hLFEWindow->fade_len ) ) );
     144         354 :     hLFEWindow->full_len = add( add( hLFEWindow->zero_pad_len, hLFEWindow->fade_len ), hLFEWindow->dct_len );
     145         354 :     move16();
     146         354 :     move16();
     147         354 :     move16();
     148             : 
     149         354 :     move16();
     150         354 :     move16();
     151         354 :     move16();
     152         354 :     move16();
     153             : 
     154         354 :     return;
     155             : }

Generated by: LCOV version 1.14