Coverage Report

Created: 2024-09-06 07:53

/src/fdk-aac/libFDK/include/fixmadd.h
Line
Count
Source (jump to first uncovered line)
1
/* -----------------------------------------------------------------------------
2
Software License for The Fraunhofer FDK AAC Codec Library for Android
3
4
© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
5
Forschung e.V. All rights reserved.
6
7
 1.    INTRODUCTION
8
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
9
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
10
scheme for digital audio. This FDK AAC Codec software is intended to be used on
11
a wide variety of Android devices.
12
13
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
14
general perceptual audio codecs. AAC-ELD is considered the best-performing
15
full-bandwidth communications codec by independent studies and is widely
16
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
17
specifications.
18
19
Patent licenses for necessary patent claims for the FDK AAC Codec (including
20
those of Fraunhofer) may be obtained through Via Licensing
21
(www.vialicensing.com) or through the respective patent owners individually for
22
the purpose of encoding or decoding bit streams in products that are compliant
23
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
24
Android devices already license these patent claims through Via Licensing or
25
directly from the patent owners, and therefore FDK AAC Codec software may
26
already be covered under those patent licenses when it is used for those
27
licensed purposes only.
28
29
Commercially-licensed AAC software libraries, including floating-point versions
30
with enhanced sound quality, are also available from Fraunhofer. Users are
31
encouraged to check the Fraunhofer website for additional applications
32
information and documentation.
33
34
2.    COPYRIGHT LICENSE
35
36
Redistribution and use in source and binary forms, with or without modification,
37
are permitted without payment of copyright license fees provided that you
38
satisfy the following conditions:
39
40
You must retain the complete text of this software license in redistributions of
41
the FDK AAC Codec or your modifications thereto in source code form.
42
43
You must retain the complete text of this software license in the documentation
44
and/or other materials provided with redistributions of the FDK AAC Codec or
45
your modifications thereto in binary form. You must make available free of
46
charge copies of the complete source code of the FDK AAC Codec and your
47
modifications thereto to recipients of copies in binary form.
48
49
The name of Fraunhofer may not be used to endorse or promote products derived
50
from this library without prior written permission.
51
52
You may not charge copyright license fees for anyone to use, copy or distribute
53
the FDK AAC Codec software or your modifications thereto.
54
55
Your modified versions of the FDK AAC Codec must carry prominent notices stating
56
that you changed the software and the date of any change. For modified versions
57
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
58
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
59
AAC Codec Library for Android."
60
61
3.    NO PATENT LICENSE
62
63
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
64
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
65
Fraunhofer provides no warranty of patent non-infringement with respect to this
66
software.
67
68
You may use this FDK AAC Codec software or modifications thereto only for
69
purposes that are authorized by appropriate patent licenses.
70
71
4.    DISCLAIMER
72
73
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
74
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
75
including but not limited to the implied warranties of merchantability and
76
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
77
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
78
or consequential damages, including but not limited to procurement of substitute
79
goods or services; loss of use, data, or profits, or business interruption,
80
however caused and on any theory of liability, whether in contract, strict
81
liability, or tort (including negligence), arising in any way out of the use of
82
this software, even if advised of the possibility of such damage.
83
84
5.    CONTACT INFORMATION
85
86
Fraunhofer Institute for Integrated Circuits IIS
87
Attention: Audio and Multimedia Departments - FDK AAC LL
88
Am Wolfsmantel 33
89
91058 Erlangen, Germany
90
91
www.iis.fraunhofer.de/amm
92
amm-info@iis.fraunhofer.de
93
----------------------------------------------------------------------------- */
94
95
/******************* Library for basic calculation routines ********************
96
97
   Author(s):   M. Lohwasser, M. Gayer
98
99
   Description: fixed point intrinsics
100
101
*******************************************************************************/
102
103
#if !defined(FIXMADD_H)
104
#define FIXMADD_H
105
106
#include "FDK_archdef.h"
107
#include "machine_type.h"
108
#include "fixmul.h"
109
110
#if defined(__arm__)
111
#include "arm/fixmadd_arm.h"
112
113
#endif /* all cores */
114
115
/*************************************************************************
116
 *************************************************************************
117
    Software fallbacks for missing functions.
118
**************************************************************************
119
**************************************************************************/
120
121
/* Divide by two versions. */
122
123
#if !defined(FUNCTION_fixmadddiv2_DD)
124
0
inline FIXP_DBL fixmadddiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
125
0
  return (x + fMultDiv2(a, b));
126
0
}
127
#endif
128
129
#if !defined(FUNCTION_fixmadddiv2_SD)
130
0
inline FIXP_DBL fixmadddiv2_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
131
#ifdef FUNCTION_fixmadddiv2_DS
132
  return fixmadddiv2_DS(x, b, a);
