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 : 38 : #include <stdint.h> 39 : #include "options.h" 40 : #ifdef DEBUGGING 41 : #include "debug.h" 42 : #endif 43 : #include "cnst.h" 44 : #include "prot.h" 45 : #include "wmc_auto.h" 46 : 47 : /*------------------------------------------------------------------------* 48 : * FEC_pitch_estim() 49 : * 50 : * Estimation of pitch for FEC 51 : *------------------------------------------------------------------------*/ 52 : 53 459954 : void FEC_pitch_estim( 54 : const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ 55 : const int16_t last_core, /* i : last core */ 56 : const int16_t L_frame, /* i : length of the frame */ 57 : const int16_t clas, /* i : current frame classification */ 58 : const int16_t last_good, /* i : last good clas information */ 59 : const float pitch_buf[], /* i : Floating pitch for each subframe */ 60 : const float old_pitch_buf[], /* i : buffer of old subframe pitch values */ 61 : float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ 62 : int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */ 63 : int16_t *upd_cnt, /* i/o: update counter */ 64 : const int16_t coder_type /* i : coder_type */ 65 : ) 66 : { 67 459954 : if ( last_core == HQ_CORE || last_core == TCX_20_CORE || last_core == TCX_10_CORE ) 68 : { 69 20583 : *bfi_pitch = pitch_buf[( L_frame / L_SUBFR ) - 1]; 70 20583 : *bfi_pitch_frame = L_frame; 71 20583 : *upd_cnt = MAX_UPD_CNT; 72 : } 73 : 74 459954 : if ( ( clas == VOICED_CLAS && last_good >= VOICED_TRANSITION ) || ( Opt_AMR_WB && clas == VOICED_CLAS ) ) 75 : { 76 : /* update pitch for FEC if pitch is coherent */ 77 216870 : if ( ( ( pitch_buf[3] < 1.4f * pitch_buf[1] ) && ( pitch_buf[3] > 0.7f * pitch_buf[1] ) && 78 208767 : ( pitch_buf[1] < 1.4f * old_pitch_buf[2 * NB_SUBFR - 1] ) && ( pitch_buf[1] > 0.7f * old_pitch_buf[2 * NB_SUBFR - 1] ) && 79 115287 : ( L_frame == L_FRAME ) ) || 80 115287 : ( ( pitch_buf[3] < 1.4f * pitch_buf[1] ) && ( pitch_buf[3] > 0.7f * pitch_buf[1] ) && 81 107184 : ( pitch_buf[1] < 1.4f * old_pitch_buf[2 * NB_SUBFR16k - 1] ) && ( pitch_buf[1] > 0.7f * old_pitch_buf[2 * NB_SUBFR16k - 1] ) && 82 27003 : ( L_frame == L_FRAME16k ) ) || 83 : ( coder_type == TRANSITION ) ) 84 : { 85 193245 : *bfi_pitch = pitch_buf[( L_frame / L_SUBFR ) - 1]; 86 193245 : *bfi_pitch_frame = L_frame; 87 193245 : *upd_cnt = 0; 88 : } 89 : } 90 : 91 459954 : return; 92 : }