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 <math.h>
40 : #include "rom_com.h"
41 : #include "prot.h"
42 : #include "wmc_auto.h"
43 :
44 : /*-------------------------------------------------------------------*
45 : * dequantize_uvg()
46 : *
47 : * Dequantize unvoiced gains
48 : *--------------------------------------------------------------------*/
49 :
50 0 : void dequantize_uvg(
51 : int16_t iG1, /* i : gain 1 index */
52 : int16_t *iG2, /* i : gain 2 index */
53 : float *G, /* o : quantized gain */
54 : const int16_t bwidth /* i : audio bandwidth */
55 : )
56 : {
57 : int16_t i, k;
58 0 : const float( *UVG1CB )[2] = NULL;
59 0 : const float( *UVG2CB1 )[5] = NULL;
60 0 : const float( *UVG2CB2 )[5] = NULL;
61 :
62 0 : if ( bwidth == NB )
63 : {
64 0 : UVG1CB = UVG1CB_NB;
65 0 : UVG2CB1 = UVG2CB1_NB;
66 0 : UVG2CB2 = UVG2CB2_NB;
67 : }
68 :
69 0 : else if ( bwidth == WB || bwidth == SWB )
70 : {
71 0 : UVG1CB = UVG1CB_WB;
72 0 : UVG2CB1 = UVG2CB1_WB;
73 0 : UVG2CB2 = UVG2CB2_WB;
74 : }
75 :
76 0 : for ( i = 0; i < 2; i++ )
77 : {
78 0 : for ( k = 0; k < 5; k++ )
79 : {
80 0 : if ( i == 0 )
81 : {
82 0 : G[i * 5 + k] = (float) pow( 10.0, UVG1CB[iG1][i] ) * UVG2CB1[iG2[i]][k];
83 : }
84 0 : else if ( i == 1 )
85 : {
86 0 : G[i * 5 + k] = (float) pow( 10.0, UVG1CB[iG1][i] ) * UVG2CB2[iG2[i]][k];
87 : }
88 : }
89 : }
90 :
91 0 : return;
92 : }
93 :
94 : /*-------------------------------------------------------------------*
95 : * generate_nelp_excitation()
96 : *
97 : * Generate excitation for NELP coding.
98 : *--------------------------------------------------------------------*/
99 :
100 0 : void generate_nelp_excitation(
101 : int16_t *seed, /* i/o: random number seed */
102 : float *Gains, /* i : excitation gains */
103 : float *output, /* o : excitation output */
104 : float gain_fac /* i : gain factor */
105 : )
106 : {
107 : int16_t i, len, j;
108 : float tmp[31], tmp1[31], tmpf;
109 : int16_t k1, k2, I[31], tmpi;
110 :
111 0 : for ( i = 0; i < 10; i++ )
112 : {
113 0 : if ( i == 9 )
114 : {
115 0 : len = 31;
116 : }
117 : else
118 : {
119 0 : len = 25;
120 : }
121 :
122 0 : for ( j = 0; j < len; j++ )
123 : {
124 0 : tmp[j] = ( ( *seed ) = (int16_t) ( 521 * ( *seed ) + 259 ) ) / PCM16_TO_FLT_FAC;
125 0 : tmp1[j] = ABSVAL( tmp[j] );
126 0 : I[j] = j;
127 : }
128 0 : for ( k1 = 0; k1 < len - 1; k1++ )
129 : {
130 0 : for ( k2 = k1 + 1; k2 < len; k2++ )
131 : {
132 0 : if ( tmp1[k2] > tmp1[k1] )
133 : {
134 0 : tmpi = I[k2];
135 0 : tmpf = tmp1[k2];
136 0 : tmp1[k2] = tmp1[k1];
137 0 : I[k2] = I[k1];
138 0 : tmp1[k1] = tmpf;
139 0 : I[k1] = tmpi;
140 : }
141 : }
142 : }
143 :
144 : /*using a factor of 1.37 to compensate for the ~ 2.5 ( or 2.73) dB diff between this scheme and EVS-UV */
145 0 : for ( j = 0; j < (int16_t) rint_new( len / 4.0f ); j++ )
146 : {
147 0 : output[i * 25 + I[j]] = (float) ( Gains[i] * sqrt( 3.0f ) * tmp[I[j]] * gain_fac );
148 : }
149 0 : for ( ; j < len; j++ )
150 : {
151 0 : output[i * 25 + I[j]] = 0;
152 : }
153 : }
154 :
155 0 : return;
156 : }
|