133
#else
134
0
  return fixmadddiv2_DD(x, FX_SGL2FX_DBL(a), b);
135
0
#endif
136
0
}
137
#endif
138
139
#if !defined(FUNCTION_fixmadddiv2_DS)
140
0
inline FIXP_DBL fixmadddiv2_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
141
0
#ifdef FUNCTION_fixmadddiv2_SD
142
0
  return fixmadddiv2_SD(x, b, a);
143
0
#else
144
0
  return fixmadddiv2_DD(x, a, FX_SGL2FX_DBL(b));
145
0
#endif
146
0
}
147
#endif
148
149
#if !defined(FUNCTION_fixmadddiv2_SS)
150
0
inline FIXP_DBL fixmadddiv2_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
151
0
  return x + fMultDiv2(a, b);
152
0
}
153
#endif
154
155
#if !defined(FUNCTION_fixmsubdiv2_DD)
156
0
inline FIXP_DBL fixmsubdiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
157
0
  return (x - fMultDiv2(a, b));
158
0
}
159
#endif
160
161
#if !defined(FUNCTION_fixmsubdiv2_SD)
162
0
inline FIXP_DBL fixmsubdiv2_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
163
#ifdef FUNCTION_fixmsubdiv2_DS
164
  return fixmsubdiv2_DS(x, b, a);
165
#else
166
0
  return fixmsubdiv2_DD(x, FX_SGL2FX_DBL(a), b);
167
0
#endif
168
0
}
169
#endif
170
171
#if !defined(FUNCTION_fixmsubdiv2_DS)
172
0
inline FIXP_DBL fixmsubdiv2_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
173
0
#ifdef FUNCTION_fixmsubdiv2_SD
174
0
  return fixmsubdiv2_SD(x, b, a);
175
0
#else
176
0
  return fixmsubdiv2_DD(x, a, FX_SGL2FX_DBL(b));
177
0
#endif
178
0
}
179
#endif
180
181
#if !defined(FUNCTION_fixmsubdiv2_SS)
182
0
inline FIXP_DBL fixmsubdiv2_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
183
0
  return x - fMultDiv2(a, b);
184
0
}
185
#endif
186
187
#if !defined(FUNCTION_fixmadddiv2BitExact_DD)
188
#define FUNCTION_fixmadddiv2BitExact_DD
189
inline FIXP_DBL fixmadddiv2BitExact_DD(FIXP_DBL x, const FIXP_DBL a,
190
0
                                       const FIXP_DBL b) {
191
0
  return x + fMultDiv2BitExact(a, b);
192
0
}
193
#endif
194
#if !defined(FUNCTION_fixmadddiv2BitExact_SD)
195
#define FUNCTION_fixmadddiv2BitExact_SD
196
inline FIXP_DBL fixmadddiv2BitExact_SD(FIXP_DBL x, const FIXP_SGL a,
197
0
                                       const FIXP_DBL b) {
198
0
#ifdef FUNCTION_fixmadddiv2BitExact_DS
199
0
  return fixmadddiv2BitExact_DS(x, b, a);
200
0
#else
201
0
  return x + fMultDiv2BitExact(a, b);
202
0
#endif
203
0
}
204
#endif
205
#if !defined(FUNCTION_fixmadddiv2BitExact_DS)
206
#define FUNCTION_fixmadddiv2BitExact_DS
207
inline FIXP_DBL fixmadddiv2BitExact_DS(FIXP_DBL x, const FIXP_DBL a,
208
0
                                       const FIXP_SGL b) {
209
0
#ifdef FUNCTION_fixmadddiv2BitExact_SD
210
0
  return fixmadddiv2BitExact_SD(x, b, a);
211
0
#else
212
0
  return x + fMultDiv2BitExact(a, b);
213
0
#endif
214
0
}
215
#endif
216
217
#if !defined(FUNCTION_fixmsubdiv2BitExact_DD)
218
#define FUNCTION_fixmsubdiv2BitExact_DD
219
inline FIXP_DBL fixmsubdiv2BitExact_DD(FIXP_DBL x, const FIXP_DBL a,
220
0
                                       const FIXP_DBL b) {
221
0
  return x - fMultDiv2BitExact(a, b);
222
0
}
223
#endif
224
#if !defined(FUNCTION_fixmsubdiv2BitExact_SD)
225
#define FUNCTION_fixmsubdiv2BitExact_SD
226
inline FIXP_DBL fixmsubdiv2BitExact_SD(FIXP_DBL x, const FIXP_SGL a,
227
0
                                       const FIXP_DBL b) {
228
0
#ifdef FUNCTION_fixmsubdiv2BitExact_DS
229
0
  return fixmsubdiv2BitExact_DS(x, b, a);
230
0
#else
231
0
  return x - fMultDiv2BitExact(a, b);
232
0
#endif
233
0
}
234
#endif
235
#if !defined(FUNCTION_fixmsubdiv2BitExact_DS)
236
#define FUNCTION_fixmsubdiv2BitExact_DS
237
inline FIXP_DBL fixmsubdiv2BitExact_DS(FIXP_DBL x, const FIXP_DBL a,
238
0
                                       const FIXP_SGL b) {
239
0
#ifdef FUNCTION_fixmsubdiv2BitExact_SD
240
0
  return fixmsubdiv2BitExact_SD(x, b, a);
241
0
#else
242
0
  return x - fMultDiv2BitExact(a, b);
243
0
#endif
244
0
}
245
#endif
246
247
  /* Normal versions */
