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 : #ifdef DEBUGGING 40 : #include "debug.h" 41 : #endif 42 : #include "cnst.h" 43 : #include "prot.h" 44 : #include "wmc_auto.h" 45 : 46 : /*-------------------------------------------------------------------* 47 : * get_next_coeff_mapped() 48 : * 49 : * 50 : *-------------------------------------------------------------------*/ 51 : 52 : /*! r: index of next coefficient */ 53 185498708 : int16_t get_next_coeff_mapped( 54 : int16_t ii[2], /* i/o: coefficient indexes */ 55 : int32_t *pp, /* o : peak(1)/hole(0) indicator */ 56 : int16_t *idx, /* o : index in unmapped domain */ 57 : CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ 58 : ) 59 : { 60 : uint32_t p; 61 : 62 185498708 : p = ( ii[1] - hm_cfg->numPeakIndices ) & ( hm_cfg->indexBuffer[ii[1]] - hm_cfg->indexBuffer[ii[0]] ); 63 185498708 : p >>= sizeof( p ) * 8 - 1; 64 185498708 : *pp = p; 65 185498708 : *idx = ii[p]; 66 185498708 : ii[p]++; 67 : 68 185498708 : return hm_cfg->indexBuffer[*idx]; 69 : } 70 : 71 : 72 : /*-------------------------------------------------------------------* 73 : * get_next_coeff_unmapped() 74 : * 75 : * 76 : *-------------------------------------------------------------------*/ 77 : 78 : /*! r: index of next coefficient */ 79 1109198 : int16_t get_next_coeff_unmapped( 80 : int16_t *ii, /* i/o: coefficient indexes */ 81 : int16_t *idx /* o : index in unmapped domain */ 82 : ) 83 : { 84 1109198 : *idx = *ii; 85 1109198 : ( *ii )++; 86 : 87 1109198 : return *idx; 88 : } 89 : 90 : /*-------------------------------------------------------------------* 91 : * update_mixed_context() 92 : * 93 : * 94 : *-------------------------------------------------------------------*/ 95 : 96 15674425 : int32_t update_mixed_context( 97 : int32_t ctx, 98 : int16_t a ) 99 : { 100 : int32_t t; 101 : 102 15674425 : t = 1 - 13 + ( a & ~1 ) * ( ( a >> 2 ) + 1 ); 103 : 104 15674425 : if ( t > 0 ) 105 : { 106 379927 : t = min( ( a >> 3 ), 2 ); 107 : } 108 : 109 15674425 : return ( ctx & 0xf ) * 16 + t + 13; 110 : }