Coverage Report

Created: 2024-09-06 07:53

/src/fdk-aac/libFDK/include/fixpoint_math.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 - 2019 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. Gayer
98
99
   Description: Fixed point specific mathematical functions
100
101
*******************************************************************************/
102
103
#ifndef FIXPOINT_MATH_H
104
#define FIXPOINT_MATH_H
105
106
#include "common_fix.h"
107
#include "scale.h"
108
109
/*
110
 * Data definitions
111
 */
112
113
#define LD_DATA_SCALING (64.0f)
114
0
#define LD_DATA_SHIFT 6 /* pow(2, LD_DATA_SHIFT) = LD_DATA_SCALING */
115
116
#define MAX_LD_PRECISION 10
117
0
#define LD_PRECISION 10
118
119
/* Taylor series coefficients for ln(1-x), centered at 0 (MacLaurin polynomial).
120
 */
121
#ifndef LDCOEFF_16BIT
122
LNK_SECTION_CONSTDATA_L1
123
static const FIXP_DBL ldCoeff[MAX_LD_PRECISION] = {
124
    FL2FXCONST_DBL(-1.0),       FL2FXCONST_DBL(-1.0 / 2.0),
125
    FL2FXCONST_DBL(-1.0 / 3.0), FL2FXCONST_DBL(-1.0 / 4.0),
126
    FL2FXCONST_DBL(-1.0 / 5.0), FL2FXCONST_DBL(-1.0 / 6.0),
127
    FL2FXCONST_DBL(-1.0 / 7.0), FL2FXCONST_DBL(-1.0 / 8.0),
128
    FL2FXCONST_DBL(-1.0 / 9.0), FL2FXCONST_DBL(-1.0 / 10.0)};
129
#else  /* LDCOEFF_16BIT */
130
LNK_SECTION_CONSTDATA_L1
131
static const FIXP_SGL ldCoeff[MAX_LD_PRECISION] = {
132
    FL2FXCONST_SGL(-1.0),       FL2FXCONST_SGL(-1.0 / 2.0),
133
    FL2FXCONST_SGL(-1.0 / 3.0), FL2FXCONST_SGL(-1.0 / 4.0),
134
    FL2FXCONST_SGL(-1.0 / 5.0), FL2FXCONST_SGL(-1.0 / 6.0),
135
    FL2FXCONST_SGL(-1.0 / 7.0), FL2FXCONST_SGL(-1.0 / 8.0),
136
    FL2FXCONST_SGL(-1.0 / 9.0), FL2FXCONST_SGL(-1.0 / 10.0)};
137
#endif /* LDCOEFF_16BIT */
138
139
/*****************************************************************************
140
141
    functionname: invSqrtNorm2
142
    description:  delivers 1/sqrt(op) normalized to .5...1 and the shift value
143
of the OUTPUT
144
145
*****************************************************************************/
146
#define SQRT_BITS 7
147
#define SQRT_VALUES (128 + 2)
148
#define SQRT_BITS_MASK 0x7f
149
#define SQRT_FRACT_BITS_MASK 0x007FFFFF
150
151
extern const FIXP_DBL invSqrtTab[SQRT_VALUES];
152
153
/*
154
 * Hardware specific implementations
155
 */
156
157
#if defined(__x86__)
158
#include "x86/fixpoint_math_x86.h"
159
#endif /* target architecture selector */
160
161
/*
162
 * Fallback implementations
163
 */
164
#if !defined(FUNCTION_fIsLessThan)
165
/**
166
 * \brief Compares two fixpoint values incl. scaling.
167
 * \param a_m mantissa of the first input value.
168
 * \param a_e exponent of the first input value.
169
 * \param b_m mantissa of the second input value.
170
 * \param b_e exponent of the second input value.
171
 * \return non-zero if (a_m*2^a_e) < (b_m*2^b_e), 0 otherwise
172
 */
173
0
FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e) {
174
0
  INT n;
175
176
0
  n = fixnorm_D(a_m);
177
0
  a_m <<= n;
178
0
  a_e -= n;
179
180
0
  n = fixnorm_D(b_m);
181
0
  b_m <<= n;
182
0
  b_e -= n;
183
184
0
  if (a_m == (FIXP_DBL)0) a_e = b_e;
185
0
  if (b_m == (FIXP_DBL)0) b_e = a_e;
186
187
0
  if (a_e > b_e) {
188
0
    return ((b_m >> fMin(a_e - b_e, DFRACT_BITS - 1)) > a_m);
189
0
  } else {
190
0
    return ((a_m >> fMin(b_e - a_e, DFRACT_BITS - 1)) < b_m);
191
0
  }
192
0
}
Unexecuted instantiation: aacenc_lib.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: channel_map.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: metadata_main.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: mps_main.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_lib.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_onsetdetect.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_paramextract.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_staticgain.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_tree.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_vectorfunctions.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: bit_sbr.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: ps_main.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sbr_encoder.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sbrenc_freq_sca.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sbrenc_ram.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sbrenc_rom.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: ton_corr.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: tran_det.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: pcm_utils.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: FDK_bitbuffer.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: FDK_hybrid.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: FDK_tools_rom.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: autocorr2nd.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: fixpoint_math.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: qmf.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: scale.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: aacenc.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: bandwidth.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: bitenc.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: metadata_compressor.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: psy_main.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: qc_main.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: quantize.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sf_estim.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: spreading.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: tonality.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: transform.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_bitstream.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_dmx_tdom_enh.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_filter.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_framewindowing.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sacenc_nlc_enc.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: code_env.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: env_bit.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: env_est.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: fram_gen.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: invf_est.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: mh_det.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: nf_est.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: ps_bitenc.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: ps_encode.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: resampler.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: sbr_misc.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: FDK_trigFcts.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: dct.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: fft.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: fft_rad2.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: mdct.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: aacEnc_ram.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: aacEnc_rom.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: aacenc_pns.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: aacenc_tns.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: adj_thr.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: band_nrg.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: bit_cnt.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: block_switch.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: chaosmeasure.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: dyn_bits.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: grp_data.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: intensity.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: line_pe.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: ms_stereo.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: noisedet.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: pnsparam.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: pre_echo_control.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: psy_configuration.cpp:fIsLessThan(int, int, int, int)
Unexecuted instantiation: FDK_lpc.cpp:fIsLessThan(int, int, int, int)
193
194
0
FDK_INLINE INT fIsLessThan(FIXP_SGL a_m, INT a_e, FIXP_SGL b_m, INT b_e) {
195
0
  INT n;
196
0
197
0
  n = fixnorm_S(a_m);
198
0
  a_m <<= n;
199
0
  a_e -= n;
200
0
201
0
  n = fixnorm_S(b_m);
202
0
  b_m <<= n;
203
0
  b_e -= n;
204
0
205
0
  if (a_m == (FIXP_SGL)0) a_e = b_e;
206
0
  if (b_m == (FIXP_SGL)0) b_e = a_e;
207
0
208
0
  if (a_e > b_e) {
209
0
    return ((b_m >> fMin(a_e - b_e, FRACT_BITS - 1)) > a_m);
210
0
  } else {
211
0
    return ((a_m >> fMin(b_e - a_e, FRACT_BITS - 1)) < b_m);
212
0
  }
213
0
}
Unexecuted instantiation: aacenc_lib.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: channel_map.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: metadata_main.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: mps_main.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_lib.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_onsetdetect.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_paramextract.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_staticgain.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_tree.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_vectorfunctions.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: bit_sbr.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: ps_main.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sbr_encoder.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sbrenc_freq_sca.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sbrenc_ram.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sbrenc_rom.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: ton_corr.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: tran_det.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: pcm_utils.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: FDK_bitbuffer.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: FDK_hybrid.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: FDK_tools_rom.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: autocorr2nd.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: fixpoint_math.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: qmf.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: scale.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: aacenc.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: bandwidth.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: bitenc.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: metadata_compressor.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: psy_main.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: qc_main.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: quantize.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sf_estim.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: spreading.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: tonality.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: transform.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_bitstream.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_dmx_tdom_enh.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_filter.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_framewindowing.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sacenc_nlc_enc.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: code_env.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: env_bit.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: env_est.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: fram_gen.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: invf_est.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: mh_det.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: nf_est.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: ps_bitenc.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: ps_encode.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: resampler.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: sbr_misc.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: FDK_trigFcts.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: dct.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: fft.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: fft_rad2.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: mdct.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: aacEnc_ram.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: aacEnc_rom.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: aacenc_pns.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: aacenc_tns.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: adj_thr.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: band_nrg.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: bit_cnt.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: block_switch.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: chaosmeasure.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: dyn_bits.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: grp_data.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: intensity.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: line_pe.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: ms_stereo.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: noisedet.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: pnsparam.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: pre_echo_control.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: psy_configuration.cpp:fIsLessThan(short, int, short, int)
Unexecuted instantiation: FDK_lpc.cpp:fIsLessThan(short, int, short, int)
214
#endif
215
216
/**
217
 * \brief deprecated. Use fLog2() instead.
218
 */