248
249
#if !defined(FUNCTION_fixmadd_DD)
250
0
inline FIXP_DBL fixmadd_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
251
0
  return fixmadddiv2_DD(x, a, b) << 1;
252
0
}
253
#endif
254
#if !defined(FUNCTION_fixmadd_SD)
255
0
inline FIXP_DBL fixmadd_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
256
0
#ifdef FUNCTION_fixmadd_DS
257
0
  return fixmadd_DS(x, b, a);
258
0
#else
259
0
  return fixmadd_DD(x, FX_SGL2FX_DBL(a), b);
260
0
#endif
261
0
}
262
#endif
263
#if !defined(FUNCTION_fixmadd_DS)
264
0
inline FIXP_DBL fixmadd_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
265
0
#ifdef FUNCTION_fixmadd_SD
266
0
  return fixmadd_SD(x, b, a);
267
0
#else
268
0
  return fixmadd_DD(x, a, FX_SGL2FX_DBL(b));
269
0
#endif
270
0
}
271
#endif
272
#if !defined(FUNCTION_fixmadd_SS)
273
0
inline FIXP_DBL fixmadd_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
274
0
  return (x + fMultDiv2(a, b)) << 1;
275
0
}
276
#endif
277
278
#if !defined(FUNCTION_fixmsub_DD)
279
0
inline FIXP_DBL fixmsub_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
280
0
  return fixmsubdiv2_DD(x, a, b) << 1;
281
0
}
282
#endif
283
#if !defined(FUNCTION_fixmsub_SD)
284
0
inline FIXP_DBL fixmsub_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
285
0
#ifdef FUNCTION_fixmsub_DS
286
0
  return fixmsub_DS(x, b, a);
287
0
#else
288
0
  return fixmsub_DD(x, FX_SGL2FX_DBL(a), b);
289
0
#endif
290
0
}
291
#endif
292
#if !defined(FUNCTION_fixmsub_DS)
293
0
inline FIXP_DBL fixmsub_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
294
0
#ifdef FUNCTION_fixmsub_SD
295
0
  return fixmsub_SD(x, b, a);
296
0
#else
297
0
  return fixmsub_DD(x, a, FX_SGL2FX_DBL(b));
298
0
#endif
299
0
}
300
#endif
301
#if !defined(FUNCTION_fixmsub_SS)
302
0
inline FIXP_DBL fixmsub_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
303
0
  return (x - fMultDiv2(a, b)) << 1;
304
0
}
305
#endif
306
307
#if !defined(FUNCTION_fixpow2adddiv2_D)
308
#ifdef FUNCTION_fixmadddiv2_DD
309
#define fixpadddiv2_D(x, a) fixmadddiv2_DD(x, a, a)
310
#else
311
0
inline INT fixpadddiv2_D(FIXP_DBL x, const FIXP_DBL a) {
312
0
  return (x + fPow2Div2(a));
313
0
}
314
#endif
315
#endif
316
#if !defined(FUNCTION_fixpow2add_D)
317
0
inline INT fixpadd_D(FIXP_DBL x, const FIXP_DBL a) { return (x + fPow2(a)); }
318
#endif
319
320
#if !defined(FUNCTION_fixpow2adddiv2_S)
321
#ifdef FUNCTION_fixmadddiv2_SS
322
#define fixpadddiv2_S(x, a) fixmadddiv2_SS(x, a, a)
323
#else
324
0
inline INT fixpadddiv2_S(FIXP_DBL x, const FIXP_SGL a) {
325
0
  return (x + fPow2Div2(a));
326
0
}
327
#endif
328
#endif
329
#if !defined(FUNCTION_fixpow2add_S)
330
0
inline INT fixpadd_S(FIXP_DBL x, const FIXP_SGL a) { return (x + fPow2(a)); }
331
#endif
332
333
#endif /* FIXMADD_H */