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 : 45 : 46 : /*-----------------------------------------------------------------------------------------* 47 : * Function ivas_lfe_lpf_select_filt_coeff() 48 : * 49 : * Selects LFE filter coeff based on config. 50 : *-----------------------------------------------------------------------------------------*/ 51 : 52 90 : 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 90 : SWITCH( order ) 60 : { 61 : 62 90 : case IVAS_FILTER_ORDER_4: 63 : SWITCH( sampling_rate ) 64 : { 65 0 : case 16000: 66 0 : *ppFilt_coeff_fx = ivas_lpf_4_butter_16k_sos_fx; // Q31-ivas_lpf_4_butter_16k_sos_e 67 0 : *ppFilt_coeff_e = ivas_lpf_4_butter_16k_sos_e; 68 0 : BREAK; 69 1 : case 32000: 70 1 : *ppFilt_coeff_fx = ivas_lpf_4_butter_32k_sos_fx; // Q31-ivas_lpf_4_butter_32k_sos_e 71 1 : *ppFilt_coeff_e = ivas_lpf_4_butter_32k_sos_e; 72 1 : BREAK; 73 89 : case 48000: 74 89 : *ppFilt_coeff_fx = ivas_lpf_4_butter_48k_sos_fx; // Q31-ivas_lpf_4_butter_48k_sos_e 75 89 : *ppFilt_coeff_e = ivas_lpf_4_butter_48k_sos_e; 76 89 : BREAK; 77 0 : default: 78 0 : BREAK; 79 : } 80 90 : BREAK; 81 0 : default: 82 0 : assert( !"Unsupported LFE Filter order" ); 83 : } 84 : 85 90 : return; 86 : } 87 : 88 : 89 : /*-----------------------------------------------------------------------------------------* 90 : * Function ivas_lfe_window_init() 91 : * 92 : * Initialize LFE window 93 : *-----------------------------------------------------------------------------------------*/ 94 : 95 712 : void ivas_lfe_window_init_fx( 96 : LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ 97 : const Word32 sampling_rate, /* i : sampling rate */ 98 : const Word16 frame_len /* i : frame length in samples */ 99 : ) 100 : { 101 : /* Set window coefficients */ 102 712 : IF( EQ_32( sampling_rate, 48000 ) ) 103 : { 104 570 : hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_48k_fx; // Q31 105 : } 106 142 : ELSE IF( EQ_32( sampling_rate, 32000 ) ) 107 : { 108 72 : hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_32k_fx; // Q31 109 : } 110 70 : ELSE IF( EQ_32( sampling_rate, 16000 ) ) 111 : { 112 70 : hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_16k_fx; // Q31 113 : } 114 : ELSE 115 : { 116 0 : assert( !"8kHz LFE Window not supported" ); 117 : } 118 : 119 : /* 10ms stride, MDCT will be done in two iterations */ 120 712 : hLFEWindow->dct_len = shr( frame_len, 1 ); 121 712 : move16(); 122 : 123 : /* 8ms of latency */ 124 712 : hLFEWindow->fade_len = NS2SA_FX2( sampling_rate, IVAS_LFE_FADE_NS ); 125 712 : hLFEWindow->zero_pad_len = ( mult( IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub( hLFEWindow->dct_len, hLFEWindow->fade_len ) ) ); 126 712 : hLFEWindow->full_len = add( add( hLFEWindow->zero_pad_len, hLFEWindow->fade_len ), hLFEWindow->dct_len ); 127 712 : move16(); 128 712 : move16(); 129 712 : move16(); 130 : 131 712 : move16(); 132 712 : move16(); 133 712 : move16(); 134 712 : move16(); 135 : 136 712 : return; 137 : }