219
0
#define CalcLdData(op) fLog2(op, 0)
220
221
void LdDataVector(FIXP_DBL *srcVector, FIXP_DBL *destVector, INT number);
222
223
extern const UINT exp2_tab_long[32];
224
extern const UINT exp2w_tab_long[32];
225
extern const UINT exp2x_tab_long[32];
226
227
LNK_SECTION_CODE_L1
228
0
FDK_INLINE FIXP_DBL CalcInvLdData(const FIXP_DBL x) {
229
0
  int set_zero = (x < FL2FXCONST_DBL(-31.0 / 64.0)) ? 0 : 1;
230
0
  int set_max = (x >= FL2FXCONST_DBL(31.0 / 64.0)) | (x == FL2FXCONST_DBL(0.0));
231
232
0
  FIXP_SGL frac = (FIXP_SGL)((LONG)x & 0x3FF);
233
0
  UINT index3 = (UINT)(LONG)(x >> 10) & 0x1F;
234
0
  UINT index2 = (UINT)(LONG)(x >> 15) & 0x1F;
235
0
  UINT index1 = (UINT)(LONG)(x >> 20) & 0x1F;
236
0
  int exp = fMin(31, ((x > FL2FXCONST_DBL(0.0f)) ? (31 - (int)(x >> 25))
237
0
                                                 : (int)(-(x >> 25))));
238
239
0
  UINT lookup1 = exp2_tab_long[index1] * set_zero;
240
0
  UINT lookup2 = exp2w_tab_long[index2];
241
0
  UINT lookup3 = exp2x_tab_long[index3];
242
0
  UINT lookup3f =
243
0
      lookup3 + (UINT)(LONG)fMultDiv2((FIXP_DBL)(0x0016302F), (FIXP_SGL)frac);
244
245
0
  UINT lookup12 = (UINT)(LONG)fMult((FIXP_DBL)lookup1, (FIXP_DBL)lookup2);
246
0
  UINT lookup = (UINT)(LONG)fMult((FIXP_DBL)lookup12, (FIXP_DBL)lookup3f);
247
248
0
  FIXP_DBL retVal = (lookup << 3) >> exp;
249
250
0
  if (set_max) {
251
0
    retVal = (FIXP_DBL)MAXVAL_DBL;
252
0
  }
253
254
0
  return retVal;
255
0
}
Unexecuted instantiation: aacenc_lib.cpp:CalcInvLdData(int)
Unexecuted instantiation: channel_map.cpp:CalcInvLdData(int)
Unexecuted instantiation: metadata_main.cpp:CalcInvLdData(int)
Unexecuted instantiation: mps_main.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_lib.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_onsetdetect.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_paramextract.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_staticgain.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_tree.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_vectorfunctions.cpp:CalcInvLdData(int)
Unexecuted instantiation: bit_sbr.cpp:CalcInvLdData(int)
Unexecuted instantiation: ps_main.cpp:CalcInvLdData(int)
Unexecuted instantiation: sbr_encoder.cpp:CalcInvLdData(int)
Unexecuted instantiation: sbrenc_freq_sca.cpp:CalcInvLdData(int)
Unexecuted instantiation: sbrenc_ram.cpp:CalcInvLdData(int)
Unexecuted instantiation: sbrenc_rom.cpp:CalcInvLdData(int)
Unexecuted instantiation: ton_corr.cpp:CalcInvLdData(int)
Unexecuted instantiation: tran_det.cpp:CalcInvLdData(int)
Unexecuted instantiation: pcm_utils.cpp:CalcInvLdData(int)
Unexecuted instantiation: FDK_bitbuffer.cpp:CalcInvLdData(int)
Unexecuted instantiation: FDK_hybrid.cpp:CalcInvLdData(int)
Unexecuted instantiation: FDK_tools_rom.cpp:CalcInvLdData(int)
Unexecuted instantiation: autocorr2nd.cpp:CalcInvLdData(int)
Unexecuted instantiation: fixpoint_math.cpp:CalcInvLdData(int)
Unexecuted instantiation: qmf.cpp:CalcInvLdData(int)
Unexecuted instantiation: scale.cpp:CalcInvLdData(int)
Unexecuted instantiation: aacenc.cpp:CalcInvLdData(int)
Unexecuted instantiation: bandwidth.cpp:CalcInvLdData(int)
Unexecuted instantiation: bitenc.cpp:CalcInvLdData(int)
Unexecuted instantiation: metadata_compressor.cpp:CalcInvLdData(int)
Unexecuted instantiation: psy_main.cpp:CalcInvLdData(int)
Unexecuted instantiation: qc_main.cpp:CalcInvLdData(int)
Unexecuted instantiation: quantize.cpp:CalcInvLdData(int)
Unexecuted instantiation: sf_estim.cpp:CalcInvLdData(int)
Unexecuted instantiation: spreading.cpp:CalcInvLdData(int)
Unexecuted instantiation: tonality.cpp:CalcInvLdData(int)
Unexecuted instantiation: transform.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_bitstream.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_dmx_tdom_enh.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_filter.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_framewindowing.cpp:CalcInvLdData(int)
Unexecuted instantiation: sacenc_nlc_enc.cpp:CalcInvLdData(int)
Unexecuted instantiation: code_env.cpp:CalcInvLdData(int)
Unexecuted instantiation: env_bit.cpp:CalcInvLdData(int)
Unexecuted instantiation: env_est.cpp:CalcInvLdData(int)
Unexecuted instantiation: fram_gen.cpp:CalcInvLdData(int)
Unexecuted instantiation: invf_est.cpp:CalcInvLdData(int)
Unexecuted instantiation: mh_det.cpp:CalcInvLdData(int)
Unexecuted instantiation: nf_est.cpp:CalcInvLdData(int)
Unexecuted instantiation: ps_bitenc.cpp:CalcInvLdData(int)
Unexecuted instantiation: ps_encode.cpp:CalcInvLdData(int)
Unexecuted instantiation: resampler.cpp:CalcInvLdData(int)
Unexecuted instantiation: sbr_misc.cpp:CalcInvLdData(int)
Unexecuted instantiation: FDK_trigFcts.cpp:CalcInvLdData(int)
Unexecuted instantiation: dct.cpp:CalcInvLdData(int)
Unexecuted instantiation: fft.cpp:CalcInvLdData(int)
Unexecuted instantiation: fft_rad2.cpp:CalcInvLdData(int)
Unexecuted instantiation: mdct.cpp:CalcInvLdData(int)
Unexecuted instantiation: aacEnc_ram.cpp:CalcInvLdData(int)
Unexecuted instantiation: aacEnc_rom.cpp:CalcInvLdData(int)
Unexecuted instantiation: aacenc_pns.cpp:CalcInvLdData(int)
Unexecuted instantiation: aacenc_tns.cpp:CalcInvLdData(int)
Unexecuted instantiation: adj_thr.cpp:CalcInvLdData(int)
Unexecuted instantiation: band_nrg.cpp:CalcInvLdData(int)
Unexecuted instantiation: bit_cnt.cpp:CalcInvLdData(int)
Unexecuted instantiation: block_switch.cpp:CalcInvLdData(int)
Unexecuted instantiation: chaosmeasure.cpp:CalcInvLdData(int)
Unexecuted instantiation: dyn_bits.cpp:CalcInvLdData(int)
Unexecuted instantiation: grp_data.cpp:CalcInvLdData(int)
Unexecuted instantiation: intensity.cpp:CalcInvLdData(int)
Unexecuted instantiation: line_pe.cpp:CalcInvLdData(int)
Unexecuted instantiation: ms_stereo.cpp:CalcInvLdData(int)
Unexecuted instantiation: noisedet.cpp:CalcInvLdData(int)
Unexecuted instantiation: pnsparam.cpp:CalcInvLdData(int)
Unexecuted instantiation: pre_echo_control.cpp:CalcInvLdData(int)
Unexecuted instantiation: psy_configuration.cpp:CalcInvLdData(int)
Unexecuted instantiation: FDK_lpc.cpp:CalcInvLdData(int)
256
257
void InitLdInt();
258
FIXP_DBL CalcLdInt(INT i);
259
260
extern const USHORT sqrt_tab[49];
261
262
0
inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x) {
263
0
  UINT y = (INT)x;
264
0
  UCHAR is_zero = (y == 0);
265
0
  INT zeros = fixnormz_D(y) & 0x1e;
266
0
  y <<= zeros;
267
0
  UINT idx = (y >> 26) - 16;
268
0
  USHORT frac = (y >> 10) & 0xffff;
269
0
  USHORT nfrac = 0xffff ^ frac;
270
0
  UINT t = (UINT)nfrac * sqrt_tab[idx] + (UINT)frac * sqrt_tab[idx + 1];
271
0
  t = t >> (zeros >> 1);
272
0
  return (is_zero ? 0 : t);
273
0
}
274
275
0
inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x, INT *x_e) {
276
0
  UINT y = (INT)x;
277
0
  INT e;
278
0
279
0
  if (x == (FIXP_DBL)0) {
280
0
    return x;
281
0
  }
282
0
283
0
  /* Normalize */
284
0
  e = fixnormz_D(y);
285
0
  y <<= e;
286
0
  e = *x_e - e + 2;
287
0
288
0
  /* Correct odd exponent. */
289
0
  if (e & 1) {
290
0
    y >>= 1;
291
0
    e++;
292
0
  }
293
0
  /* Get square root */
294
0
  UINT idx = (y >> 26) - 16;
295
0
  USHORT frac = (y >> 10) & 0xffff;
296
0
  USHORT nfrac = 0xffff ^ frac;
297
0
  UINT t = (UINT)nfrac * sqrt_tab[idx] + (UINT)frac * sqrt_tab[idx + 1];
298
0
299
0
  /* Write back exponent */
300
0
  *x_e = e >> 1;
301
0
  return (FIXP_DBL)(LONG)(t >> 1);
302
0
}
303
304
void InitInvSqrtTab();
305
306
#ifndef FUNCTION_invSqrtNorm2
307
/**
308
 * \brief calculate 1.0/sqrt(op)
309
 * \param op_m mantissa of input value.
310
 * \param result_e pointer to return the exponent of the result
311
 * \return mantissa of the result
312
 */
