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_fx.h"
40 : #include "wmc_auto.h"
41 :
42 8725 : void deemph_fx_32(
43 : Word32 *signal, /* i/o: signal Qx*/
44 : const Word16 mu, /* i : deemphasis factor Q15*/
45 : const Word16 L, /* i : vector size */
46 : Word32 *mem /* i/o: memory (y[-1]) Qx*/
47 : )
48 : {
49 : Word16 i;
50 :
51 8725 : signal[0] = Madd_32_16( signal[0], *mem, mu ); // Qx
52 8725 : move32();
53 2792000 : FOR( i = 1; i < L; i++ )
54 : {
55 2783275 : signal[i] = Madd_32_16( signal[i], signal[i - 1], mu ); // Qx
56 2783275 : move32();
57 : }
58 :
59 8725 : *mem = signal[L - 1]; // Qx
60 8725 : move32();
61 :
62 8725 : return;
63 : }
64 :
65 :
66 : /*========================================================================*/
67 : /* FUNCTION : deemph_fx() */
68 : /*------------------------------------------------------------------------*/
69 : /* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1) */
70 : /*------------------------------------------------------------------------*/
71 : /* INPUT ARGUMENTS : */
72 : /* _ (Word16) mu : deemphasis factor Q15 */
73 : /* _ (Word16) L : vector size */
74 : /*------------------------------------------------------------------------*/
75 : /* INPUT/OUTPUT ARGUMENTS : */
76 : /* _ (Word16*) signal : signal Q_syn2-1 */
77 : /* _ (Word16*) mem : memory (y[-1]) Q_syn2-1 */
78 : /*------------------------------------------------------------------------*/
79 : /* OUTPUT ARGUMENTS : */
80 : /*------------------------------------------------------------------------*/
81 :
82 : /*------------------------------------------------------------------------*/
83 : /* RETURN ARGUMENTS : */
84 : /* _ None */
85 : /*========================================================================*/
86 1479564 : void deemph_fx(
87 : Word16 *signal, /* i/o: signal Qx */
88 : const Word16 mu, /* i : deemphasis factor Q15 */
89 : const Word16 L, /* i : vector size Q0 */
90 : Word16 *mem /* i/o: memory (y[-1]) Qx */
91 : )
92 : {
93 : Word16 i;
94 : Word32 L_tmp;
95 : #ifndef ISSUE_1836_replace_overflow_libcom
96 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
97 : Flag Overflow;
98 : Overflow = 0;
99 : move32();
100 : #endif
101 : L_tmp = L_deposit_h( signal[0] ); /*Qx+16*/
102 : L_tmp = L_mac_o( L_tmp, *mem, mu, &Overflow ); /*Qx+16*/
103 : signal[0] = round_fx_o( L_tmp, &Overflow ); /*Qx*/
104 : #else
105 1479564 : L_tmp = L_deposit_h( signal[0] ); /*Qx+16*/
106 1479564 : L_tmp = L_mac_sat( L_tmp, *mem, mu ); /*Qx+16*/
107 1479564 : signal[0] = round_fx_sat( L_tmp ); /*Qx*/
108 : #endif
109 :
110 :
111 1479564 : move16();
112 :
113 208422224 : FOR( i = 1; i < L; i++ )
114 : {
115 206942660 : L_tmp = L_deposit_h( signal[i] ); /*Qx+16*/
116 : #ifdef ISSUE_1836_replace_overflow_libcom
117 206942660 : L_tmp = L_mac_sat( L_tmp, signal[i - 1], mu ); /*Qx+16*/
118 206942660 : signal[i] = round_fx_sat( L_tmp ); /*Qx*/
119 : #else
120 : L_tmp = L_mac_o( L_tmp, signal[i - 1], mu, &Overflow ); /*Qx+16*/
121 : signal[i] = round_fx_o( L_tmp, &Overflow ); /*Qx*/
122 : #endif
123 206942660 : move16();
124 : }
125 :
126 1479564 : *mem = signal[L - 1]; /*Qx*/
127 1479564 : move16();
128 1479564 : }
129 :
130 : /*-------------------------------------------------------------------*
131 : * Deeemph2 :
132 : *
133 : * Deemphasis: filtering through 1/(1-mu z^-1)
134 : * Output divided by 2
135 : *-------------------------------------------------------------------*/
136 0 : void Deemph2(
137 : Word16 x[], /* i/o: input signal overwritten by the output Qx/Qx-1 */
138 : const Word16 mu, /* i : deemphasis factor Q15 */
139 : const Word16 L, /* i : vector size Q0 */
140 : Word16 *mem /* i/o: memory (y[-1]) Qx-1 */
141 : )
142 : {
143 : Word16 i;
144 : Word32 L_tmp;
145 : #ifndef ISSUE_1836_replace_overflow_libcom
146 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
147 : Flag Overflow;
148 : Overflow = 0;
149 : move32();
150 : #endif
151 : #endif
152 : /* saturation can occur in L_mac() */
153 :
154 0 : L_tmp = L_mult( x[0], 16384 /*0.5f in Q15*/ ); /*Qx+16*/
155 0 : x[0] = mac_r( L_tmp, *mem, mu ); /*Qx-1*/
156 0 : move16();
157 :
158 0 : FOR( i = 1; i < L; i++ )
159 : {
160 0 : L_tmp = L_mult( x[i], 16384 /*0.5f in Q15*/ ); /*Qx+16*/
161 : #ifdef ISSUE_1836_replace_overflow_libcom
162 0 : x[i] = mac_r_sat( L_tmp, x[i - 1], mu ); /*Qx-1*/
163 : #else
164 : x[i] = mac_ro( L_tmp, x[i - 1], mu, &Overflow ); /*Qx-1*/
165 : #endif
166 0 : move16();
167 : }
168 :
169 0 : *mem = x[L - 1]; /*Qx-1*/
170 0 : move16();
171 0 : }
172 :
173 :
174 : /*
175 : * E_UTIL_deemph2
176 : *
177 : * Parameters:
178 : * shift I: scale output
179 : * x I/O: signal Qx/Qx-shift
180 : * mu I: deemphasis factor Qx
181 : * L I: vector size
182 : * mem I/O: memory (signal[-1]) Qx
183 : *
184 : * Function:
185 : * Filtering through 1/(1-mu z^-1)
186 : * Signal is divided by 2.
187 : *
188 : * Returns:
189 : * void
190 : */
191 604 : void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem )
192 : {
193 : Word16 i;
194 : Word32 L_tmp;
195 : #ifndef ISSUE_1836_replace_overflow_libcom
196 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
197 : Flag Overflow;
198 : Overflow = 0;
199 : move32();
200 : #endif
201 : #endif
202 :
203 : /* signal[0] = signal[0] + mu * (*mem); */
204 604 : L_tmp = L_deposit_h( *mem ); /*Qx+16*/
205 604 : IF( shift >= 0 )
206 : {
207 306 : shift = shr( -32768, shift ); /*Q15 - shift*/
208 98226 : FOR( i = 0; i < L; i++ )
209 : {
210 : #ifdef ISSUE_1836_replace_overflow_libcom
211 97920 : L_tmp = L_msu_sat( Mpy_32_16_1( L_tmp, mu ), x[i], shift ); /*Qx-shift+16*/
212 97920 : x[i] = round_fx_sat( L_tmp ); /*Qx-shift*/
213 : #else
214 : L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), x[i], shift, &Overflow ); /*Qx-shift+16*/
215 : x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/
216 : #endif
217 97920 : move16();
218 : }
219 : }
220 : ELSE
221 : {
222 95658 : FOR( i = 0; i < L; i++ )
223 : {
224 : #ifdef ISSUE_1836_replace_overflow_libcom
225 95360 : L_tmp = L_msu_sat( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/ ); /*Qx-shift+16*/
226 95360 : x[i] = round_fx_sat( L_tmp ); /*Qx-shift*/
227 : #else
228 : L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
229 : x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/
230 : #endif
231 95360 : move16();
232 : }
233 : }
234 :
235 604 : *mem = x[L - 1]; /*Qx-shift*/
236 604 : move16();
237 :
238 604 : return;
239 : }
|