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 : #include "prot.h" 40 : #include "rom_enc.h" 41 : #include "cnst.h" 42 : #include "wmc_auto.h" 43 : 44 : /*-------------------------------------------------------------------* 45 : * spec_center() 46 : * 47 : * 48 : *-------------------------------------------------------------------*/ 49 : 50 3100 : void spec_center( 51 : float spec_power[], /* i : energy of sub-band divided uniformly */ 52 : float sp_center[], /* o : spectral centroid */ 53 : const int16_t bw_index /* i : bandwidth */ 54 : ) 55 : { 56 : int16_t i; 57 : float t_sp_center, frame_power; 58 3100 : int16_t sp_center_band_num = SP_CENTER_BAND_NUM_TAB[bw_index]; 59 : float sp_center_mem; 60 : 61 3100 : t_sp_center = 0; 62 3100 : frame_power = 0; 63 : 64 74400 : for ( i = 1; i < sp_center_band_num; i++ ) 65 : { 66 71300 : t_sp_center += spec_power[i] * ( i ); 67 71300 : frame_power += spec_power[i]; 68 : } 69 3100 : sp_center[3] = (float) ( ( t_sp_center + VAD_DELTA1[bw_index] ) / ( frame_power + VAD_DELTA2[bw_index] ) ); 70 : 71 3100 : sp_center_mem = 0; 72 3100 : frame_power = 0; 73 : 74 34100 : for ( i = 0; i < 10; i++ ) 75 : { 76 31000 : sp_center_mem += spec_power[i] * ( i + 1 ); 77 31000 : frame_power += spec_power[i]; 78 : } 79 : 80 : /* 107374184.f = 32768.f * 32768.f * 0.1 */ 81 3100 : t_sp_center = (float) ( ( sp_center_mem + 107374184.f ) / ( frame_power + 107374184.f ) ); 82 : 83 3100 : sp_center[0] = 0.7f * sp_center[0] + 0.3f * t_sp_center; 84 3100 : sp_center[2] = t_sp_center; 85 : 86 3100 : if ( bw_index == CLDFBVAD_NB_ID ) 87 : { 88 0 : t_sp_center = (float) ( ( sp_center_mem ) / ( frame_power + FLT_MIN ) ); 89 0 : sp_center[0] = 0.7f * sp_center[0] + 0.3f * t_sp_center; 90 0 : sp_center[2] = t_sp_center; 91 : } 92 : 93 3100 : return; 94 : }