313
/*****************************************************************************
314
  delivers 1/sqrt(op) normalized to .5...1 and the shift value of the OUTPUT,
315
  i.e. the denormalized result is 1/sqrt(op) = invSqrtNorm(op) * 2^(shift)
316
  uses Newton-iteration for approximation
317
      Q(n+1) = Q(n) + Q(n) * (0.5 - 2 * V * Q(n)^2)
318
      with Q = 0.5* V ^-0.5; 0.5 <= V < 1.0
319
*****************************************************************************/
320
static FDK_FORCEINLINE FIXP_DBL invSqrtNorm2(FIXP_DBL op, INT *shift) {
321
  FIXP_DBL val = op;
322
  FIXP_DBL reg1, reg2;
323
324
  if (val == FL2FXCONST_DBL(0.0)) {
325
    *shift = 16;
326
    return ((LONG)MAXVAL_DBL); /* maximum positive value */
327
  }
328
329
#define INVSQRTNORM2_LINEAR_INTERPOLATE
330
#define INVSQRTNORM2_LINEAR_INTERPOLATE_HQ
331
332
  /* normalize input, calculate shift value */
333
  FDK_ASSERT(val > FL2FXCONST_DBL(0.0));
334
  *shift = fNormz(val) - 1; /* CountLeadingBits() is not necessary here since
335
                               test value is always > 0 */
336
  val <<= *shift;           /* normalized input V */
337
  *shift += 2;              /* bias for exponent */
338
339
#if defined(INVSQRTNORM2_LINEAR_INTERPOLATE)
340
  INT index =
341
      (INT)(val >> (DFRACT_BITS - 1 - (SQRT_BITS + 1))) & SQRT_BITS_MASK;
342
  FIXP_DBL Fract =
343
      (FIXP_DBL)(((INT)val & SQRT_FRACT_BITS_MASK) << (SQRT_BITS + 1));
344
  FIXP_DBL diff = invSqrtTab[index + 1] - invSqrtTab[index];
345
  reg1 = invSqrtTab[index] + (fMultDiv2(diff, Fract) << 1);
346
#if defined(INVSQRTNORM2_LINEAR_INTERPOLATE_HQ)
347
  /* reg1 = t[i] + (t[i+1]-t[i])*fract ... already computed ...
348
                                       + (1-fract)fract*(t[i+2]-t[i+1])/2 */
349
  if (Fract != (FIXP_DBL)0) {
350
    /* fract = fract * (1 - fract) */
351
    Fract = fMultDiv2(Fract, (FIXP_DBL)((ULONG)0x80000000 - (ULONG)Fract)) << 1;
352
    diff = diff - (invSqrtTab[index + 2] - invSqrtTab[index + 1]);
353
    reg1 = fMultAddDiv2(reg1, Fract, diff);
354
  }
355
#endif /* INVSQRTNORM2_LINEAR_INTERPOLATE_HQ */
356
#else
357
#error \
358
    "Either define INVSQRTNORM2_NEWTON_ITERATE or INVSQRTNORM2_LINEAR_INTERPOLATE"
359
#endif
360
  /* calculate the output exponent = input exp/2 */
361
  if (*shift & 0x00000001) { /* odd shift values ? */
362
    /* Note: Do not use rounded value 0x5A82799A to avoid overflow with
363
     * shift-by-2 */
364
    reg2 = (FIXP_DBL)0x5A827999;
365
    /* FL2FXCONST_DBL(0.707106781186547524400844362104849f);*/ /* 1/sqrt(2);
366
                                                                */
367
    reg1 = fMultDiv2(reg1, reg2) << 2;
368
  }
369
370
  *shift = *shift >> 1;
371
372
  return (reg1);
373
}
374
#endif /* FUNCTION_invSqrtNorm2 */
375
376
#ifndef FUNCTION_sqrtFixp
377
static FDK_FORCEINLINE FIXP_DBL sqrtFixp(FIXP_DBL op) {
378
  INT tmp_exp = 0;
379
  FIXP_DBL tmp_inv = invSqrtNorm2(op, &tmp_exp);
380
381
  FDK_ASSERT(tmp_exp > 0);
382
  return ((FIXP_DBL)(fMultDiv2((op << (tmp_exp - 1)), tmp_inv) << 2));
383
}
384
#endif /* FUNCTION_sqrtFixp */
385
386
#ifndef FUNCTION_invFixp
387
/**
388
 * \brief calculate 1.0/op
389
 * \param op mantissa of the input value.
390
 * \return mantissa of the result with implicit exponent of 31
391
 * \exceptions are provided for op=0,1 setting max. positive value
392
 */
393
static inline FIXP_DBL invFixp(FIXP_DBL op) {
394
  if ((op == (FIXP_DBL)0x00000000) || (op == (FIXP_DBL)0x00000001)) {
395
    return ((LONG)MAXVAL_DBL);
396
  }
397
  INT tmp_exp;
398
  FIXP_DBL tmp_inv = invSqrtNorm2(op, &tmp_exp);
399
  FDK_ASSERT((31 - (2 * tmp_exp + 1)) >= 0);
400
  int shift = 31 - (2 * tmp_exp + 1);
401
  tmp_inv = fPow2Div2(tmp_inv);
402
  if (shift) {
403
    tmp_inv = ((tmp_inv >> (shift - 1)) + (FIXP_DBL)1) >> 1;
404
  }
405
  return tmp_inv;
406
}
407
408
/**
409
 * \brief calculate 1.0/(op_m * 2^op_e)
410
 * \param op_m mantissa of the input value.
411
 * \param op_e pointer into were the exponent of the input value is stored, and
412
 * the result will be stored into.
413
 * \return mantissa of the result
414
 */
415
static inline FIXP_DBL invFixp(FIXP_DBL op_m, int *op_e) {
416
  if ((op_m == (FIXP_DBL)0x00000000) || (op_m == (FIXP_DBL)0x00000001)) {
417
    *op_e = 31 - *op_e;
418
    return ((LONG)MAXVAL_DBL);
419
  }
420
421
  INT tmp_exp;
422
  FIXP_DBL tmp_inv = invSqrtNorm2(op_m, &tmp_exp);
423
424
  *op_e = (tmp_exp << 1) - *op_e + 1;
425
  return fPow2Div2(tmp_inv);
426
}
427
#endif /* FUNCTION_invFixp */
428
429
#ifndef FUNCTION_schur_div
430
431
/**
432
 * \brief Divide two FIXP_DBL values with given precision.
433
 * \param num dividend
434
 * \param denum divisor
435
 * \param count amount of significant bits of the result (starting to the MSB)
436
 * \return num/divisor
437
 */
438
439
FIXP_DBL schur_div(FIXP_DBL num, FIXP_DBL denum, INT count);
440
441
#endif /* FUNCTION_schur_div */
442
443
FIXP_DBL mul_dbl_sgl_rnd(const FIXP_DBL op1, const FIXP_SGL op2);
444
445
#ifndef FUNCTION_fMultNorm
446
/**
447
 * \brief multiply two values with normalization, thus max precision.
448
 * Author: Robert Weidner
449
 *
450
 * \param f1 first factor
451
 * \param f2 second factor
452
 * \param result_e pointer to an INT where the exponent of the result is stored
453
 * into
454
 * \return mantissa of the product f1*f2
455
 */
456
FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2, INT *result_e);
457
458
/**
459
 * \brief Multiply 2 values using maximum precision. The exponent of the result
460
 * is 0.
461
 * \param f1_m mantissa of factor 1
462
 * \param f2_m mantissa of factor 2
463
 * \return mantissa of the result with exponent equal to 0
464
 */
465
0
inline FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2) {
466
0
  FIXP_DBL m;
467
0
  INT e;
468
469
0
  m = fMultNorm(f1, f2, &e);
470
471
0
  m = scaleValueSaturate(m, e);
472
473
0
  return m;
474
0
}
475
476
/**
477
 * \brief Multiply 2 values with exponent and use given exponent for the
478
 * mantissa of the result.
479
 * \param f1_m mantissa of factor 1
480
 * \param f1_e exponent of factor 1
481
 * \param f2_m mantissa of factor 2
482
 * \param f2_e exponent of factor 2
483
 * \param result_e exponent for the returned mantissa of the result
484
 * \return mantissa of the result with exponent equal to result_e
485
 */
486
inline FIXP_DBL fMultNorm(FIXP_DBL f1_m, INT f1_e, FIXP_DBL f2_m, INT f2_e,
487
0
                          INT result_e) {
488
0
  FIXP_DBL m;
489
0
  INT e;
490
491
0
  m = fMultNorm(f1_m, f2_m, &e);
492
493
0
  m = scaleValueSaturate(m, e + f1_e + f2_e - result_e);
494
495
0
  return m;
496
0
}
497
#endif /* FUNCTION_fMultNorm */
498
499
#ifndef FUNCTION_fMultI
500
/**
501
 * \brief Multiplies a fractional value and a integer value and performs
502
 * rounding to nearest
503
 * \param a fractional value
504
 * \param b integer value
505
 * \return integer value
506
 */
507
0
inline INT fMultI(FIXP_DBL a, INT b) {
508
0
  FIXP_DBL m, mi;
509
0
  INT m_e;
510
511
0
  m = fMultNorm(a, (FIXP_DBL)b, &m_e);
512
513
0
  if (m_e < (INT)0) {
514
0
    if (m_e > (INT)-DFRACT_BITS) {
515
0
      m = m >> ((-m_e) - 1);
516
0
      mi = (m + (FIXP_DBL)1) >> 1;
517
0
    } else {
518
0
      mi = (FIXP_DBL)0;
519
0
    }
520
0
  } else {
521
0
    mi = scaleValueSaturate(m, m_e);
522
0
  }
523
524
0
  return ((INT)mi);
525
0
}
526
#endif /* FUNCTION_fMultI */
527
528
#ifndef FUNCTION_fMultIfloor
529
/**
530
 * \brief Multiplies a fractional value and a integer value and performs floor
531
 * rounding
532
 * \param a fractional value
533
 * \param b integer value
534
 * \return integer value
535
 */
536
0
inline INT fMultIfloor(FIXP_DBL a, INT b) {
537
0
  FIXP_DBL m, mi;
538
0
  INT m_e;
539
540
0
  m = fMultNorm(a, (FIXP_DBL)b, &m_e);
541
542
0
  if (m_e < (INT)0) {
543
0
    if (m_e > (INT)-DFRACT_BITS) {
544
0
      mi = m >> (-m_e);
545
0
    } else {
546
0
      mi = (FIXP_DBL)0;
547
0
      if (m < (FIXP_DBL)0) {
548
0
        mi = (FIXP_DBL)-1;
549
0
      }
550
0
    }
551
0
  } else {
552
0
    mi = scaleValueSaturate(m, m_e);
553
0
  }
554
555
0
  return ((INT)mi);
556
0
}
557
#endif /* FUNCTION_fMultIfloor */
558
559
#ifndef FUNCTION_fMultIceil
560
/**
561
 * \brief Multiplies a fractional value and a integer value and performs ceil
562
 * rounding
563
 * \param a fractional value
564
 * \param b integer value
565
 * \return integer value
566
 */
567
0
inline INT fMultIceil(FIXP_DBL a, INT b) {
568
0
  FIXP_DBL m, mi;
569
0
  INT m_e;
570
0
571
0
  m = fMultNorm(a, (FIXP_DBL)b, &m_e);
572
0
573
0
  if (m_e < (INT)0) {
574
0
    if (m_e > (INT) - (DFRACT_BITS - 1)) {
575
0
      mi = (m >> (-m_e));
576
0
      if ((LONG)m & ((1 << (-m_e)) - 1)) {
577
0
        mi = mi + (FIXP_DBL)1;
578
0
      }
579
0
    } else {
580
0
      if (m > (FIXP_DBL)0) {
581
0
        mi = (FIXP_DBL)1;
582
0
      } else {
583
0
        if ((m_e == -(DFRACT_BITS - 1)) && (m == (FIXP_DBL)MINVAL_DBL)) {
584
0
          mi = (FIXP_DBL)-1;
585
0
        } else {
586
0
          mi = (FIXP_DBL)0;
587
0
        }
588
0
      }
589
0
    }
590
0
  } else {
591
0
    mi = scaleValueSaturate(m, m_e);
592
0
  }
593
0
594
0
  return ((INT)mi);
595
0
}
596
#endif /* FUNCTION_fMultIceil */
597
598
#ifndef FUNCTION_fDivNorm
599
/**
600
 * \brief Divide 2 FIXP_DBL values with normalization of input values.
601
 * \param num numerator
602
 * \param denum denominator
603
 * \param result_e pointer to an INT where the exponent of the result is stored
604
 * into
605
 * \return num/denum with exponent = *result_e
606
 */
607
FIXP_DBL fDivNorm(FIXP_DBL num, FIXP_DBL denom, INT *result_e);
608
609
/**
610
 * \brief Divide 2 positive FIXP_DBL values with normalization of input values.
611
 * \param num numerator
612
 * \param denum denominator
613
 * \return num/denum with exponent = 0
614
 */
615
FIXP_DBL fDivNorm(FIXP_DBL num, FIXP_DBL denom);
616
617
/**
618
 * \brief Divide 2 signed FIXP_DBL values with normalization of input values.
619
 * \param num numerator
620
 * \param denum denominator
621
 * \param result_e pointer to an INT where the exponent of the result is stored
622
 * into
623
 * \return num/denum with exponent = *result_e
624
 */
625
FIXP_DBL fDivNormSigned(FIXP_DBL L_num, FIXP_DBL L_denum, INT *result_e);
626
627
/**
628
 * \brief Divide 2 signed FIXP_DBL values with normalization of input values.
629
 * \param num numerator
630
 * \param denum denominator
631
 * \return num/denum with exponent = 0
632
 */
633
FIXP_DBL fDivNormSigned(FIXP_DBL num, FIXP_DBL denom);
634
#endif /* FUNCTION_fDivNorm */
635
636
/**
637
 * \brief Adjust mantissa to exponent -1
638
 * \param a_m mantissa of value to be adjusted
639
 * \param pA_e pointer to the exponen of a_m
640
 * \return adjusted mantissa
641
 */
642
0
inline FIXP_DBL fAdjust(FIXP_DBL a_m, INT *pA_e) {
643
0
  INT shift;
644
645
0
  shift = fNorm(a_m) - 1;
646
0
  *pA_e -= shift;
647
648
0
  return scaleValue(a_m, shift);
649
0
}
650
651
#ifndef FUNCTION_fAddNorm
652
/**
653
 * \brief Add two values with normalization
654
 * \param a_m mantissa of first summand
655
 * \param a_e exponent of first summand
656
 * \param a_m mantissa of second summand
657
 * \param a_e exponent of second summand
658
 * \param pResult_e pointer to where the exponent of the result will be stored
659
 * to.
660
 * \return mantissa of result
661
 */
662
inline FIXP_DBL fAddNorm(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e,
663
0
                         INT *pResult_e) {
664
0
  INT result_e;
665
0
  FIXP_DBL result_m;
666
667
  /* If one of the summands is zero, return the other.
668
     This is necessary for the summation of a very small number to zero */
669
0
  if (a_m == (FIXP_DBL)0) {
670
0
    *pResult_e = b_e;
671
0
    return b_m;
672
0
  }
673
0
  if (b_m == (FIXP_DBL)0) {
674
0
    *pResult_e = a_e;
675
0
    return a_m;
676
0
  }
677
678
0
  a_m = fAdjust(a_m, &a_e);
679
0
  b_m = fAdjust(b_m, &b_e);
680
681
0
  if (a_e > b_e) {
682
0
    result_m = a_m + (b_m >> fMin(a_e - b_e, DFRACT_BITS - 1));
683
0
    result_e = a_e;
684
0
  } else {
685
0
    result_m = (a_m >> fMin(b_e - a_e, DFRACT_BITS - 1)) + b_m;
686
0
    result_e = b_e;
687
0
  }
688
689
0
  *pResult_e = result_e;
690
0
  return result_m;
691
0
}
692
693
inline FIXP_DBL fAddNorm(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e,
694
0
                         INT result_e) {
695
0
  FIXP_DBL result_m;
696
0
697
0
  a_m = scaleValue(a_m, a_e - result_e);
698
0
  b_m = scaleValue(b_m, b_e - result_e);
699
0
700
0
  result_m = a_m + b_m;
701
0
702
0
  return result_m;
703
0
}
704
#endif /* FUNCTION_fAddNorm */
705
706
/**
707
 * \brief Divide 2 FIXP_DBL values with normalization of input values.
708
 * \param num numerator
709
 * \param denum denomintator
710
 * \return num/denum with exponent = 0
711
 */
712
FIXP_DBL fDivNormHighPrec(FIXP_DBL L_num, FIXP_DBL L_denum, INT *result_e);
713
714
#ifndef FUNCTION_fPow
715
/**
716
 * \brief return 2 ^ (exp_m * 2^exp_e)
717
 * \param exp_m mantissa of the exponent to 2.0f
718
 * \param exp_e exponent of the exponent to 2.0f
719
 * \param result_e pointer to a INT where the exponent of the result will be
720
 * stored into
721
 * \return mantissa of the result
722
 */
723
FIXP_DBL f2Pow(const FIXP_DBL exp_m, const INT exp_e, INT *result_e);
724
725
/**
726
 * \brief return 2 ^ (exp_m * 2^exp_e). This version returns only the mantissa
727
 * with implicit exponent of zero.
728
 * \param exp_m mantissa of the exponent to 2.0f
729
 * \param exp_e exponent of the exponent to 2.0f
730
 * \return mantissa of the result
731
 */
732
FIXP_DBL f2Pow(const FIXP_DBL exp_m, const INT exp_e);
733
734
/**
735
 * \brief return x ^ (exp_m * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e).
736
 * This saves the need to compute log2() of constant values (when x is a
737
 * constant).
738
 * \param baseLd_m mantissa of log2() of x.
739
 * \param baseLd_e exponent of log2() of x.
740
 * \param exp_m mantissa of the exponent to 2.0f
741
 * \param exp_e exponent of the exponent to 2.0f
742
 * \param result_e pointer to a INT where the exponent of the result will be
743
 * stored into
744
 * \return mantissa of the result
745
 */
746
FIXP_DBL fLdPow(FIXP_DBL baseLd_m, INT baseLd_e, FIXP_DBL exp_m, INT exp_e,
747
                INT *result_e);
748
749
/**
750
 * \brief return x ^ (exp_m * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e).
751
 * This saves the need to compute log2() of constant values (when x is a
752
 * constant). This version does not return an exponent, which is
753
 * implicitly 0.
754
 * \param baseLd_m mantissa of log2() of x.
755
 * \param baseLd_e exponent of log2() of x.
756
 * \param exp_m mantissa of the exponent to 2.0f
757
 * \param exp_e exponent of the exponent to 2.0f
758
 * \return mantissa of the result
759
 */
760
FIXP_DBL fLdPow(FIXP_DBL baseLd_m, INT baseLd_e, FIXP_DBL exp_m, INT exp_e);
761
762
/**
763
 * \brief return (base_m * 2^base_e) ^ (exp * 2^exp_e). Use fLdPow() instead
764
 * whenever possible.
765
 * \param base_m mantissa of the base.
766
 * \param base_e exponent of the base.
767
 * \param exp_m mantissa of power to be calculated of the base.
768
 * \param exp_e exponent of power to be calculated of the base.
769
 * \param result_e pointer to a INT where the exponent of the result will be
770
 * stored into.
771
 * \return mantissa of the result.
772
 */
773
FIXP_DBL fPow(FIXP_DBL base_m, INT base_e, FIXP_DBL exp_m, INT exp_e,
774
              INT *result_e);
775
776
/**
777
 * \brief return (base_m * 2^base_e) ^ N
778
 * \param base_m mantissa of the base. Must not be negative.
779
 * \param base_e exponent of the base
780
 * \param N power to be calculated of the base
781
 * \param result_e pointer to a INT where the exponent of the result will be
782
 * stored into
783
 * \return mantissa of the result
784
 */
785
FIXP_DBL fPowInt(FIXP_DBL base_m, INT base_e, INT N, INT *result_e);
786
#endif /* #ifndef FUNCTION_fPow */
787
788
#ifndef FUNCTION_fLog2
789
/**
790
 * \brief Calculate log(argument)/log(2) (logarithm with base 2). deprecated.
791
 * Use fLog2() instead.
792
 * \param arg mantissa of the argument
793
 * \param arg_e exponent of the argument
794
 * \param result_e pointer to an INT to store the exponent of the result
795
 * \return the mantissa of the result.
796
 * \param
797
 */
798
FIXP_DBL CalcLog2(FIXP_DBL arg, INT arg_e, INT *result_e);
799
800
/**
801
 * \brief calculate logarithm of base 2 of x_m * 2^(x_e)
802
 * \param x_m mantissa of the input value.
803
 * \param x_e exponent of the input value.
804
 * \param pointer to an INT where the exponent of the result is returned into.
805
 * \return mantissa of the result.
806
 */
807
0
FDK_INLINE FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e, INT *result_e) {
808
0
  FIXP_DBL result_m;
809
810
  /* Short cut for zero and negative numbers. */
811
0
  if (x_m <= FL2FXCONST_DBL(0.0f)) {
812
0
    *result_e = DFRACT_BITS - 1;
813
0
    return FL2FXCONST_DBL(-1.0f);
814
0
  }
815
816
  /* Calculate log2() */
817
0
  {
818
0
    FIXP_DBL x2_m;
819
820
    /* Move input value x_m * 2^x_e toward 1.0, where the taylor approximation
821
       of the function log(1-x) centered at 0 is most accurate. */
822
0
    {
823
0
      INT b_norm;
824
825
0
      b_norm = fNormz(x_m) - 1;
826
0
      x2_m = x_m << b_norm;
827
0
      x_e = x_e - b_norm;
828
0
    }
829
830
    /* map x from log(x) domain to log(1-x) domain. */
831
0
    x2_m = -(x2_m + FL2FXCONST_DBL(-1.0));
832
833
    /* Taylor polynomial approximation of ln(1-x) */
834
0
    {
835
0
      FIXP_DBL px2_m;
836
0
      result_m = FL2FXCONST_DBL(0.0);
837
0
      px2_m = x2_m;
838
0
      for (int i = 0; i < LD_PRECISION; i++) {
839
0
        result_m = fMultAddDiv2(result_m, ldCoeff[i], px2_m);
840
0
        px2_m = fMult(px2_m, x2_m);
841
0
      }
842
0
    }
843
    /* Multiply result with 1/ln(2) = 1.0 + 0.442695040888 (get log2(x) from
844
     * ln(x) result). */
845
0
    result_m =
846
0
        fMultAddDiv2(result_m, result_m,
847
0
                     FL2FXCONST_DBL(2.0 * 0.4426950408889634073599246810019));
848
849
    /* Add exponent part. log2(x_m * 2^x_e) = log2(x_m) + x_e */
850
0
    if (x_e != 0) {
851
0
      int enorm;
852
853
0
      enorm = DFRACT_BITS - fNorm((FIXP_DBL)x_e);
854
      /* The -1 in the right shift of result_m compensates the fMultDiv2() above
855
       * in the taylor polynomial evaluation loop.*/
856
0
      result_m = (result_m >> (enorm - 1)) +
857
0
                 ((FIXP_DBL)x_e << (DFRACT_BITS - 1 - enorm));
858
859
0
      *result_e = enorm;
860
0
    } else {
861
      /* 1 compensates the fMultDiv2() above in the taylor polynomial evaluation
862
       * loop.*/
863
0
      *result_e = 1;
864
0
    }
865
0
  }
866
867
0
  return result_m;
868
0
}
Unexecuted instantiation: aacenc_lib.cpp:fLog2(int, int, int*)
Unexecuted instantiation: channel_map.cpp:fLog2(int, int, int*)
Unexecuted instantiation: metadata_main.cpp:fLog2(int, int, int*)
Unexecuted instantiation: mps_main.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_lib.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_onsetdetect.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_paramextract.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_staticgain.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_tree.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_vectorfunctions.cpp:fLog2(int, int, int*)
Unexecuted instantiation: bit_sbr.cpp:fLog2(int, int, int*)
Unexecuted instantiation: ps_main.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sbr_encoder.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sbrenc_freq_sca.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sbrenc_ram.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sbrenc_rom.cpp:fLog2(int, int, int*)
Unexecuted instantiation: ton_corr.cpp:fLog2(int, int, int*)
Unexecuted instantiation: tran_det.cpp:fLog2(int, int, int*)
Unexecuted instantiation: pcm_utils.cpp:fLog2(int, int, int*)
Unexecuted instantiation: FDK_bitbuffer.cpp:fLog2(int, int, int*)
Unexecuted instantiation: FDK_hybrid.cpp:fLog2(int, int, int*)
Unexecuted instantiation: FDK_tools_rom.cpp:fLog2(int, int, int*)
Unexecuted instantiation: autocorr2nd.cpp:fLog2(int, int, int*)
Unexecuted instantiation: fixpoint_math.cpp:fLog2(int, int, int*)
Unexecuted instantiation: qmf.cpp:fLog2(int, int, int*)
Unexecuted instantiation: scale.cpp:fLog2(int, int, int*)
Unexecuted instantiation: aacenc.cpp:fLog2(int, int, int*)
Unexecuted instantiation: bandwidth.cpp:fLog2(int, int, int*)
Unexecuted instantiation: bitenc.cpp:fLog2(int, int, int*)
Unexecuted instantiation: metadata_compressor.cpp:fLog2(int, int, int*)
Unexecuted instantiation: psy_main.cpp:fLog2(int, int, int*)
Unexecuted instantiation: qc_main.cpp:fLog2(int, int, int*)
Unexecuted instantiation: quantize.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sf_estim.cpp:fLog2(int, int, int*)
Unexecuted instantiation: spreading.cpp:fLog2(int, int, int*)
Unexecuted instantiation: tonality.cpp:fLog2(int, int, int*)
Unexecuted instantiation: transform.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_bitstream.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_dmx_tdom_enh.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_filter.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_framewindowing.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sacenc_nlc_enc.cpp:fLog2(int, int, int*)
Unexecuted instantiation: code_env.cpp:fLog2(int, int, int*)
Unexecuted instantiation: env_bit.cpp:fLog2(int, int, int*)
Unexecuted instantiation: env_est.cpp:fLog2(int, int, int*)
Unexecuted instantiation: fram_gen.cpp:fLog2(int, int, int*)
Unexecuted instantiation: invf_est.cpp:fLog2(int, int, int*)
Unexecuted instantiation: mh_det.cpp:fLog2(int, int, int*)
Unexecuted instantiation: nf_est.cpp:fLog2(int, int, int*)
Unexecuted instantiation: ps_bitenc.cpp:fLog2(int, int, int*)
Unexecuted instantiation: ps_encode.cpp:fLog2(int, int, int*)
Unexecuted instantiation: resampler.cpp:fLog2(int, int, int*)
Unexecuted instantiation: sbr_misc.cpp:fLog2(int, int, int*)
Unexecuted instantiation: FDK_trigFcts.cpp:fLog2(int, int, int*)
Unexecuted instantiation: dct.cpp:fLog2(int, int, int*)
Unexecuted instantiation: fft.cpp:fLog2(int, int, int*)
Unexecuted instantiation: fft_rad2.cpp:fLog2(int, int, int*)
Unexecuted instantiation: mdct.cpp:fLog2(int, int, int*)
Unexecuted instantiation: aacEnc_ram.cpp:fLog2(int, int, int*)
Unexecuted instantiation: aacEnc_rom.cpp:fLog2(int, int, int*)
Unexecuted instantiation: aacenc_pns.cpp:fLog2(int, int, int*)
Unexecuted instantiation: aacenc_tns.cpp:fLog2(int, int, int*)
Unexecuted instantiation: adj_thr.cpp:fLog2(int, int, int*)
Unexecuted instantiation: band_nrg.cpp:fLog2(int, int, int*)
Unexecuted instantiation: bit_cnt.cpp:fLog2(int, int, int*)
Unexecuted instantiation: block_switch.cpp:fLog2(int, int, int*)
Unexecuted instantiation: chaosmeasure.cpp:fLog2(int, int, int*)
Unexecuted instantiation: dyn_bits.cpp:fLog2(int, int, int*)
Unexecuted instantiation: grp_data.cpp:fLog2(int, int, int*)
Unexecuted instantiation: intensity.cpp:fLog2(int, int, int*)
Unexecuted instantiation: line_pe.cpp:fLog2(int, int, int*)
Unexecuted instantiation: ms_stereo.cpp:fLog2(int, int, int*)
Unexecuted instantiation: noisedet.cpp:fLog2(int, int, int*)
Unexecuted instantiation: pnsparam.cpp:fLog2(int, int, int*)
Unexecuted instantiation: pre_echo_control.cpp:fLog2(int, int, int*)
Unexecuted instantiation: psy_configuration.cpp:fLog2(int, int, int*)
Unexecuted instantiation: FDK_lpc.cpp:fLog2(int, int, int*)
869
870
/**
871
 * \brief calculate logarithm of base 2 of x_m * 2^(x_e)
872
 * \param x_m mantissa of the input value.
873
 * \param x_e exponent of the input value.
874
 * \return mantissa of the result with implicit exponent of LD_DATA_SHIFT.
875
 */
876
0
FDK_INLINE FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e) {
877
0
  if (x_m <= FL2FXCONST_DBL(0.0f)) {
878
0
    x_m = FL2FXCONST_DBL(-1.0f);
879
0
  } else {
880
0
    INT result_e;
881
0
    x_m = fLog2(x_m, x_e, &result_e);
882
0
    x_m = scaleValue(x_m, result_e - LD_DATA_SHIFT);
883
0
  }
884
0
  return x_m;
885
0
}
Unexecuted instantiation: aacenc_lib.cpp:fLog2(int, int)
Unexecuted instantiation: channel_map.cpp:fLog2(int, int)
Unexecuted instantiation: metadata_main.cpp:fLog2(int, int)
Unexecuted instantiation: mps_main.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_lib.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_onsetdetect.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_paramextract.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_staticgain.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_tree.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_vectorfunctions.cpp:fLog2(int, int)
Unexecuted instantiation: bit_sbr.cpp:fLog2(int, int)
Unexecuted instantiation: ps_main.cpp:fLog2(int, int)
Unexecuted instantiation: sbr_encoder.cpp:fLog2(int, int)
Unexecuted instantiation: sbrenc_freq_sca.cpp:fLog2(int, int)
Unexecuted instantiation: sbrenc_ram.cpp:fLog2(int, int)
Unexecuted instantiation: sbrenc_rom.cpp:fLog2(int, int)
Unexecuted instantiation: ton_corr.cpp:fLog2(int, int)
Unexecuted instantiation: tran_det.cpp:fLog2(int, int)
Unexecuted instantiation: pcm_utils.cpp:fLog2(int, int)
Unexecuted instantiation: FDK_bitbuffer.cpp:fLog2(int, int)
Unexecuted instantiation: FDK_hybrid.cpp:fLog2(int, int)
Unexecuted instantiation: FDK_tools_rom.cpp:fLog2(int, int)
Unexecuted instantiation: autocorr2nd.cpp:fLog2(int, int)
Unexecuted instantiation: fixpoint_math.cpp:fLog2(int, int)
Unexecuted instantiation: qmf.cpp:fLog2(int, int)
Unexecuted instantiation: scale.cpp:fLog2(int, int)
Unexecuted instantiation: aacenc.cpp:fLog2(int, int)
Unexecuted instantiation: bandwidth.cpp:fLog2(int, int)
Unexecuted instantiation: bitenc.cpp:fLog2(int, int)
Unexecuted instantiation: metadata_compressor.cpp:fLog2(int, int)
Unexecuted instantiation: psy_main.cpp:fLog2(int, int)
Unexecuted instantiation: qc_main.cpp:fLog2(int, int)
Unexecuted instantiation: quantize.cpp:fLog2(int, int)
Unexecuted instantiation: sf_estim.cpp:fLog2(int, int)
Unexecuted instantiation: spreading.cpp:fLog2(int, int)
Unexecuted instantiation: tonality.cpp:fLog2(int, int)
Unexecuted instantiation: transform.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_bitstream.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_dmx_tdom_enh.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_filter.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_framewindowing.cpp:fLog2(int, int)
Unexecuted instantiation: sacenc_nlc_enc.cpp:fLog2(int, int)
Unexecuted instantiation: code_env.cpp:fLog2(int, int)
Unexecuted instantiation: env_bit.cpp:fLog2(int, int)
Unexecuted instantiation: env_est.cpp:fLog2(int, int)
Unexecuted instantiation: fram_gen.cpp:fLog2(int, int)
Unexecuted instantiation: invf_est.cpp:fLog2(int, int)
Unexecuted instantiation: mh_det.cpp:fLog2(int, int)
Unexecuted instantiation: nf_est.cpp:fLog2(int, int)
Unexecuted instantiation: ps_bitenc.cpp:fLog2(int, int)
Unexecuted instantiation: ps_encode.cpp:fLog2(int, int)
Unexecuted instantiation: resampler.cpp:fLog2(int, int)
Unexecuted instantiation: sbr_misc.cpp:fLog2(int, int)
Unexecuted instantiation: FDK_trigFcts.cpp:fLog2(int, int)
Unexecuted instantiation: dct.cpp:fLog2(int, int)
Unexecuted instantiation: fft.cpp:fLog2(int, int)
Unexecuted instantiation: fft_rad2.cpp:fLog2(int, int)
Unexecuted instantiation: mdct.cpp:fLog2(int, int)
Unexecuted instantiation: aacEnc_ram.cpp:fLog2(int, int)
Unexecuted instantiation: aacEnc_rom.cpp:fLog2(int, int)
Unexecuted instantiation: aacenc_pns.cpp:fLog2(int, int)
Unexecuted instantiation: aacenc_tns.cpp:fLog2(int, int)
Unexecuted instantiation: adj_thr.cpp:fLog2(int, int)
Unexecuted instantiation: band_nrg.cpp:fLog2(int, int)
Unexecuted instantiation: bit_cnt.cpp:fLog2(int, int)
Unexecuted instantiation: block_switch.cpp:fLog2(int, int)
Unexecuted instantiation: chaosmeasure.cpp:fLog2(int, int)
Unexecuted instantiation: dyn_bits.cpp:fLog2(int, int)
Unexecuted instantiation: grp_data.cpp:fLog2(int, int)
Unexecuted instantiation: intensity.cpp:fLog2(int, int)
Unexecuted instantiation: line_pe.cpp:fLog2(int, int)
Unexecuted instantiation: ms_stereo.cpp:fLog2(int, int)
Unexecuted instantiation: noisedet.cpp:fLog2(int, int)
Unexecuted instantiation: pnsparam.cpp:fLog2(int, int)
Unexecuted instantiation: pre_echo_control.cpp:fLog2(int, int)
Unexecuted instantiation: psy_configuration.cpp:fLog2(int, int)
Unexecuted instantiation: FDK_lpc.cpp:fLog2(int, int)
886
887
#endif /* FUNCTION_fLog2 */
888
889
#ifndef FUNCTION_fAddSaturate
890
/**
891
 * \brief Add with saturation of the result.
892
 * \param a first summand
893
 * \param b second summand
894
 * \return saturated sum of a and b.
895
 */
896
0
inline FIXP_SGL fAddSaturate(const FIXP_SGL a, const FIXP_SGL b) {
897
0
  LONG sum;
898
0
899
0
  sum = (LONG)(SHORT)a + (LONG)(SHORT)b;
900
0
  sum = fMax(fMin((INT)sum, (INT)MAXVAL_SGL), (INT)MINVAL_SGL);
901
0
  return (FIXP_SGL)(SHORT)sum;
902
0
}
903
904
/**
905
 * \brief Add with saturation of the result.
906
 * \param a first summand
907
 * \param b second summand
908
 * \return saturated sum of a and b.
909
 */
910
0
inline FIXP_DBL fAddSaturate(const FIXP_DBL a, const FIXP_DBL b) {
911
0
  LONG sum;
912
913
0
  sum = (LONG)(a >> 1) + (LONG)(b >> 1);
914
0
  sum = fMax(fMin((INT)sum, (INT)(MAXVAL_DBL >> 1)), (INT)(MINVAL_DBL >> 1));
915
0
  return (FIXP_DBL)(LONG)(sum << 1);
916
0
}
917
#endif /* FUNCTION_fAddSaturate */
918
919
INT fixp_floorToInt(FIXP_DBL f_inp, INT sf);
920
FIXP_DBL fixp_floor(FIXP_DBL f_inp, INT sf);
921
922
INT fixp_ceilToInt(FIXP_DBL f_inp, INT sf);
923
FIXP_DBL fixp_ceil(FIXP_DBL f_inp, INT sf);
924
925
INT fixp_truncateToInt(FIXP_DBL f_inp, INT sf);
926
FIXP_DBL fixp_truncate(FIXP_DBL f_inp, INT sf);
927
928
INT fixp_roundToInt(FIXP_DBL f_inp, INT sf);
929
FIXP_DBL fixp_round(FIXP_DBL f_inp, INT sf);
930
931
/*****************************************************************************
932
933
 array for 1/n, n=1..80
934
935
****************************************************************************/
936
937
extern const FIXP_DBL invCount[80];
938
939
LNK_SECTION_INITCODE
940
0
inline void InitInvInt(void) {}
941
942
/**
943
 * \brief Calculate the value of 1/i where i is a integer value. It supports
944
 *        input values from 1 upto (80-1).
945
 * \param intValue Integer input value.
946
 * \param FIXP_DBL representation of 1/intValue
947
 */
948
0
inline FIXP_DBL GetInvInt(int intValue) {
949
0
  return invCount[fMin(fMax(intValue, 0), 80 - 1)];
950
0
}
951
952
#endif /* FIXPOINT_MATH_H */