Changes of Revision 12

fdk-aac.changes Changed
x
 
1
@@ -1,4 +1,12 @@
2
 -------------------------------------------------------------------
3
+Sun Jul 25 17:02:42 UTC 2021 - Bjørn Lie <zaitor@opensuse.org>
4
+
5
+- Update to version 2.0.2:
6
+  + This version adds files for building with CMake in addition to
7
+    autotools, and contains a small number of upstream fixes and
8
+    local fuzzing fixes.
9
+
10
+-------------------------------------------------------------------
11
 Tue Mar 24 17:47:21 UTC 2020 - Bjørn Lie <zaitor@opensuse.org>
12
 
13
 - Update to version 2.0.1:
14
fdk-aac.spec Changed
10
 
1
@@ -18,7 +18,7 @@
2
 
3
 %define _sover  2
4
 Name:           fdk-aac
5
-Version:        2.0.1
6
+Version:        2.0.2
7
 Release:        0
8
 Summary:        A standalone library of the Fraunhofer FDK AAC code from Android
9
 License:        NonFree
10
fdk-aac-2.0.1.tar.gz/Makefile.vc Deleted
201
 
1
@@ -1,321 +0,0 @@
2
-#
3
-# Options:
4
-# prefix=\path\to\install
5
-#
6
-# Compiling:  nmake -f Makefile.vc
7
-# Installing: nmake -f Makefile.vc prefix=\path\to\x install
8
-#
9
-
10
-# Linker and librarian commands
11
-LD = link
12
-AR = lib
13
-
14
-!IFDEF HOME
15
-# In case we are using a cross compiler shell.
16
-MKDIR_FLAGS = -p
17
-!ENDIF
18
-
19
-AM_CPPFLAGS = \
20
-    -Iwin32 \
21
-    -IlibAACdec/include \
22
-    -IlibAACenc/include \
23
-    -IlibArithCoding/include \
24
-    -IlibDRCdec/include \
25
-    -IlibSACdec/include \
26
-    -IlibSACenc/include \
27
-    -IlibSBRdec/include \
28
-    -IlibSBRenc/include \
29
-    -IlibMpegTPDec/include \
30
-    -IlibMpegTPEnc/include \
31
-    -IlibSYS/include \
32
-    -IlibFDK/include \
33
-    -IlibPCMutils/include
34
-
35
-AACDEC_SRC = \
36
-    libAACdec/src/FDK_delay.cpp \
37
-    libAACdec/src/aac_ram.cpp \
38
-    libAACdec/src/aac_rom.cpp \
39
-    libAACdec/src/aacdec_drc.cpp \
40
-    libAACdec/src/aacdec_hcr.cpp \
41
-    libAACdec/src/aacdec_hcr_bit.cpp \
42
-    libAACdec/src/aacdec_hcrs.cpp \
43
-    libAACdec/src/aacdec_pns.cpp \
44
-    libAACdec/src/aacdec_tns.cpp \
45
-    libAACdec/src/aacdecoder.cpp \
46
-    libAACdec/src/aacdecoder_lib.cpp \
47
-    libAACdec/src/block.cpp \
48
-    libAACdec/src/channel.cpp \
49
-    libAACdec/src/channelinfo.cpp \
50
-    libAACdec/src/conceal.cpp \
51
-    libAACdec/src/ldfiltbank.cpp \
52
-    libAACdec/src/pulsedata.cpp \
53
-    libAACdec/src/rvlc.cpp \
54
-    libAACdec/src/rvlcbit.cpp \
55
-    libAACdec/src/rvlcconceal.cpp \
56
-    libAACdec/src/stereo.cpp \
57
-    libAACdec/src/usacdec_ace_d4t64.cpp \
58
-    libAACdec/src/usacdec_ace_ltp.cpp \
59
-    libAACdec/src/usacdec_acelp.cpp \
60
-    libAACdec/src/usacdec_fac.cpp \
61
-    libAACdec/src/usacdec_lpc.cpp \
62
-    libAACdec/src/usacdec_lpd.cpp \
63
-    libAACdec/src/usacdec_rom.cpp
64
-
65
-AACENC_SRC = \
66
-    libAACenc/src/aacEnc_ram.cpp \
67
-    libAACenc/src/aacEnc_rom.cpp \
68
-    libAACenc/src/aacenc.cpp \
69
-    libAACenc/src/aacenc_lib.cpp \
70
-    libAACenc/src/aacenc_pns.cpp \
71
-    libAACenc/src/aacenc_tns.cpp \
72
-    libAACenc/src/adj_thr.cpp \
73
-    libAACenc/src/band_nrg.cpp \
74
-    libAACenc/src/bandwidth.cpp \
75
-    libAACenc/src/bit_cnt.cpp \
76
-    libAACenc/src/bitenc.cpp \
77
-    libAACenc/src/block_switch.cpp \
78
-    libAACenc/src/channel_map.cpp \
79
-    libAACenc/src/chaosmeasure.cpp \
80
-    libAACenc/src/dyn_bits.cpp \
81
-    libAACenc/src/grp_data.cpp \
82
-    libAACenc/src/intensity.cpp \
83
-    libAACenc/src/line_pe.cpp \
84
-    libAACenc/src/metadata_compressor.cpp \
85
-    libAACenc/src/metadata_main.cpp \
86
-    libAACenc/src/mps_main.cpp \
87
-    libAACenc/src/ms_stereo.cpp \
88
-    libAACenc/src/noisedet.cpp \
89
-    libAACenc/src/pnsparam.cpp \
90
-    libAACenc/src/pre_echo_control.cpp \
91
-    libAACenc/src/psy_configuration.cpp \
92
-    libAACenc/src/psy_main.cpp \
93
-    libAACenc/src/qc_main.cpp \
94
-    libAACenc/src/quantize.cpp \
95
-    libAACenc/src/sf_estim.cpp \
96
-    libAACenc/src/spreading.cpp \
97
-    libAACenc/src/tonality.cpp \
98
-    libAACenc/src/transform.cpp
99
-
100
-ARITHCODING_SRC = \
101
-    libArithCoding/src/ac_arith_coder.cpp
102
-
103
-DRCDEC_SRC = \
104
-    libDRCdec/src/FDK_drcDecLib.cpp \
105
-    libDRCdec/src/drcDec_gainDecoder.cpp \
106
-    libDRCdec/src/drcDec_reader.cpp \
107
-    libDRCdec/src/drcDec_rom.cpp \
108
-    libDRCdec/src/drcDec_selectionProcess.cpp \
109
-    libDRCdec/src/drcDec_tools.cpp \
110
-    libDRCdec/src/drcGainDec_init.cpp \
111
-    libDRCdec/src/drcGainDec_preprocess.cpp \
112
-    libDRCdec/src/drcGainDec_process.cpp
113
-
114
-FDK_SRC = \
115
-    libFDK/src/FDK_bitbuffer.cpp \
116
-    libFDK/src/FDK_core.cpp \
117
-    libFDK/src/FDK_crc.cpp \
118
-    libFDK/src/FDK_decorrelate.cpp \
119
-    libFDK/src/FDK_hybrid.cpp \
120
-    libFDK/src/FDK_lpc.cpp \
121
-    libFDK/src/FDK_matrixCalloc.cpp \
122
-    libFDK/src/FDK_qmf_domain.cpp \
123
-    libFDK/src/FDK_tools_rom.cpp \
124
-    libFDK/src/FDK_trigFcts.cpp \
125
-    libFDK/src/autocorr2nd.cpp \
126
-    libFDK/src/dct.cpp \
127
-    libFDK/src/fft.cpp \
128
-    libFDK/src/fft_rad2.cpp \
129
-    libFDK/src/fixpoint_math.cpp \
130
-    libFDK/src/huff_nodes.cpp \
131
-    libFDK/src/mdct.cpp \
132
-    libFDK/src/nlc_dec.cpp \
133
-    libFDK/src/qmf.cpp \
134
-    libFDK/src/scale.cpp
135
-
136
-MPEGTPDEC_SRC = \
137
-    libMpegTPDec/src/tpdec_adif.cpp \
138
-    libMpegTPDec/src/tpdec_adts.cpp \
139
-    libMpegTPDec/src/tpdec_asc.cpp \
140
-    libMpegTPDec/src/tpdec_drm.cpp \
141
-    libMpegTPDec/src/tpdec_latm.cpp \
142
-    libMpegTPDec/src/tpdec_lib.cpp
143
-
144
-MPEGTPENC_SRC = \
145
-    libMpegTPEnc/src/tpenc_adif.cpp \
146
-    libMpegTPEnc/src/tpenc_adts.cpp \
147
-    libMpegTPEnc/src/tpenc_asc.cpp \
148
-    libMpegTPEnc/src/tpenc_latm.cpp \
149
-    libMpegTPEnc/src/tpenc_lib.cpp
150
-
151
-PCMUTILS_SRC = \
152
-    libPCMutils/src/limiter.cpp \
153
-    libPCMutils/src/pcm_utils.cpp \
154
-    libPCMutils/src/pcmdmx_lib.cpp
155
-
156
-SACDEC_SRC = \
157
-    libSACdec/src/sac_bitdec.cpp \
158
-    libSACdec/src/sac_calcM1andM2.cpp \
159
-    libSACdec/src/sac_dec.cpp \
160
-    libSACdec/src/sac_dec_conceal.cpp \
161
-    libSACdec/src/sac_dec_lib.cpp \
162
-    libSACdec/src/sac_process.cpp \
163
-    libSACdec/src/sac_qmf.cpp \
164
-    libSACdec/src/sac_reshapeBBEnv.cpp \
165
-    libSACdec/src/sac_rom.cpp \
166
-    libSACdec/src/sac_smoothing.cpp \
167
-    libSACdec/src/sac_stp.cpp \
168
-    libSACdec/src/sac_tsd.cpp
169
-
170
-SACENC_SRC = \
171
-    libSACenc/src/sacenc_bitstream.cpp \
172
-    libSACenc/src/sacenc_delay.cpp \
173
-    libSACenc/src/sacenc_dmx_tdom_enh.cpp \
174
-    libSACenc/src/sacenc_filter.cpp \
175
-    libSACenc/src/sacenc_framewindowing.cpp \
176
-    libSACenc/src/sacenc_huff_tab.cpp \
177
-    libSACenc/src/sacenc_lib.cpp \
178
-    libSACenc/src/sacenc_nlc_enc.cpp \
179
-    libSACenc/src/sacenc_onsetdetect.cpp \
180
-    libSACenc/src/sacenc_paramextract.cpp \
181
-    libSACenc/src/sacenc_staticgain.cpp \
182
-    libSACenc/src/sacenc_tree.cpp \
183
-    libSACenc/src/sacenc_vectorfunctions.cpp
184
-
185
-SBRDEC_SRC = \
186
-    libSBRdec/src/HFgen_preFlat.cpp \
187
-    libSBRdec/src/env_calc.cpp \
188
-    libSBRdec/src/env_dec.cpp \
189
-    libSBRdec/src/env_extr.cpp \
190
-    libSBRdec/src/hbe.cpp \
191
-    libSBRdec/src/huff_dec.cpp \
192
-    libSBRdec/src/lpp_tran.cpp \
193
-    libSBRdec/src/psbitdec.cpp \
194
-    libSBRdec/src/psdec.cpp \
195
-    libSBRdec/src/psdec_drm.cpp \
196
-    libSBRdec/src/psdecrom_drm.cpp \
197
-    libSBRdec/src/pvc_dec.cpp \
198
-    libSBRdec/src/sbr_crc.cpp \
199
-    libSBRdec/src/sbr_deb.cpp \
200
-    libSBRdec/src/sbr_dec.cpp \
201
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_crc.cpp Deleted
194
 
1
@@ -1,192 +0,0 @@
2
-/* -----------------------------------------------------------------------------
3
-Software License for The Fraunhofer FDK AAC Codec Library for Android
4
-
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
-Forschung e.V. All rights reserved.
7
-
8
- 1.    INTRODUCTION
9
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
10
-that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
11
-scheme for digital audio. This FDK AAC Codec software is intended to be used on
12
-a wide variety of Android devices.
13
-
14
-AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
15
-general perceptual audio codecs. AAC-ELD is considered the best-performing
16
-full-bandwidth communications codec by independent studies and is widely
17
-deployed. AAC has been standardized by ISO and IEC as part of the MPEG
18
-specifications.
19
-
20
-Patent licenses for necessary patent claims for the FDK AAC Codec (including
21
-those of Fraunhofer) may be obtained through Via Licensing
22
-(www.vialicensing.com) or through the respective patent owners individually for
23
-the purpose of encoding or decoding bit streams in products that are compliant
24
-with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
25
-Android devices already license these patent claims through Via Licensing or
26
-directly from the patent owners, and therefore FDK AAC Codec software may
27
-already be covered under those patent licenses when it is used for those
28
-licensed purposes only.
29
-
30
-Commercially-licensed AAC software libraries, including floating-point versions
31
-with enhanced sound quality, are also available from Fraunhofer. Users are
32
-encouraged to check the Fraunhofer website for additional applications
33
-information and documentation.
34
-
35
-2.    COPYRIGHT LICENSE
36
-
37
-Redistribution and use in source and binary forms, with or without modification,
38
-are permitted without payment of copyright license fees provided that you
39
-satisfy the following conditions:
40
-
41
-You must retain the complete text of this software license in redistributions of
42
-the FDK AAC Codec or your modifications thereto in source code form.
43
-
44
-You must retain the complete text of this software license in the documentation
45
-and/or other materials provided with redistributions of the FDK AAC Codec or
46
-your modifications thereto in binary form. You must make available free of
47
-charge copies of the complete source code of the FDK AAC Codec and your
48
-modifications thereto to recipients of copies in binary form.
49
-
50
-The name of Fraunhofer may not be used to endorse or promote products derived
51
-from this library without prior written permission.
52
-
53
-You may not charge copyright license fees for anyone to use, copy or distribute
54
-the FDK AAC Codec software or your modifications thereto.
55
-
56
-Your modified versions of the FDK AAC Codec must carry prominent notices stating
57
-that you changed the software and the date of any change. For modified versions
58
-of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
59
-must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
60
-AAC Codec Library for Android."
61
-
62
-3.    NO PATENT LICENSE
63
-
64
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
65
-limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
66
-Fraunhofer provides no warranty of patent non-infringement with respect to this
67
-software.
68
-
69
-You may use this FDK AAC Codec software or modifications thereto only for
70
-purposes that are authorized by appropriate patent licenses.
71
-
72
-4.    DISCLAIMER
73
-
74
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
75
-holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
76
-including but not limited to the implied warranties of merchantability and
77
-fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
78
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
79
-or consequential damages, including but not limited to procurement of substitute
80
-goods or services; loss of use, data, or profits, or business interruption,
81
-however caused and on any theory of liability, whether in contract, strict
82
-liability, or tort (including negligence), arising in any way out of the use of
83
-this software, even if advised of the possibility of such damage.
84
-
85
-5.    CONTACT INFORMATION
86
-
87
-Fraunhofer Institute for Integrated Circuits IIS
88
-Attention: Audio and Multimedia Departments - FDK AAC LL
89
-Am Wolfsmantel 33
90
-91058 Erlangen, Germany
91
-
92
-www.iis.fraunhofer.de/amm
93
-amm-info@iis.fraunhofer.de
94
------------------------------------------------------------------------------ */
95
-
96
-/**************************** SBR decoder library ******************************
97
-
98
-   Author(s):
99
-
100
-   Description:
101
-
102
-*******************************************************************************/
103
-
104
-/*!
105
-  \file
106
-  \brief  CRC check coutines
107
-*/
108
-
109
-#include "sbr_crc.h"
110
-
111
-#include "FDK_bitstream.h"
112
-#include "transcendent.h"
113
-
114
-#define MAXCRCSTEP 16
115
-#define MAXCRCSTEP_LD 4
116
-
117
-/*!
118
-  \brief     crc calculation
119
-*/
120
-static ULONG calcCRC(HANDLE_CRC hCrcBuf, ULONG bValue, int nBits) {
121
-  int i;
122
-  ULONG bMask = (1UL << (nBits - 1));
123
-
124
-  for (i = 0; i < nBits; i++, bMask >>= 1) {
125
-    USHORT flag = (hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0;
126
-    USHORT flag1 = (bMask & bValue) ? 1 : 0;
127
-
128
-    flag ^= flag1;
129
-    hCrcBuf->crcState <<= 1;
130
-    if (flag) hCrcBuf->crcState ^= hCrcBuf->crcPoly;
131
-  }
132
-
133
-  return (hCrcBuf->crcState);
134
-}
135
-
136
-/*!
137
-  \brief     crc
138
-*/
139
-static int getCrc(HANDLE_FDK_BITSTREAM hBs, ULONG NrBits) {
140
-  int i;
141
-  CRC_BUFFER CrcBuf;
142
-
143
-  CrcBuf.crcState = SBR_CRC_START;
144
-  CrcBuf.crcPoly = SBR_CRC_POLY;
145
-  CrcBuf.crcMask = SBR_CRC_MASK;
146
-
147
-  int CrcStep = NrBits >> MAXCRCSTEP_LD;
148
-
149
-  int CrcNrBitsRest = (NrBits - CrcStep * MAXCRCSTEP);
150
-  ULONG bValue;
151
-
152
-  for (i = 0; i < CrcStep; i++) {
153
-    bValue = FDKreadBits(hBs, MAXCRCSTEP);
154
-    calcCRC(&CrcBuf, bValue, MAXCRCSTEP);
155
-  }
156
-
157
-  bValue = FDKreadBits(hBs, CrcNrBitsRest);
158
-  calcCRC(&CrcBuf, bValue, CrcNrBitsRest);
159
-
160
-  return (CrcBuf.crcState & SBR_CRC_RANGE);
161
-}
162
-
163
-/*!
164
-  \brief   crc interface
165
-  \return  1: CRC OK, 0: CRC check failure
166
-*/
167
-int SbrCrcCheck(HANDLE_FDK_BITSTREAM hBs, /*!< handle to bit-buffer  */
168
-                LONG NrBits)              /*!< max. CRC length       */
169
-{
170
-  int crcResult = 1;
171
-  ULONG NrCrcBits;
172
-  ULONG crcCheckResult;
173
-  LONG NrBitsAvailable;
174
-  ULONG crcCheckSum;
175
-
176
-  crcCheckSum = FDKreadBits(hBs, 10);
177
-
178
-  NrBitsAvailable = FDKgetValidBits(hBs);
179
-  if (NrBitsAvailable <= 0) {
180
-    return 0;
181
-  }
182
-
183
-  NrCrcBits = fixMin((INT)NrBits, (INT)NrBitsAvailable);
184
-
185
-  crcCheckResult = getCrc(hBs, NrCrcBits);
186
-  FDKpushBack(hBs, (NrBitsAvailable - FDKgetValidBits(hBs)));
187
-
188
-  if (crcCheckResult != crcCheckSum) {
189
-    crcResult = 0;
190
-  }
191
-
192
-  return (crcResult);
193
-}
194
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_crc.h Deleted
140
 
1
@@ -1,138 +0,0 @@
2
-/* -----------------------------------------------------------------------------
3
-Software License for The Fraunhofer FDK AAC Codec Library for Android
4
-
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
-Forschung e.V. All rights reserved.
7
-
8
- 1.    INTRODUCTION
9
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
10
-that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
11
-scheme for digital audio. This FDK AAC Codec software is intended to be used on
12
-a wide variety of Android devices.
13
-
14
-AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
15
-general perceptual audio codecs. AAC-ELD is considered the best-performing
16
-full-bandwidth communications codec by independent studies and is widely
17
-deployed. AAC has been standardized by ISO and IEC as part of the MPEG
18
-specifications.
19
-
20
-Patent licenses for necessary patent claims for the FDK AAC Codec (including
21
-those of Fraunhofer) may be obtained through Via Licensing
22
-(www.vialicensing.com) or through the respective patent owners individually for
23
-the purpose of encoding or decoding bit streams in products that are compliant
24
-with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
25
-Android devices already license these patent claims through Via Licensing or
26
-directly from the patent owners, and therefore FDK AAC Codec software may
27
-already be covered under those patent licenses when it is used for those
28
-licensed purposes only.
29
-
30
-Commercially-licensed AAC software libraries, including floating-point versions
31
-with enhanced sound quality, are also available from Fraunhofer. Users are
32
-encouraged to check the Fraunhofer website for additional applications
33
-information and documentation.
34
-
35
-2.    COPYRIGHT LICENSE
36
-
37
-Redistribution and use in source and binary forms, with or without modification,
38
-are permitted without payment of copyright license fees provided that you
39
-satisfy the following conditions:
40
-
41
-You must retain the complete text of this software license in redistributions of
42
-the FDK AAC Codec or your modifications thereto in source code form.
43
-
44
-You must retain the complete text of this software license in the documentation
45
-and/or other materials provided with redistributions of the FDK AAC Codec or
46
-your modifications thereto in binary form. You must make available free of
47
-charge copies of the complete source code of the FDK AAC Codec and your
48
-modifications thereto to recipients of copies in binary form.
49
-
50
-The name of Fraunhofer may not be used to endorse or promote products derived
51
-from this library without prior written permission.
52
-
53
-You may not charge copyright license fees for anyone to use, copy or distribute
54
-the FDK AAC Codec software or your modifications thereto.
55
-
56
-Your modified versions of the FDK AAC Codec must carry prominent notices stating
57
-that you changed the software and the date of any change. For modified versions
58
-of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
59
-must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
60
-AAC Codec Library for Android."
61
-
62
-3.    NO PATENT LICENSE
63
-
64
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
65
-limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
66
-Fraunhofer provides no warranty of patent non-infringement with respect to this
67
-software.
68
-
69
-You may use this FDK AAC Codec software or modifications thereto only for
70
-purposes that are authorized by appropriate patent licenses.
71
-
72
-4.    DISCLAIMER
73
-
74
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
75
-holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
76
-including but not limited to the implied warranties of merchantability and
77
-fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
78
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
79
-or consequential damages, including but not limited to procurement of substitute
80
-goods or services; loss of use, data, or profits, or business interruption,
81
-however caused and on any theory of liability, whether in contract, strict
82
-liability, or tort (including negligence), arising in any way out of the use of
83
-this software, even if advised of the possibility of such damage.
84
-
85
-5.    CONTACT INFORMATION
86
-
87
-Fraunhofer Institute for Integrated Circuits IIS
88
-Attention: Audio and Multimedia Departments - FDK AAC LL
89
-Am Wolfsmantel 33
90
-91058 Erlangen, Germany
91
-
92
-www.iis.fraunhofer.de/amm
93
-amm-info@iis.fraunhofer.de
94
------------------------------------------------------------------------------ */
95
-
96
-/**************************** SBR decoder library ******************************
97
-
98
-   Author(s):
99
-
100
-   Description:
101
-
102
-*******************************************************************************/
103
-
104
-/*!
105
-  \file
106
-  \brief  CRC checking routines
107
-*/
108
-#ifndef SBR_CRC_H
109
-#define SBR_CRC_H
110
-
111
-#include "sbrdecoder.h"
112
-
113
-#include "FDK_bitstream.h"
114
-
115
-/* some useful crc polynoms:
116
-
117
-crc5: x^5+x^4+x^2+x^1+1
118
-crc6: x^6+x^5+x^3+x^2+x+1
119
-crc7: x^7+x^6+x^2+1
120
-crc8: x^8+x^2+x+x+1
121
-*/
122
-
123
-/* default SBR CRC */ /* G(x) = x^10 + x^9 + x^5 + x^4 + x + 1 */
124
-#define SBR_CRC_POLY 0x0233
125
-#define SBR_CRC_MASK 0x0200
126
-#define SBR_CRC_START 0x0000
127
-#define SBR_CRC_RANGE 0x03FF
128
-
129
-typedef struct {
130
-  USHORT crcState;
131
-  USHORT crcMask;
132
-  USHORT crcPoly;
133
-} CRC_BUFFER;
134
-
135
-typedef CRC_BUFFER *HANDLE_CRC;
136
-
137
-int SbrCrcCheck(HANDLE_FDK_BITSTREAM hBitBuf, LONG NrCrcBits);
138
-
139
-#endif
140
fdk-aac-2.0.1.tar.gz/.gitignore -> fdk-aac-2.0.2.tar.gz/.gitignore Changed
20
 
1
@@ -27,3 +27,18 @@
2
 stamp-h1
3
 aac-enc
4
 compile
5
+
6
+CMakeCache.txt
7
+CMakeFiles
8
+CMakeScripts
9
+Testing
10
+cmake_install.cmake
11
+install_manifest.txt
12
+compile_commands.json
13
+CTestTestfile.cmake
14
+CMakeSettings.json
15
+
16
+*[Bb]uild*/
17
+
18
+.vs/
19
+.vscode/
20
fdk-aac-2.0.1.tar.gz/Android.bp -> fdk-aac-2.0.2.tar.gz/Android.bp Changed
78
 
1
@@ -1,6 +1,40 @@
2
+// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS.  PLEASE
3
+//     CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
4
+//     DEPENDING ON IT IN YOUR PROJECT. ***
5
+package {
6
+    default_applicable_licenses: ["external_aac_license"],
7
+}
8
+
9
+// Added automatically by a large-scale-change that took the approach of
10
+// 'apply every license found to every target'. While this makes sure we respect
11
+// every license restriction, it may not be entirely correct.
12
+//
13
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
14
+//
15
+// Please consider splitting the single license below into multiple licenses,
16
+// taking care not to lose any license_kind information, and overriding the
17
+// default license using the 'licenses: [...]' property on targets as needed.
18
+//
19
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
20
+// to attach the license to, and including a comment whether the files may be
21
+// used in the current project.
22
+// See: http://go/android-license-faq
23
+license {
24
+    name: "external_aac_license",
25
+    visibility: [":__subpackages__"],
26
+    license_kinds: [
27
+        "SPDX-license-identifier-Apache-2.0",
28
+        "legacy_by_exception_only", // by exception only
29
+    ],
30
+    license_text: [
31
+        "NOTICE",
32
+    ],
33
+}
34
+
35
 cc_library_static {
36
     name: "libFraunhoferAAC",
37
     vendor_available: true,
38
+    host_supported: true,
39
     srcs: [
40
         "libAACdec/src/*.cpp",
41
         "libAACenc/src/*.cpp",
42
@@ -23,12 +57,13 @@
43
         "-Wuninitialized",
44
         "-Wno-self-assign",
45
         "-Wno-implicit-fallthrough",
46
+        "-DSUPPRESS_BUILD_DATE_INFO",
47
     ],
48
     sanitize: {
49
-        misc_undefined:[
50
-           "unsigned-integer-overflow",
51
-           "signed-integer-overflow",
52
-           "bounds",
53
+        misc_undefined: [
54
+            "unsigned-integer-overflow",
55
+            "signed-integer-overflow",
56
+            "bounds",
57
         ],
58
         cfi: true,
59
     },
60
@@ -50,4 +85,17 @@
61
         "libSACdec/include",
62
         "libSACenc/include",
63
     ],
64
+
65
+    target: {
66
+        darwin: {
67
+            enabled: false,
68
+        },
69
+    },
70
+
71
+    apex_available: [
72
+        "//apex_available:platform",
73
+        "com.android.bluetooth.updatable",
74
+        "com.android.media.swcodec",
75
+    ],
76
+    min_sdk_version: "29",
77
 }
78
fdk-aac-2.0.2.tar.gz/CMakeLists.txt Added
201
 
1
@@ -0,0 +1,588 @@
2
+# # CMake project for fdk-aac
3
+#
4
+# ## Basic usage
5
+#
6
+# 1. Download and install CMake >= 3.10 (CMake >= 3.15 is recommended)
7
+# 2. Clone fdk-aac repository
8
+# 3. In fdk-aac directory create and go to `build` subdirectory:
9
+#
10
+#    mkdir build
11
+#    cd build
12
+#
13
+# 4. Run cmake to configure project with desired build type (Release|Debug):
14
+#
15
+#    cmake .. -DCMAKE_BUILD_TYPE=Release
16
+#
17
+#    Note CMake configuration without CMAKE_BUILD_TYPE option will not set build
18
+#    type to some default and it is most likely is not what you want.
19
+#
20
+#    If you want to build static (default is shared library), add BUILD_SHARED_LIBS=OFF option:
21
+#
22
+#    #    cmake .. -DBUILD_SHARED_LIBS=OFF
23
+#
24
+#    You can combine options as well:
25
+#
26
+#    cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
27
+#
28
+# 5. Run cmake to build project:
29
+#
30
+#    cmake --build . -c Release
31
+
32
+cmake_minimum_required(VERSION 3.5.1)
33
+
34
+# Policies
35
+
36
+## Enables CMAKE_MSVC_RUNTIME_LIBRARY option support for CMake >= 3.15
37
+## if you want to use a MSVC multi-threaded statically-linked runtime library
38
+## If you enable it, CMake will build fdk-acc.dll without external dependencies.
39
+##
40
+## Example usage:
41
+##
42
+## cmake .. -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>
43
+if(POLICY CMP0091)
44
+  cmake_policy(SET CMP0091 NEW)
45
+endif()
46
+
47
+project(fdk-aac VERSION 2.0.2)
48
+
49
+# Includes
50
+
51
+include(CheckFunctionExists)
52
+include(CheckLibraryExists)
53
+include(GNUInstallDirs)
54
+include(CMakePackageConfigHelpers)
55
+
56
+if(CMAKE_VERSION VERSION_LESS 3.11)
57
+  set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
58
+  set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
59
+  set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
60
+endif()
61
+include(CPack)
62
+
63
+# Options
64
+
65
+option(BUILD_SHARED_LIBS "Build shared library" ON)
66
+option(BUILD_PROGRAMS "Build aac-enc utility" OFF)
67
+option(FDK_AAC_INSTALL_CMAKE_CONFIG_MODULE "Install CMake package configuration file" ON)
68
+option(FDK_AAC_INSTALL_PKGCONFIG_MODULE "Install pkg-config .pc file" ON)
69
+
70
+# Checks
71
+
72
+## Check if math functions are in separate library (Most of Linux distros, maybe some other OSes)
73
+check_function_exists(sin HAVE_DEFAULT_MATH)
74
+if(NOT HAVE_DEFAULT_MATH)
75
+  check_library_exists(m sin "" HAVE_LIBM)
76
+endif()
77
+
78
+# Library
79
+
80
+## Sources
81
+
82
+set(AACDEC_SRC
83
+  libAACdec/src/FDK_delay.cpp
84
+  libAACdec/src/aac_ram.cpp
85
+  libAACdec/src/aac_rom.cpp
86
+  libAACdec/src/aacdec_drc.cpp
87
+  libAACdec/src/aacdec_hcr.cpp
88
+  libAACdec/src/aacdec_hcr_bit.cpp
89
+  libAACdec/src/aacdec_hcrs.cpp
90
+  libAACdec/src/aacdec_pns.cpp
91
+  libAACdec/src/aacdec_tns.cpp
92
+  libAACdec/src/aacdecoder.cpp
93
+  libAACdec/src/aacdecoder_lib.cpp
94
+  libAACdec/src/block.cpp
95
+  libAACdec/src/channel.cpp
96
+  libAACdec/src/channelinfo.cpp
97
+  libAACdec/src/conceal.cpp
98
+  libAACdec/src/ldfiltbank.cpp
99
+  libAACdec/src/pulsedata.cpp
100
+  libAACdec/src/rvlc.cpp
101
+  libAACdec/src/rvlcbit.cpp
102
+  libAACdec/src/rvlcconceal.cpp
103
+  libAACdec/src/stereo.cpp
104
+  libAACdec/src/usacdec_ace_d4t64.cpp
105
+  libAACdec/src/usacdec_ace_ltp.cpp
106
+  libAACdec/src/usacdec_acelp.cpp
107
+  libAACdec/src/usacdec_fac.cpp
108
+  libAACdec/src/usacdec_lpc.cpp
109
+  libAACdec/src/usacdec_lpd.cpp
110
+  libAACdec/src/usacdec_rom.cpp
111
+  libAACdec/src/aac_ram.h
112
+  libAACdec/src/aac_rom.h
113
+  libAACdec/src/aacdec_drc.h
114
+  libAACdec/src/aacdec_drc_types.h
115
+  libAACdec/src/aacdec_hcr.h
116
+  libAACdec/src/aacdec_hcr_bit.h
117
+  libAACdec/src/aacdec_hcr_types.h
118
+  libAACdec/src/aacdec_hcrs.h
119
+  libAACdec/src/aacdec_pns.h
120
+  libAACdec/src/aacdec_tns.h
121
+  libAACdec/src/aacdecoder.h
122
+  libAACdec/src/block.h
123
+  libAACdec/src/channel.h
124
+  libAACdec/src/channelinfo.h
125
+  libAACdec/src/conceal.h
126
+  libAACdec/src/conceal_types.h
127
+  libAACdec/src/FDK_delay.h
128
+  libAACdec/src/ldfiltbank.h
129
+  libAACdec/src/overlapadd.h
130
+  libAACdec/src/pulsedata.h
131
+  libAACdec/src/rvlc.h
132
+  libAACdec/src/rvlc_info.h
133
+  libAACdec/src/rvlcbit.h
134
+  libAACdec/src/rvlcconceal.h
135
+  libAACdec/src/stereo.h
136
+  libAACdec/src/usacdec_ace_d4t64.h
137
+  libAACdec/src/usacdec_ace_ltp.h
138
+  libAACdec/src/usacdec_acelp.h
139
+  libAACdec/src/usacdec_const.h
140
+  libAACdec/src/usacdec_fac.h
141
+  libAACdec/src/usacdec_lpc.h
142
+  libAACdec/src/usacdec_lpd.h
143
+  libAACdec/src/usacdec_rom.h)
144
+
145
+set(AACENC_SRC
146
+  libAACenc/src/aacEnc_ram.cpp
147
+  libAACenc/src/aacEnc_rom.cpp
148
+  libAACenc/src/aacenc.cpp
149
+  libAACenc/src/aacenc_lib.cpp
150
+  libAACenc/src/aacenc_pns.cpp
151
+  libAACenc/src/aacenc_tns.cpp
152
+  libAACenc/src/adj_thr.cpp
153
+  libAACenc/src/band_nrg.cpp
154
+  libAACenc/src/bandwidth.cpp
155
+  libAACenc/src/bit_cnt.cpp
156
+  libAACenc/src/bitenc.cpp
157
+  libAACenc/src/block_switch.cpp
158
+  libAACenc/src/channel_map.cpp
159
+  libAACenc/src/chaosmeasure.cpp
160
+  libAACenc/src/dyn_bits.cpp
161
+  libAACenc/src/grp_data.cpp
162
+  libAACenc/src/intensity.cpp
163
+  libAACenc/src/line_pe.cpp
164
+  libAACenc/src/metadata_compressor.cpp
165
+  libAACenc/src/metadata_main.cpp
166
+  libAACenc/src/mps_main.cpp
167
+  libAACenc/src/ms_stereo.cpp
168
+  libAACenc/src/noisedet.cpp
169
+  libAACenc/src/pnsparam.cpp
170
+  libAACenc/src/pre_echo_control.cpp
171
+  libAACenc/src/psy_configuration.cpp
172
+  libAACenc/src/psy_main.cpp
173
+  libAACenc/src/qc_main.cpp
174
+  libAACenc/src/quantize.cpp
175
+  libAACenc/src/sf_estim.cpp
176
+  libAACenc/src/spreading.cpp
177
+  libAACenc/src/tonality.cpp
178
+  libAACenc/src/transform.cpp
179
+  libAACenc/src/aacenc.h
180
+  libAACenc/src/aacenc_pns.h
181
+  libAACenc/src/aacEnc_ram.h
182
+  libAACenc/src/aacEnc_rom.h
183
+  libAACenc/src/aacenc_tns.h
184
+  libAACenc/src/adj_thr.h
185
+  libAACenc/src/adj_thr_data.h
186
+  libAACenc/src/band_nrg.h
187
+  libAACenc/src/bandwidth.h
188
+  libAACenc/src/bit_cnt.h
189
+  libAACenc/src/bitenc.h
190
+  libAACenc/src/block_switch.h
191
+  libAACenc/src/channel_map.h
192
+  libAACenc/src/chaosmeasure.h
193
+  libAACenc/src/dyn_bits.h
194
+  libAACenc/src/grp_data.h
195
+  libAACenc/src/intensity.h
196
+  libAACenc/src/interface.h
197
+  libAACenc/src/line_pe.h
198
+  libAACenc/src/metadata_compressor.h
199
+  libAACenc/src/metadata_main.h
200
+  libAACenc/src/mps_main.h
201
fdk-aac-2.0.1.tar.gz/ChangeLog -> fdk-aac-2.0.2.tar.gz/ChangeLog Changed
11
 
1
@@ -1,3 +1,9 @@
2
+2.0.2
3
+ - Minor upstream updates
4
+ - Lots of upstream and local fuzzing fixes
5
+ - Added CMake project files
6
+ - Removed the MSVC specific makefile
7
+
8
 2.0.1
9
  - Minor release with a number of crash/fuzz fixes, primarily for the decoder
10
 
11
fdk-aac-2.0.2.tar.gz/METADATA Added
5
 
1
@@ -0,0 +1,3 @@
2
+third_party {
3
+  license_type: BY_EXCEPTION_ONLY
4
+}
5
fdk-aac-2.0.1.tar.gz/Makefile.am -> fdk-aac-2.0.2.tar.gz/Makefile.am Changed
37
 
1
@@ -210,7 +210,6 @@
2
     libSBRdec/src/psdec_drm.cpp \
3
     libSBRdec/src/psdecrom_drm.cpp \
4
     libSBRdec/src/pvc_dec.cpp \
5
-    libSBRdec/src/sbr_crc.cpp \
6
     libSBRdec/src/sbr_deb.cpp \
7
     libSBRdec/src/sbr_dec.cpp \
8
     libSBRdec/src/sbr_ram.cpp \
9
@@ -254,15 +253,18 @@
10
     $(PCMUTILS_SRC) $(FDK_SRC) $(SYS_SRC)
11
 
12
 EXTRA_DIST = \
13
+    $(top_srcdir)/CMakeLists.txt \
14
     $(top_srcdir)/.clang-format \
15
     $(top_srcdir)/autogen.sh \
16
     $(top_srcdir)/MODULE_LICENSE_FRAUNHOFER \
17
     $(top_srcdir)/NOTICE \
18
     $(top_srcdir)/OWNERS \
19
     $(top_srcdir)/Android.bp \
20
+    $(top_srcdir)/fdk-aac.def \
21
     $(top_srcdir)/fdk-aac.sym \
22
-    $(top_srcdir)/Makefile.vc \
23
+    $(top_srcdir)/fdk-aac-config.cmake.in \
24
     $(top_srcdir)/documentation/*.pdf \
25
+    $(top_srcdir)/fuzzer/* \
26
     $(top_srcdir)/libAACdec/src/*.h \
27
     $(top_srcdir)/libAACdec/src/arm/*.cpp \
28
     $(top_srcdir)/libAACenc/src/*.h \
29
@@ -292,5 +294,7 @@
30
     $(top_srcdir)/libFDK/include/x86/*.h \
31
     $(top_srcdir)/libFDK/src/arm/*.cpp \
32
     $(top_srcdir)/libFDK/src/mips/*.cpp \
33
+    $(top_srcdir)/METADATA \
34
+    $(top_srcdir)/PREUPLOAD.cfg \
35
     $(top_srcdir)/win32/*.h
36
 
37
fdk-aac-2.0.2.tar.gz/PREUPLOAD.cfg Added
4
 
1
@@ -0,0 +1,2 @@
2
+[Hook Scripts]
3
+mainline_hook = ${REPO_ROOT}/frameworks/av/tools/mainline_hook_project.sh
4
fdk-aac-2.0.1.tar.gz/configure.ac -> fdk-aac-2.0.2.tar.gz/configure.ac Changed
19
 
1
@@ -1,7 +1,7 @@
2
 dnl                                               -*- Autoconf -*-
3
 dnl Process this file with autoconf to produce a configure script.
4
 
5
-AC_INIT([fdk-aac], [2.0.1], [http://sourceforge.net/projects/opencore-amr/])
6
+AC_INIT([fdk-aac], [2.0.2], [http://sourceforge.net/projects/opencore-amr/])
7
 AC_CONFIG_AUX_DIR(.)
8
 AC_CONFIG_MACRO_DIR([m4])
9
 AM_INIT_AUTOMAKE([tar-ustar foreign])
10
@@ -26,7 +26,7 @@
11
 dnl soname version to use
12
 dnl goes by ‘current[:revision[:age]]’ with the soname ending up as
13
 dnl current.age.revision
14
-FDK_AAC_VERSION=2:1:0
15
+FDK_AAC_VERSION=2:2:0
16
 
17
 AS_IF([test x$enable_shared = xyes], [LIBS_PRIVATE=$LIBS], [LIBS_PUBLIC=$LIBS])
18
 AC_SUBST(FDK_AAC_VERSION)
19
fdk-aac-2.0.1.tar.gz/documentation/aacDecoder.pdf -> fdk-aac-2.0.2.tar.gz/documentation/aacDecoder.pdf Changed
fdk-aac-2.0.1.tar.gz/documentation/aacEncoder.pdf -> fdk-aac-2.0.2.tar.gz/documentation/aacEncoder.pdf Changed
fdk-aac-2.0.2.tar.gz/fdk-aac-config.cmake.in Added
7
 
1
@@ -0,0 +1,5 @@
2
+@PACKAGE_INIT@
3
+
4
+include(${CMAKE_CURRENT_LIST_DIR}/fdk-aac-targets.cmake)
5
+
6
+check_required_components(FDK-AAC)
7
fdk-aac-2.0.2.tar.gz/fdk-aac.def Added
21
 
1
@@ -0,0 +1,19 @@
2
+EXPORTS
3
+    aacDecoder_AncDataGet
4
+    aacDecoder_AncDataInit
5
+    aacDecoder_Close
6
+    aacDecoder_ConfigRaw
7
+    aacDecoder_DecodeFrame
8
+    aacDecoder_Fill
9
+    aacDecoder_GetFreeBytes
10
+    aacDecoder_GetLibInfo
11
+    aacDecoder_GetStreamInfo
12
+    aacDecoder_Open
13
+    aacDecoder_SetParam
14
+    aacEncClose
15
+    aacEncEncode
16
+    aacEncGetLibInfo
17
+    aacEncInfo
18
+    aacEncOpen
19
+    aacEncoder_GetParam
20
+    aacEncoder_SetParam
21
fdk-aac-2.0.2.tar.gz/fuzzer Added
2
 
1
+(directory)
2
fdk-aac-2.0.2.tar.gz/fuzzer/Android.bp Added
84
 
1
@@ -0,0 +1,82 @@
2
+/******************************************************************************
3
+ *
4
+ * Copyright (C) 2020 The Android Open Source Project
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at:
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ *****************************************************************************
19
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
20
+ */
21
+
22
+package {
23
+    // See: http://go/android-license-faq
24
+    // A large-scale-change added 'default_applicable_licenses' to import
25
+    // all of the 'license_kinds' from "external_aac_license"
26
+    // to get the below license kinds:
27
+    //   SPDX-license-identifier-Apache-2.0
28
+    default_applicable_licenses: ["external_aac_license"],
29
+}
30
+
31
+cc_defaults {
32
+    name: "aac_fuzz_defaults",
33
+    host_supported: true,
34
+
35
+    static_libs: [
36
+        "libFraunhoferAAC",
37
+    ],
38
+
39
+    target: {
40
+        darwin: {
41
+            enabled: false,
42
+        },
43
+    },
44
+
45
+    fuzz_config: {
46
+        cc: [
47
+            "android-media-fuzzing-reports@google.com",
48
+        ],
49
+        componentid: 155276,
50
+    },
51
+}
52
+
53
+cc_fuzz {
54
+    name: "aac_dec_fuzzer",
55
+
56
+    srcs: [
57
+        "aac_dec_fuzzer.cpp",
58
+    ],
59
+
60
+    static_libs: [
61
+        "liblog",
62
+    ],
63
+
64
+    defaults: [
65
+        "aac_fuzz_defaults"
66
+    ],
67
+}
68
+
69
+cc_fuzz {
70
+    name: "aac_enc_fuzzer",
71
+
72
+    srcs: [
73
+        "aac_enc_fuzzer.cpp",
74
+    ],
75
+
76
+    defaults: [
77
+        "aac_fuzz_defaults"
78
+    ],
79
+
80
+    include_dirs: [
81
+        "external/aac/libAACenc/"
82
+    ],
83
+}
84
fdk-aac-2.0.2.tar.gz/fuzzer/README.md Added
152
 
1
@@ -0,0 +1,150 @@
2
+# Fuzzer for libFraunhoferAAC decoder
3
+
4
+## Plugin Design Considerations
5
+The fuzzer plugin for aac decoder is designed based on the understanding of the
6
+codec and tries to achieve the following:
7
+
8
+##### Maximize code coverage
9
+
10
+This fuzzer makes use of the following config parameters:
11
+1. Transport type (parameter name: `TRANSPORT_TYPE`)
12
+
13
+| Parameter| Valid Values| Configured Value|
14
+|------------- |-------------| ----- |
15
+| `TRANSPORT_TYPE` | 0.`TT_UNKNOWN  ` 1.`TT_MP4_RAW ` 2.`TT_MP4_ADIF ` 3.`TT_MP4_ADTS ` 4.`TT_MP4_LATM_MCP1 ` 5.`TT_MP4_LATM_MCP0  ` 6.`TT_MP4_LOAS ` 7.`TT_DRM ` | `TT_MP4_ADIF ` |
16
+
17
+Note: Value of `TRANSPORT_TYPE` could be set to any of these values.
18
+It is set to `TT_MP4_ADIF` in the fuzzer plugin.
19
+
20
+##### Maximize utilization of input data
21
+The plugin feeds the entire input data to the codec using a loop.
22
+ * If the decode operation was successful, the input is advanced by an
23
+   offset calculated using valid bytes.
24
+ * If the decode operation was un-successful, the input is advanced by 1 byte
25
+   till it reaches a valid frame or end of stream.
26
+
27
+This ensures that the plugin tolerates any kind of input (empty, huge,
28
+malformed, etc) and doesnt `exit()` on any input and thereby increasing the
29
+chance of identifying vulnerabilities.
30
+
31
+## Build
32
+
33
+This describes steps to build aac_dec_fuzzer binary.
34
+
35
+## Android
36
+
37
+### Steps to build
38
+Build the fuzzer
39
+```
40
+  $ mm -j$(nproc) aac_dec_fuzzer
41
+```
42
+
43
+### Steps to run
44
+Create a directory CORPUS_DIR and copy some aac files to that folder.
45
+Push this directory to device.
46
+
47
+To run on device
48
+```
49
+  $ adb sync data
50
+  $ adb shell /data/fuzz/arm64/aac_dec_fuzzer/aac_dec_fuzzer CORPUS_DIR
51
+```
52
+To run on host
53
+```
54
+  $ $ANDROID_HOST_OUT/fuzz/x86_64/aac_dec_fuzzer/aac_dec_fuzzer CORPUS_DIR
55
+```
56
+
57
+# Fuzzer for libFraunhoferAAC encoder
58
+
59
+## Plugin Design Considerations
60
+The fuzzer plugin for aac encoder is designed based on the understanding of the
61
+codec and tries to achieve the following:
62
+
63
+##### Maximize code coverage
64
+
65
+The configuration parameters are not hardcoded, but instead selected based on
66
+incoming data. This ensures more code paths are reached by the fuzzer.
67
+
68
+Following arguments are passed to aacEncoder_SetParam to set the respective AACENC_PARAM parameter:
69
+
70
+| AACENC_PARAM param| Valid Values| Configured Value|
71
+|-------------| ----- |----- |
72
+|`AACENC_SBR_MODE` | `-1 ` `0 ` `1 ` `2 ` | Calculated using first byte of data |
73
+|`AACENC_AOT` |`AOT_NONE ` `AOT_NULL_OBJECT ` `AOT_AAC_MAIN ` `AOT_AAC_LC ` `AOT_AAC_SSR ` `AOT_AAC_LTP ` `AOT_SBR ` `AOT_AAC_SCAL ` `AOT_TWIN_VQ ` `AOT_CELP ` `AOT_HVXC ` `AOT_RSVD_10 ` `AOT_RSVD_11 ` `AOT_TTSI ` `AOT_MAIN_SYNTH ` `AOT_WAV_TAB_SYNTH ` `AOT_GEN_MIDI ` `AOT_ALG_SYNTH_AUD_FX ` `AOT_ER_AAC_LC ` `AOT_RSVD_18 ` `AOT_ER_AAC_LTP ` `AOT_ER_AAC_SCAL ` `AOT_ER_TWIN_VQ ` `AOT_ER_BSAC ` `AOT_ER_AAC_LD ` `AOT_ER_CELP ` `AOT_ER_HVXC ` `AOT_ER_HILN ` `AOT_ER_PARA ` `AOT_RSVD_28 ` `AOT_PS ` `AOT_MPEGS ` `AOT_ESCAPE ` `AOT_MP3ONMP4_L1 ` `AOT_MP3ONMP4_L2 ` `AOT_MP3ONMP4_L3 ` `AOT_RSVD_35 ` `AOT_RSVD_36 ` `AOT_AAC_SLS ` `AOT_SLS ` `AOT_ER_AAC_ELD ` `AOT_USAC ` `AOT_SAOC ` `AOT_LD_MPEGS ` `AOT_MP2_AAC_LC ` `AOT_MP2_SBR ` `AOT_DRM_AAC ` `AOT_DRM_SBR ` `AOT_DRM_MPEG_PS ` `AOT_DRM_SURROUND ` `AOT_DRM_USAC `  | Calculated using second byte of data  |
74
+|`AACENC_SAMPLERATE` |  `8000 ` `11025 ` `12000 ` `16000 ` `22050 ` `24000 ` `32000 ` `44100 ` `48000 ` `64000 ` `88200 ` `96000 `| Calculated using third byte of data  |
75
+|`AACENC_BITRATE` | In range `8000 ` to `960000 ` | Calculated using fourth, fifth and sixth byte of data  |
76
+|`AACENC_CHANNELMODE` | `MODE_1 ` `MODE_2 ` `MODE_1_2 ` `MODE_1_2_1 ` `MODE_1_2_2 ` `MODE_1_2_2_1 ` `MODE_1_2_2_2_1 ` `MODE_6_1 `  `MODE_7_1_BACK ` `MODE_7_1_TOP_FRONT ` `MODE_7_1_REAR_SURROUND ` `MODE_7_1_FRONT_CENTER ` `MODE_212 ` | Calculated using seventh byte of data |
77
+|`AACENC_TRANSMUX` | `TT_MP4_RAW ` `TT_MP4_ADIF ` `TT_MP4_ADTS ` `TT_MP4_LATM_MCP1 ` `TT_MP4_LATM_MCP0 ` `TT_MP4_LOAS ` `TT_DRM `  | Calculated using eight byte of data  |`AACENC_SBR_RATIO` |`-1 ` `0 ` `1 ` `2 ` | Calculated using ninth byte of data |
78
+|`AACENC_BITRATEMODE` |`AACENC_BR_MODE_INVALID ` `AACENC_BR_MODE_CBR ` `AACENC_BR_MODE_VBR_1 ` `AACENC_BR_MODE_VBR_2 ` `AACENC_BR_MODE_VBR_3 ` `AACENC_BR_MODE_VBR_4 ` `AACENC_BR_MODE_VBR_5 ` `AACENC_BR_MODE_FF ` `AACENC_BR_MODE_SFR `  | Calculated using thirty-fourth byte of data |
79
+|`AACENC_GRANULE_LENGTH` |`120 ` `128 ` `240 ` `256 ` `480 ` `512 ` `1024 ` | Calculated using thirty-fifth byte of data |
80
+|`AACENC_CHANNELORDER` |`CH_ORDER_MPEG ` `CH_ORDER_WAV ` | Calculated using thirty-sixth byte of data |
81
+|`AACENC_AFTERBURNER` |`0 ` `1 ` | Calculated using thirty-seventh byte of data |
82
+|`AACENC_BANDWIDTH` |`0 ` `1`  | Calculated using thirty-eigth byte of data |
83
+|` AACENC_IDX_PEAK_BITRATE` | In range `8000 ` to `960000 ` | Calculated using thirty-ninth byte of data |
84
+|` AACENC_HEADER_PERIOD` |In range `0 ` to `255 ` | Calculated using fortieth byte of data |
85
+|` AACENC_SIGNALING_MODE` |`-1 ` `0 ` `1 ` `2 ` `3 `  | Calculated using forty-first byte of data |
86
+|` AACENC_TPSUBFRAMES` |In range `0 ` to `255 ` | Calculated using forty-second byte of data |
87
+|` AACENC_AUDIOMUXVER` |`-1 ` `0 ` `1 ` `2 ` | Calculated using forty-third byte of data |
88
+|` AACENC_PROTECTION` |`0 ` `1 ` | Calculated using forty-fourth of data |
89
+|`AACENC_ANCILLARY_BITRATE` |In range `0 ` to `960000 `| Calculated using forty-fifth byte of data |
90
+|`AACENC_METADATA_MODE ` |`0 ` `1 ` `2 ` `3 ` | Calculated using forty-sixth byte of data |
91
+
92
+Following values are configured to set up the meta data represented by the class variable `mMetaData ` :
93
+
94
+| Variable name| Possible Values| Configured Value|
95
+|------------- | ----- |----- |
96
+| `drc_profile`   | `AACENC_METADATA_DRC_NONE ` `AACENC_METADATA_DRC_FILMSTANDARD ` `AACENC_METADATA_DRC_FILMLIGHT ` `AACENC_METADATA_DRC_MUSICSTANDARD ` `AACENC_METADATA_DRC_MUSICLIGHT ` `AACENC_METADATA_DRC_SPEECH ` `AACENC_METADATA_DRC_NOT_PRESENT `  | Calculated using tenth byte of data |
97
+| `comp_profile`   | `AACENC_METADATA_DRC_NONE ` `AACENC_METADATA_DRC_FILMSTANDARD ` `AACENC_METADATA_DRC_FILMLIGHT ` `AACENC_METADATA_DRC_MUSICSTANDARD ` `AACENC_METADATA_DRC_MUSICLIGHT ` `AACENC_METADATA_DRC_SPEECH ` `AACENC_METADATA_DRC_NOT_PRESENT `  | Calculated using eleventh byte of data |
98
+| `drc_TargetRefLevel`   | In range `0 ` to `255 `  | Calculated using twelfth byte of data |
99
+| `comp_TargetRefLevel`   | In range `0 ` to `255 `  | Calculated using thirteenth byte of data |
100
+| `prog_ref_level_present`   | `0 ` `1 `  | Calculated using fourteenth byte of data |
101
+| `prog_ref_level`   | In range `0 ` to `255 `  | Calculated using fifteenth byte of data |
102
+| `PCE_mixdown_idx_present`   | `0 ` `1 `   | Calculated using sixteenth byte of data |
103
+| `ETSI_DmxLvl_present`   | `0 ` `1 `   | Calculated using seventeenth byte of data |
104
+| `centerMixLevel`   | In range `0 ` to `7 `  | Calculated using eighteenth byte of data |
105
+| `surroundMixLevel`   | In range `0 ` to `7 `  | Calculated using nineteenth byte of data |
106
+| `dolbySurroundMode`   | In range `0 ` to `2 `   | Calculated using twentieth byte of data |
107
+| `drcPresentationMode`   | In range `0 ` to `2 `   | Calculated using twenty-first byte of data |
108
+| `extAncDataEnable`   | `0 ` `1 `  | Calculated using twenty-second byte of data |
109
+| `extDownmixLevelEnable`   | `0 ` `1 `  | Calculated using twenty-third byte of data |
110
+| `extDownmixLevel_A`   | In range `0 ` to `7 `  | Calculated using twenty-fourth byte of data |
111
+| `extDownmixLevel_B`   | In range `0 ` to `7 `  | Calculated using twenty-fifth byte of data |
112
+| `dmxGainEnable`   |  `0 ` `1 `   | Calculated using twenty-sixth byte of data |
113
+| `dmxGain5`   | In range `0 ` to `255 `  | Calculated using twenty-seventh byte of data |
114
+| `dmxGain2`   | In range `0 ` to `255 `  | Calculated using twenty-eighth byte of data |
115
+| `lfeDmxEnable`   | `0 ` `1 `  | Calculated using twenty-ninth byte of data |
116
+| `lfeDmxLevel`   | In range `0 ` to `15 `  | Calculated using thirtieth byte of data |
117
+
118
+Indexes `mInBufferIdx_1`, `mInBufferIdx_2`  and `mInBufferIdx_3`(in range `0 ` to `2`) are calculated using the thirty-first, thirty-second and thirty-third byte respectively.
119
+
120
+##### Maximize utilization of input data
121
+The plugin feeds the entire input data to the codec and continues with the encoding even on a failure. This ensures that the plugin tolerates any kind of input (empty, huge, malformed, etc) and doesnt `exit()` on any input and thereby increasing the chance of identifying vulnerabilities.
122
+
123
+## Build
124
+
125
+This describes steps to build aac_enc_fuzzer binary.
126
+
127
+## Android
128
+
129
+### Steps to build
130
+Build the fuzzer
131
+```
132
+  $ mm -j$(nproc) aac_enc_fuzzer
133
+```
134
+
135
+### Steps to run
136
+Create a directory CORPUS_DIR and copy some raw files to that folder.
137
+Push this directory to device.
138
+
139
+To run on device
140
+```
141
+  $ adb sync data
142
+  $ adb shell /data/fuzz/arm64/aac_enc_fuzzer/aac_enc_fuzzer CORPUS_DIR
143
+```
144
+To run on host
145
+```
146
+  $ $ANDROID_HOST_OUT/fuzz/x86_64/aac_enc_fuzzer/aac_enc_fuzzer CORPUS_DIR
147
+```
148
+
149
+## References:
150
+ * http://llvm.org/docs/LibFuzzer.html
151
+ * https://github.com/google/oss-fuzz
152
fdk-aac-2.0.2.tar.gz/fuzzer/aac_dec_fuzzer.cpp Added
142
 
1
@@ -0,0 +1,140 @@
2
+/******************************************************************************
3
+ *
4
+ * Copyright (C) 2020 The Android Open Source Project
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at:
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ *****************************************************************************
19
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
20
+ */
21
+
22
+#include <stdint.h>
23
+#include <string.h>
24
+#include <algorithm>
25
+#include "aacdecoder_lib.h"
26
+
27
+constexpr uint8_t kNumberOfLayers = 1;
28
+constexpr uint8_t kMaxChannelCount = 8;
29
+constexpr uint32_t kMaxConfigurationSize = 1024;
30
+constexpr uint32_t kMaxOutBufferSize = 2048 * kMaxChannelCount;
31
+
32
+// Value indicating the start of AAC Header Segment
33
+constexpr const char *kAacSegStartSeq = "AAC_STRT";
34
+constexpr uint8_t kAacSegStartSeqLen = sizeof(kAacSegStartSeq);
35
+// Value indicating the end of AAC Header Segment
36
+constexpr const char *kAacSegEndSeq = "AAC_ENDS";
37
+constexpr uint8_t kAacSegEndSeqLen = sizeof(kAacSegEndSeq);
38
+
39
+// Number of bytes used to signal the length of the header
40
+constexpr uint8_t kHeaderLengthBytes = 2;
41
+// Minimum size of an AAC header is 2
42
+// Minimum data required is
43
+// strlen(AAC_STRT) + strlen(AAC_ENDS) + kHeaderLengthBytes + 2;
44
+constexpr UINT kMinDataSize = kAacSegStartSeqLen + kAacSegEndSeqLen + kHeaderLengthBytes + 2;
45
+
46
+UINT getHeaderSize(UCHAR *data, UINT size) {
47
+  if (size < kMinDataSize) {
48
+    return 0;
49
+  }
50
+
51
+  int32_t result = memcmp(data, kAacSegStartSeq, kAacSegStartSeqLen);
52
+  if (result) {
53
+    return 0;
54
+  }
55
+  data += kAacSegStartSeqLen;
56
+  size -= kAacSegStartSeqLen;
57
+
58
+  uint32_t headerLengthInBytes = (data[0] << 8 | data[1]) & 0xFFFF;
59
+  data += kHeaderLengthBytes;
60
+  size -= kHeaderLengthBytes;
61
+
62
+  if (headerLengthInBytes + kAacSegEndSeqLen > size) {
63
+    return 0;
64
+  }
65
+
66
+  data += headerLengthInBytes;
67
+  size -= headerLengthInBytes;
68
+  result = memcmp(data, kAacSegEndSeq, kAacSegEndSeqLen);
69
+  if (result) {
70
+    return 0;
71
+  }
72
+
73
+  return std::min(headerLengthInBytes, kMaxConfigurationSize);
74
+}
75
+
76
+class Codec {
77
+ public:
78
+  Codec() = default;
79
+  ~Codec() { deInitDecoder(); }
80
+  bool initDecoder();
81
+  void decodeFrames(UCHAR *data, UINT size);
82
+  void deInitDecoder();
83
+
84
+ private:
85
+  HANDLE_AACDECODER mAacDecoderHandle = nullptr;
86
+  AAC_DECODER_ERROR mErrorCode = AAC_DEC_OK;
87
+};
88
+
89
+bool Codec::initDecoder() {
90
+  mAacDecoderHandle = aacDecoder_Open(TT_MP4_ADIF, kNumberOfLayers);
91
+  if (!mAacDecoderHandle) {
92
+    return false;
93
+  }
94
+  return true;
95
+}
96
+
97
+void Codec::deInitDecoder() {
98
+  aacDecoder_Close(mAacDecoderHandle);
99
+  mAacDecoderHandle = nullptr;
100
+}
101
+
102
+void Codec::decodeFrames(UCHAR *data, UINT size) {
103
+  UINT headerSize = getHeaderSize(data, size);
104
+  if (headerSize != 0) {
105
+    data += kAacSegStartSeqLen + kHeaderLengthBytes;
106
+    size -= kAacSegStartSeqLen + kHeaderLengthBytes;
107
+    aacDecoder_ConfigRaw(mAacDecoderHandle, &data, &headerSize);
108
+    data += headerSize + kAacSegEndSeqLen;
109
+    size -= headerSize + kAacSegEndSeqLen;
110
+  }
111
+  while (size > 0) {
112
+    UINT inputSize = size;
113
+    UINT valid = size;
114
+    mErrorCode = aacDecoder_Fill(mAacDecoderHandle, &data, &inputSize, &valid);
115
+    if (mErrorCode != AAC_DEC_OK) {
116
+      ++data;
117
+      --size;
118
+    } else {
119
+      INT_PCM outputBuf[kMaxOutBufferSize];
120
+      do {
121
+        mErrorCode =
122
+            aacDecoder_DecodeFrame(mAacDecoderHandle, outputBuf, sizeof(outputBuf), 0);
123
+      } while (mErrorCode == AAC_DEC_OK);
124
+      UINT offset = inputSize - valid;
125
+      data += offset;
126
+      size = valid;
127
+    }
128
+  }
129
+}
130
+
131
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
132
+  Codec *codec = new Codec();
133
+  if (!codec) {
134
+    return 0;
135
+  }
136
+  if (codec->initDecoder()) {
137
+    codec->decodeFrames((UCHAR *)(data), static_cast<UINT>(size));
138
+  }
139
+  delete codec;
140
+  return 0;
141
+}
142
fdk-aac-2.0.2.tar.gz/fuzzer/aac_enc_fuzzer.cpp Added
201
 
1
@@ -0,0 +1,479 @@
2
+/******************************************************************************
3
+ *
4
+ * Copyright (C) 2020 The Android Open Source Project
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at:
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ *****************************************************************************
19
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
20
+ */
21
+
22
+#include <string>
23
+#include "aacenc_lib.h"
24
+#include "src/aacenc.h"
25
+
26
+using namespace std;
27
+
28
+// IN_AUDIO_DATA, IN_ANCILLRY_DATA and IN_METADATA_SETUP
29
+constexpr size_t kMaxBuffers = 3;
30
+
31
+constexpr size_t kMaxOutputBufferSize = 8192;
32
+
33
+constexpr uint32_t kMinBitRate = 8000;
34
+constexpr uint32_t kMaxBitRate = 960000;
35
+
36
+constexpr int32_t kSampleRates[] = {8000,  11025, 12000, 16000, 22050, 24000,
37
+                                    32000, 44100, 48000, 64000, 88200, 96000};
38
+constexpr size_t kSampleRatesSize = size(kSampleRates);
39
+
40
+constexpr CHANNEL_MODE kChannelModes[] = {MODE_1,
41
+                                          MODE_2,
42
+                                          MODE_1_2,
43
+                                          MODE_1_2_1,
44
+                                          MODE_1_2_2,
45
+                                          MODE_1_2_2_1,
46
+                                          MODE_1_2_2_2_1,
47
+                                          MODE_6_1,
48
+                                          MODE_7_1_BACK,
49
+                                          MODE_7_1_TOP_FRONT,
50
+                                          MODE_7_1_REAR_SURROUND,
51
+                                          MODE_7_1_FRONT_CENTER,
52
+                                          MODE_212};
53
+constexpr size_t kChannelModesSize = size(kChannelModes);
54
+
55
+constexpr TRANSPORT_TYPE kIdentifiers[] = {
56
+    TT_MP4_RAW, TT_MP4_ADIF, TT_MP4_ADTS, TT_MP4_LATM_MCP1, TT_MP4_LATM_MCP0, TT_MP4_LOAS, TT_DRM};
57
+constexpr size_t kIdentifiersSize = size(kIdentifiers);
58
+
59
+constexpr AUDIO_OBJECT_TYPE kAudioObjectTypes[] = {AOT_NONE,        AOT_NULL_OBJECT,
60
+                                                   AOT_AAC_MAIN,    AOT_AAC_LC,
61
+                                                   AOT_AAC_SSR,     AOT_AAC_LTP,
62
+                                                   AOT_SBR,         AOT_AAC_SCAL,
63
+                                                   AOT_TWIN_VQ,     AOT_CELP,
64
+                                                   AOT_HVXC,        AOT_RSVD_10,
65
+                                                   AOT_RSVD_11,     AOT_TTSI,
66
+                                                   AOT_MAIN_SYNTH,  AOT_WAV_TAB_SYNTH,
67
+                                                   AOT_GEN_MIDI,    AOT_ALG_SYNTH_AUD_FX,
68
+                                                   AOT_ER_AAC_LC,   AOT_RSVD_18,
69
+                                                   AOT_ER_AAC_LTP,  AOT_ER_AAC_SCAL,
70
+                                                   AOT_ER_TWIN_VQ,  AOT_ER_BSAC,
71
+                                                   AOT_ER_AAC_LD,   AOT_ER_CELP,
72
+                                                   AOT_ER_HVXC,     AOT_ER_HILN,
73
+                                                   AOT_ER_PARA,     AOT_RSVD_28,
74
+                                                   AOT_PS,          AOT_MPEGS,
75
+                                                   AOT_ESCAPE,      AOT_MP3ONMP4_L1,
76
+                                                   AOT_MP3ONMP4_L2, AOT_MP3ONMP4_L3,
77
+                                                   AOT_RSVD_35,     AOT_RSVD_36,
78
+                                                   AOT_AAC_SLS,     AOT_SLS,
79
+                                                   AOT_ER_AAC_ELD,  AOT_USAC,
80
+                                                   AOT_SAOC,        AOT_LD_MPEGS,
81
+                                                   AOT_MP2_AAC_LC,  AOT_MP2_SBR,
82
+                                                   AOT_DRM_AAC,     AOT_DRM_SBR,
83
+                                                   AOT_DRM_MPEG_PS, AOT_DRM_SURROUND,
84
+                                                   AOT_DRM_USAC};
85
+
86
+constexpr size_t kAudioObjectTypesSize = size(kAudioObjectTypes);
87
+
88
+constexpr int32_t kSbrRatios[] = {-1, 0, 1, 2};
89
+constexpr size_t kSbrRatiosSize = size(kSbrRatios);
90
+
91
+constexpr int32_t kBitRateModes[] = {
92
+    AACENC_BR_MODE_INVALID, AACENC_BR_MODE_CBR,   AACENC_BR_MODE_VBR_1,
93
+    AACENC_BR_MODE_VBR_2,   AACENC_BR_MODE_VBR_3, AACENC_BR_MODE_VBR_4,
94
+    AACENC_BR_MODE_VBR_5,   AACENC_BR_MODE_FF,    AACENC_BR_MODE_SFR};
95
+constexpr size_t kBitRateModesSize = size(kBitRateModes);
96
+
97
+constexpr int32_t kGranuleLengths[] = {120, 128, 240, 256, 480, 512, 1024};
98
+constexpr size_t kGranuleLengthsSize = size(kGranuleLengths);
99
+
100
+constexpr int32_t kChannelOrder[] = {CH_ORDER_MPEG, CH_ORDER_WAV};
101
+constexpr size_t kChannelOrderSize = size(kChannelOrder);
102
+
103
+constexpr int32_t kSignalingModes[] = {-1, 0, 1, 2, 3};
104
+constexpr size_t kSignalingModesSize = size(kSignalingModes);
105
+
106
+constexpr int32_t kAudioMuxVer[] = {-1, 0, 1, 2};
107
+constexpr size_t kAudioMuxVerSize = size(kAudioMuxVer);
108
+
109
+constexpr int32_t kSbrModes[] = {-1, 0, 1, 2};
110
+constexpr size_t kSbrModesSize = size(kSbrModes);
111
+
112
+constexpr AACENC_METADATA_DRC_PROFILE kMetaDataDrcProfiles[] = {
113
+    AACENC_METADATA_DRC_NONE,       AACENC_METADATA_DRC_FILMSTANDARD,
114
+    AACENC_METADATA_DRC_FILMLIGHT,  AACENC_METADATA_DRC_MUSICSTANDARD,
115
+    AACENC_METADATA_DRC_MUSICLIGHT, AACENC_METADATA_DRC_SPEECH,
116
+    AACENC_METADATA_DRC_NOT_PRESENT};
117
+constexpr size_t kMetaDataDrcProfilesSize = size(kMetaDataDrcProfiles);
118
+
119
+enum {
120
+    IDX_SBR_MODE = 0,
121
+    IDX_AAC_AOT,
122
+    IDX_SAMPLE_RATE,
123
+    IDX_BIT_RATE_1,
124
+    IDX_BIT_RATE_2,
125
+    IDX_BIT_RATE_3,
126
+    IDX_CHANNEL,
127
+    IDX_IDENTIFIER,
128
+    IDX_SBR_RATIO,
129
+    IDX_METADATA_DRC_PROFILE,
130
+    IDX_METADATA_COMP_PROFILE,
131
+    IDX_METADATA_DRC_TARGET_REF_LEVEL,
132
+    IDX_METADATA_COMP_TARGET_REF_LEVEL,
133
+    IDX_METADATA_PROG_LEVEL_PRESENT,
134
+    IDX_METADATA_PROG_LEVEL,
135
+    IDX_METADATA_PCE_MIXDOWN_IDX_PRESENT,
136
+    IDX_METADATA_ETSI_DMXLVL_PRESENT,
137
+    IDX_METADATA_CENTER_MIX_LEVEL,
138
+    IDX_METADATA_SURROUND_MIX_LEVEL,
139
+    IDX_METADATA_DOLBY_SURROUND_MODE,
140
+    IDX_METADATA_DRC_PRESENTATION_MODE,
141
+    IDX_METADATA_EXT_ANC_DATA_ENABLE,
142
+    IDX_METADATA_EXT_DOWNMIX_LEVEL_ENABLE,
143
+    IDX_METADATA_EXT_DOWNMIX_LEVEL_A,
144
+    IDX_METADATA_EXT_DOWNMIX_LEVEL_B,
145
+    IDX_METADATA_DMX_GAIN_ENABLE,
146
+    IDX_METADATA_DMX_GAIN_5,
147
+    IDX_METADATA_DMX_GAIN_2,
148
+    IDX_METADATA_LFE_DMX_ENABLE,
149
+    IDX_METADATA_LFE_DMX_LEVEL,
150
+    IDX_IN_BUFFER_INDEX_1,
151
+    IDX_IN_BUFFER_INDEX_2,
152
+    IDX_IN_BUFFER_INDEX_3,
153
+    IDX_BIT_RATE_MODE,
154
+    IDX_GRANULE_LENGTH,
155
+    IDX_CHANNELORDER,
156
+    IDX_AFTERBURNER,
157
+    IDX_BANDWIDTH,
158
+    IDX_PEAK_BITRATE,
159
+    IDX_HEADER_PERIOD,
160
+    IDX_SIGNALING_MODE,
161
+    IDX_TPSUBFRAMES,
162
+    IDX_AUDIOMUXVER,
163
+    IDX_PROTECTION,
164
+    IDX_ANCILLARY_BITRATE,
165
+    IDX_METADATA_MODE,
166
+    IDX_LAST
167
+};
168
+
169
+template <typename type1, typename type2, typename type3>
170
+auto generateNumberInRangeFromData(type1 data, type2 min, type3 max) -> decltype(max) {
171
+    return (data % (1 + max - min)) + min;
172
+}
173
+
174
+class Codec {
175
+   public:
176
+    ~Codec() { deInitEncoder(); }
177
+    bool initEncoder(uint8_t **dataPtr, size_t *sizePtr);
178
+    void encodeFrames(const uint8_t *data, size_t size);
179
+    void deInitEncoder();
180
+
181
+   private:
182
+    template <typename type1, typename type2, typename type3>
183
+    void setAACParam(type1 data, const AACENC_PARAM aacParam, type2 min, type2 max,
184
+                     const type3 *array = nullptr);
185
+    void setupMetaData(uint8_t *data);
186
+
187
+    HANDLE_AACENCODER mEncoder = nullptr;
188
+    AACENC_MetaData mMetaData = {};
189
+    uint32_t mInBufferIdx_1 = 0;
190
+    uint32_t mInBufferIdx_2 = 0;
191
+    uint32_t mInBufferIdx_3 = 0;
192
+};
193
+
194
+void Codec::setupMetaData(uint8_t *data) {
195
+    uint32_t drcProfileIndex = generateNumberInRangeFromData(data[IDX_METADATA_DRC_PROFILE], 0,
196
+                                                             kMetaDataDrcProfilesSize - 1);
197
+    AACENC_METADATA_DRC_PROFILE drcProfile = kMetaDataDrcProfiles[drcProfileIndex];
198
+    mMetaData.drc_profile = drcProfile;
199
+
200
+    uint32_t compProfileIndex = generateNumberInRangeFromData(data[IDX_METADATA_COMP_PROFILE], 0,
201
fdk-aac-2.0.1.tar.gz/libAACdec/include/aacdecoder_lib.h -> fdk-aac-2.0.2.tar.gz/libAACdec/include/aacdecoder_lib.h Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -164,9 +164,6 @@
11
 files are provided for usage in specific C/C++ programs. The main AAC decoder
12
 library API functions are located in aacdecoder_lib.h header file.
13
 
14
-In binary releases the decoder core resides in statically linkable libraries,
15
-for example libAACdec.a.
16
-
17
 
18
 \section Calling_Sequence Calling Sequence
19
 
20
@@ -174,19 +171,7 @@
21
 HE-AAC v2, or MPEG-D USAC bitstreams. In the following description, input stream
22
 read and output write function details are left out, since they may be
23
 implemented in a variety of configurations depending on the user's specific
24
-requirements. The example implementation uses file-based input/output, and in
25
-such case one may call mpegFileRead_Open() to open an input file and to allocate
26
-memory for the required structures, and the corresponding mpegFileRead_Close()
27
-to close opened files and to de-allocate associated structures.
28
-mpegFileRead_Open() will attempt to detect the bitstream format and in case of
29
-MPEG-4 file format or Raw Packets file format (a proprietary Fraunhofer IIS file
30
-format suitable only for testing) it will read the Audio Specific Config data
31
-(ASC). An unsuccessful attempt to recognize the bitstream format requires the
32
-user to provide this information manually. For any other bitstream formats that
33
-are usually applicable in streaming applications, the decoder itself will try to
34
-synchronize and parse the given bitstream fragment using the FDK transport
35
-library. Hence, for streaming applications (without file access) this step is
36
-not necessary.
37
+requirements.
38
 
39
 
40
 -# Call aacDecoder_Open() to open and retrieve a handle to a new AAC decoder
41
@@ -205,19 +190,17 @@
42
 working memory (a client-supplied input buffer "inBuffer" in framework). This
43
 buffer will be used to load AAC bitstream data to the decoder.  Only when all
44
 data in this buffer has been processed will the decoder signal an empty buffer.
45
-For file-based input, you may invoke mpegFileRead_Read() to acquire new
46
-bitstream data.
47
 -# Call aacDecoder_Fill() to fill the decoder's internal bitstream input buffer
48
 with the client-supplied bitstream input buffer. Note, if the data loaded in to
49
 the internal buffer is not sufficient to decode a frame,
50
 aacDecoder_DecodeFrame() will return ::AAC_DEC_NOT_ENOUGH_BITS until a
51
 sufficient amount of data is loaded in to the internal buffer. For streaming
52
 formats (ADTS, LOAS), it is acceptable to load more than one frame to the
53
-decoder. However, for RAW file format (Fraunhofer IIS proprietary format), only
54
-one frame may be loaded to the decoder per aacDecoder_DecodeFrame() call. For
55
-least amount of communication delay, fill and decode should be performed on a
56
-frame by frame basis. \code ErrorStatus = aacDecoder_Fill(aacDecoderInfo,
57
-inBuffer, bytesRead, bytesValid); \endcode
58
+decoder. However, for packed based formats, only one frame may be loaded to the
59
+decoder per aacDecoder_DecodeFrame() call. For least amount of communication
60
+delay, fill and decode should be performed on a frame by frame basis. \code
61
+    ErrorStatus = aacDecoder_Fill(aacDecoderInfo, inBuffer, bytesRead,
62
+bytesValid); \endcode
63
 -# Call aacDecoder_DecodeFrame(). This function decodes one frame and writes
64
 decoded PCM audio data to a client-supplied buffer. It is the client's
65
 responsibility to allocate a buffer which is large enough to hold the decoded
66
@@ -225,12 +208,9 @@
67
 TimeData, OUT_BUF_SIZE, flags); \endcode If the bitstream configuration (number
68
 of channels, sample rate, frame size) is not known a priori, you may call
69
 aacDecoder_GetStreamInfo() to retrieve a structure that contains this
70
-information. You may use this data to initialize an audio output device. In the
71
-example program, if the number of channels or the sample rate has changed since
72
-program start or the previously decoded frame, the audio output device is then
73
-re-initialized. If WAVE file output is chosen, a new WAVE file for each new
74
-stream configuration is be created. \code p_si =
75
-aacDecoder_GetStreamInfo(aacDecoderInfo); \endcode
76
+information. You may use this data to initialize an audio output device. \code
77
+    p_si = aacDecoder_GetStreamInfo(aacDecoderInfo);
78
+\endcode
79
 -# Repeat steps 5 to 7 until no data is available to decode any more, or in case
80
 of error. \code } while (bytesRead[0] > 0 || doFlush || doBsFlush ||
81
 forceContinue); \endcode
82
@@ -239,7 +219,7 @@
83
 
84
 \image latex decode.png "Decode calling sequence" width=11cm
85
 
86
-\image latex change_source.png "Change data source sequence" width 5cm
87
+\image latex change_source.png "Change data source sequence" width=5cm
88
 
89
 \image latex conceal.png "Error concealment sequence" width=14cm
90
 
91
@@ -296,16 +276,14 @@
92
 limited applications, the output buffer may be reused as an external input
93
 buffer prior to the subsequence aacDecoder_Fill() function call.
94
 
95
-The external input buffer is set in the example program and its size is defined
96
-by ::IN_BUF_SIZE. You may freely choose different buffer sizes. To feed the data
97
-to the decoder-internal input buffer, use the function aacDecoder_Fill(). This
98
-function returns important information regarding the number of bytes in the
99
-external input buffer that have not yet been copied into the internal input
100
-buffer (variable bytesValid). Once the external buffer has been fully copied, it
101
-can be completely re-filled again. In case you wish to refill the buffer while
102
-there are unprocessed bytes (bytesValid is unequal 0), you should preserve the
103
-unconsumed data. However, we recommend to refill the buffer only when bytesValid
104
-returns 0.
105
+To feed the data to the decoder-internal input buffer, use the
106
+function aacDecoder_Fill(). This function returns important information
107
+regarding the number of bytes in the external input buffer that have not yet
108
+been copied into the internal input buffer (variable bytesValid). Once the
109
+external buffer has been fully copied, it can be completely re-filled again. In
110
+case you wish to refill the buffer while there are unprocessed bytes (bytesValid
111
+is unequal 0), you should preserve the unconsumed data. However, we recommend to
112
+refill the buffer only when bytesValid returns 0.
113
 
114
 The bytesValid parameter is an input and output parameter to the FDK decoder. As
115
 an input, it signals how many valid bytes are available in the external buffer.
116
@@ -340,10 +318,7 @@
117
 In case a Program Config is included in the audio configuration, the channel
118
 mapping described within it will be adopted.
119
 
120
-In case of MPEG-D Surround the channel mapping will follow the same criteria
121
-described in ISO/IEC 13818-7:2005(E), but adding corresponding top channels (if
122
-available) to the channel types in order to avoid ambiguity. The examples below
123
-explain these aspects in detail.
124
+The examples below explain these aspects in detail.
125
 
126
 \section OutputFormatChange Changing the audio output format
127
 
128
@@ -459,7 +434,7 @@
129
 #include "genericStds.h"
130
 
131
 #define AACDECODER_LIB_VL0 3
132
-#define AACDECODER_LIB_VL1 0
133
+#define AACDECODER_LIB_VL1 2
134
 #define AACDECODER_LIB_VL2 0
135
 
136
 /**
137
@@ -694,9 +669,7 @@
138
                      2. If the parameter value is greater than that of
139
                  ::AAC_PCM_MAX_OUTPUT_CHANNELS both will be set to the same
140
                  value. \n
141
-                     3. This parameter does not affect MPEG Surround processing.
142
-                 \n
143
-                     4. This parameter will be ignored if the number of encoded
144
+                     3. This parameter will be ignored if the number of encoded
145
                  audio channels is greater than 8. */
146
   AAC_PCM_MAX_OUTPUT_CHANNELS =
147
       0x0012, /*!< Maximum number of PCM output channels. If lower than the
148
@@ -723,11 +696,7 @@
149
                      2. If the parameter value is greater than zero but smaller
150
                  than ::AAC_PCM_MIN_OUTPUT_CHANNELS both will be set to same
151
                  value. \n
152
-                     3. The operating mode of the MPEG Surround module will be
153
-                 set accordingly. \n
154
-                     4. Setting this parameter with any value will disable the
155
-                 binaural processing of the MPEG Surround module
156
-                     5. This parameter will be ignored if the number of encoded
157
+                     3. This parameter will be ignored if the number of encoded
158
                  audio channels is greater than 8. */
159
   AAC_METADATA_PROFILE =
160
       0x0020, /*!< See ::AAC_MD_PROFILE for all available values. */
161
@@ -746,66 +715,77 @@
162
                                   ::CONCEAL_INTER. only some AOTs are
163
                                   supported). \n */
164
   AAC_DRC_BOOST_FACTOR =
165
-      0x0200, /*!< Dynamic Range Control: Scaling factor for boosting gain
166
-                 values. Defines how the boosting DRC factors (conveyed in the
167
-                 bitstream) will be applied to the decoded signal. The valid
168
-                 values range from 0 (don't apply boost factors) to 127 (fully
169
-                   apply boost factors). Default value is 0. */
170
-  AAC_DRC_ATTENUATION_FACTOR =
171
-      0x0201, /*!< Dynamic Range Control: Scaling factor for attenuating gain
172
-                 values. Same as
173
-                   ::AAC_DRC_BOOST_FACTOR but for attenuating DRC factors. */
174
+      0x0200, /*!< MPEG-4 / MPEG-D Dynamic Range Control (DRC): Scaling factor
175
+                 for boosting gain values. Defines how the boosting DRC factors
176
+                 (conveyed in the bitstream) will be applied to the decoded
177
+                 signal. The valid values range from 0 (don't apply boost
178
+                 factors) to 127 (fully apply boost factors). Default value is 0
179
+                 for MPEG-4 DRC and 127 for MPEG-D DRC. */
180
+  AAC_DRC_ATTENUATION_FACTOR = 0x0201, /*!< MPEG-4 / MPEG-D DRC: Scaling factor
181
+                                          for attenuating gain values. Same as
182
+                                            ::AAC_DRC_BOOST_FACTOR but for
183
+                                          attenuating DRC factors. */
184
   AAC_DRC_REFERENCE_LEVEL =
185
-      0x0202, /*!< Dynamic Range Control (DRC): Target reference level. Defines
186
-                 the level below full-scale (quantized in steps of 0.25dB) to
187
-                 which the output audio signal will be normalized to by the DRC
188
-                 module. The parameter controls loudness normalization for both
189
-                 MPEG-4 DRC and MPEG-D DRC. The valid values range from 40 (-10
190
-                 dBFS) to 127 (-31.75 dBFS). Any value smaller than 0 switches
191
-                 off loudness normalization and MPEG-4 DRC. By default, loudness
192
-                 normalization and MPEG-4 DRC is switched off. */
193
+      0x0202, /*!< MPEG-4 / MPEG-D DRC: Target reference level / decoder target
194
+                 loudness.\n Defines the level below full-scale (quantized in
195
+                 steps of 0.25dB) to which the output audio signal will be
196
+                 normalized to by the DRC module.\n The parameter controls
197
+                 loudness normalization for both MPEG-4 DRC and MPEG-D DRC. The
198
+                 valid values range from 40 (-10 dBFS) to 127 (-31.75 dBFS).\n
199
+                   Example values:\n
200
+                   124 (-31 dBFS) for audio/video receivers (AVR) or other
201
fdk-aac-2.0.1.tar.gz/libAACdec/src/FDK_delay.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/FDK_delay.cpp Changed
67
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -113,7 +113,7 @@
11
 
12
   if (delay > 0) {
13
     data->delay_line =
14
-        (INT_PCM*)FDKcalloc(num_channels * delay, sizeof(INT_PCM));
15
+        (PCM_DEC*)FDKcalloc(num_channels * delay, sizeof(PCM_DEC));
16
     if (data->delay_line == NULL) {
17
       return -1;
18
     }
19
@@ -126,36 +126,36 @@
20
   return 0;
21
 }
22
 
23
-void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
24
+void FDK_Delay_Apply(FDK_SignalDelay* data, PCM_DEC* time_buffer,
25
                      const UINT frame_length, const UCHAR channel) {
26
   FDK_ASSERT(data != NULL);
27
 
28
   if (data->delay > 0) {
29
-    C_ALLOC_SCRATCH_START(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
30
+    C_ALLOC_SCRATCH_START(tmp, PCM_DEC, MAX_FRAME_LENGTH)
31
     FDK_ASSERT(frame_length <= MAX_FRAME_LENGTH);
32
     FDK_ASSERT(channel < data->num_channels);
33
     FDK_ASSERT(time_buffer != NULL);
34
     if (frame_length >= data->delay) {
35
       FDKmemcpy(tmp, &time_buffer[frame_length - data->delay],
36
-                data->delay * sizeof(FIXP_PCM));
37
+                data->delay * sizeof(PCM_DEC));
38
       FDKmemmove(&time_buffer[data->delay], &time_buffer[0],
39
-                 (frame_length - data->delay) * sizeof(FIXP_PCM));
40
+                 (frame_length - data->delay) * sizeof(PCM_DEC));
41
       FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
42
-                data->delay * sizeof(FIXP_PCM));
43
+                data->delay * sizeof(PCM_DEC));
44
       FDKmemcpy(&data->delay_line[channel * data->delay], tmp,
45
-                data->delay * sizeof(FIXP_PCM));
46
+                data->delay * sizeof(PCM_DEC));
47
     } else {
48
-      FDKmemcpy(tmp, &time_buffer[0], frame_length * sizeof(FIXP_PCM));
49
+      FDKmemcpy(tmp, &time_buffer[0], frame_length * sizeof(PCM_DEC));
50
       FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
51
-                frame_length * sizeof(FIXP_PCM));
52
+                frame_length * sizeof(PCM_DEC));
53
       FDKmemcpy(&data->delay_line[channel * data->delay],
54
                 &data->delay_line[channel * data->delay + frame_length],
55
-                (data->delay - frame_length) * sizeof(FIXP_PCM));
56
+                (data->delay - frame_length) * sizeof(PCM_DEC));
57
       FDKmemcpy(&data->delay_line[channel * data->delay +
58
                                   (data->delay - frame_length)],
59
-                tmp, frame_length * sizeof(FIXP_PCM));
60
+                tmp, frame_length * sizeof(PCM_DEC));
61
     }
62
-    C_ALLOC_SCRATCH_END(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
63
+    C_ALLOC_SCRATCH_END(tmp, PCM_DEC, MAX_FRAME_LENGTH)
64
   }
65
 
66
   return;
67
fdk-aac-2.0.1.tar.gz/libAACdec/src/FDK_delay.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/FDK_delay.h Changed
28
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -109,7 +109,7 @@
11
  * Structure representing one delay element for multiple channels.
12
  */
13
 typedef struct {
14
-  INT_PCM* delay_line; /*!< Pointer which stores allocated delay line. */
15
+  PCM_DEC* delay_line; /*!< Pointer which stores allocated delay line. */
16
   USHORT delay;        /*!< Delay required in samples (per channel). */
17
   UCHAR num_channels;  /*!< Number of channels to delay. */
18
 } FDK_SignalDelay;
19
@@ -137,7 +137,7 @@
20
  *
21
  * \return void
22
  */
23
-void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
24
+void FDK_Delay_Apply(FDK_SignalDelay* data, PCM_DEC* time_buffer,
25
                      const UINT frame_length, const UCHAR channel);
26
 
27
 /**
28
fdk-aac-2.0.1.tar.gz/libAACdec/src/aac_ram.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aac_ram.cpp Changed
33
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -105,12 +105,7 @@
11
 
12
 #define WORKBUFFER1_TAG 0
13
 #define WORKBUFFER2_TAG 1
14
-
15
-#define WORKBUFFER3_TAG 4
16
-#define WORKBUFFER4_TAG 5
17
-
18
 #define WORKBUFFER5_TAG 6
19
-
20
 #define WORKBUFFER6_TAG 7
21
 
22
 /*! The structure AAC_DECODER_INSTANCE is the top level structure holding all
23
@@ -169,9 +164,6 @@
24
 C_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL, ((8) * 1024), SECT_DATA_L2,
25
                     WORKBUFFER2_TAG)
26
 
27
-C_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL, WB_SECTION_SIZE, SECT_DATA_L2,
28
-                    WORKBUFFER3_TAG)
29
-C_AALLOC_MEM(WorkBufferCore4, FIXP_DBL, WB_SECTION_SIZE)
30
 C_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR,
31
                     fMax((INT)(sizeof(FIXP_DBL) * WB_SECTION_SIZE),
32
                          (INT)sizeof(CAacDecoderCommonData)),
33
fdk-aac-2.0.1.tar.gz/libAACdec/src/aac_ram.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aac_ram.h Changed
23
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -136,12 +136,7 @@
11
 
12
 H_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1)
13
 H_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL)
14
-
15
-H_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL)
16
-H_ALLOC_MEM(WorkBufferCore4, FIXP_DBL)
17
-
18
 H_ALLOC_MEM_OVERLAY(WorkBufferCore5, PCM_DEC)
19
-
20
 H_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR)
21
 
22
 #endif /* #ifndef AAC_RAM_H */
23
fdk-aac-2.0.1.tar.gz/libAACdec/src/aac_rom.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aac_rom.h Changed
18
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -108,6 +108,7 @@
11
 #include "aacdec_hcr_types.h"
12
 #include "aacdec_hcrs.h"
13
 
14
+#define PCM_AAC LONG
15
 #define PCM_DEC FIXP_DBL
16
 #define MAXVAL_PCM_DEC MAXVAL_DBL
17
 #define MINVAL_PCM_DEC MINVAL_DBL
18
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdec_drc.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdec_drc.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -150,6 +150,20 @@
11
 }
12
 
13
 /*!
14
+\brief Reset DRC information
15
+
16
+\self Handle of DRC info
17
+
18
+\return none
19
+*/
20
+void aacDecoder_drcReset(HANDLE_AAC_DRC self) {
21
+  self->applyExtGain = 0;
22
+  self->additionalGainPrev = AACDEC_DRC_GAIN_INIT_VALUE;
23
+  self->additionalGainFilterState = AACDEC_DRC_GAIN_INIT_VALUE;
24
+  self->additionalGainFilterState1 = AACDEC_DRC_GAIN_INIT_VALUE;
25
+}
26
+
27
+/*!
28
   \brief Initialize DRC information
29
 
30
   \self Handle of DRC info
31
@@ -174,9 +188,8 @@
32
   pParams->usrCut = FL2FXCONST_DBL(0.0f);
33
   pParams->boost = FL2FXCONST_DBL(0.0f);
34
   pParams->usrBoost = FL2FXCONST_DBL(0.0f);
35
-  pParams->targetRefLevel = -1;
36
+  pParams->targetRefLevel = 96;
37
   pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES;
38
-  pParams->applyDigitalNorm = OFF;
39
   pParams->applyHeavyCompression = OFF;
40
   pParams->usrApplyHeavyCompression = OFF;
41
 
42
@@ -192,6 +205,8 @@
43
   self->progRefLevelPresent = 0;
44
   self->presMode = -1;
45
   self->uniDrcPrecedence = 0;
46
+
47
+  aacDecoder_drcReset(self);
48
 }
49
 
50
 /*!
51
@@ -258,11 +273,8 @@
52
         return AAC_DEC_INVALID_HANDLE;
53
       }
54
       if (value < 0) {
55
-        self->params.applyDigitalNorm = OFF;
56
         self->params.targetRefLevel = -1;
57
       } else {
58
-        /* ref_level must be between 0 and MAX_REFERENCE_LEVEL, inclusive */
59
-        self->params.applyDigitalNorm = ON;
60
         if (self->params.targetRefLevel != (SCHAR)value) {
61
           self->params.targetRefLevel = (SCHAR)value;
62
           self->progRefLevel = (SCHAR)value; /* Always set the program reference
63
@@ -273,16 +285,6 @@
64
         self->update = 1;
65
       }
66
       break;
67
-    case APPLY_NORMALIZATION:
68
-      if ((value != OFF) && (value != ON)) {
69
-        return AAC_DEC_SET_PARAM_FAIL;
70
-      }
71
-      if (self == NULL) {
72
-        return AAC_DEC_INVALID_HANDLE;
73
-      }
74
-      /* Store new parameter value */
75
-      self->params.applyDigitalNorm = (UCHAR)value;
76
-      break;
77
     case APPLY_HEAVY_COMPRESSION:
78
       if ((value != OFF) && (value != ON)) {
79
         return AAC_DEC_SET_PARAM_FAIL;
80
@@ -910,11 +912,9 @@
81
       FDK_ASSERT(0);
82
     }
83
   }
84
-  if (self->params.applyDigitalNorm == OFF) {
85
-    /* Reset normalization gain since this module must not apply it */
86
-    norm_mantissa = FL2FXCONST_DBL(0.5f);
87
-    norm_exponent = 1;
88
-  }
89
+  /* Reset normalization gain since this module must not apply it */
90
+  norm_mantissa = FL2FXCONST_DBL(0.5f);
91
+  norm_exponent = 1;
92
 
93
   /* calc scale factors */
94
   for (band = 0; band < numBands; band++) {
95
@@ -1353,3 +1353,152 @@
96
     }
97
   }
98
 }
99
+
100
+/**
101
+ * \brief  Apply DRC Level Normalization.
102
+ *
103
+ *         This function prepares/applies the gain values for the DRC Level
104
+ * Normalization and returns the exponent of the time data. The following two
105
+ * cases are handled:
106
+ *
107
+ *         - Limiter enabled:
108
+ *           The input data must be interleaved.
109
+ *           One gain per sample is written to the buffer pGainPerSample.
110
+ *           If necessary the time data is rescaled.
111
+ *
112
+ *         - Limiter disabled:
113
+ *           The input data can be interleaved or deinterleaved.
114
+ *           The gain values are applied to the time data.
115
+ *           If necessary the time data is rescaled.
116
+ *
117
+ * \param hDrcInfo                     [i/o] handle to drc data structure.
118
+ * \param samplesIn                    [i/o] pointer to time data.
119
+ * \param pGain                        [i  ] pointer to gain to be applied to
120
+ * the time data.
121
+ * \param pGainPerSample               [o  ] pointer to the gain per sample to
122
+ * be applied to the time data in the limiter.
123
+ * \param gain_scale                   [i  ] exponent to be applied to the time
124
+ * data.
125
+ * \param gain_delay                   [i  ] delay[samples] with which the gains
126
+ * in pGain shall be applied (gain_delay <= nSamples).
127
+ * \param nSamples                     [i  ] number of samples per frame.
128
+ * \param channels                     [i  ] number of channels.
129
+ * \param stride                       [i  ] channel stride of time data.
130
+ * \param limiterEnabled               [i  ] 1 if limiter is enabled, otherwise
131
+ * 0.
132
+ *
133
+ * \return exponent of time data
134
+ */
135
+INT applyDrcLevelNormalization(HANDLE_AAC_DRC hDrcInfo, PCM_DEC *samplesIn,
136
+                               FIXP_DBL *pGain, FIXP_DBL *pGainPerSample,
137
+                               const INT gain_scale, const UINT gain_delay,
138
+                               const UINT nSamples, const UINT channels,
139
+                               const UINT stride, const UINT limiterEnabled) {
140
+  UINT i;
141
+  INT additionalGain_scaling;
142
+  FIXP_DBL additionalGain;
143
+
144
+  FDK_ASSERT(gain_delay <= nSamples);
145
+
146
+  FIXP_DBL additionalGainSmoothState = hDrcInfo->additionalGainFilterState;
147
+  FIXP_DBL additionalGainSmoothState1 = hDrcInfo->additionalGainFilterState1;
148
+
149
+  if (!gain_delay) {
150
+    additionalGain = pGain[0];
151
+
152
+    /* Apply the additional scaling gain_scale[0] that has no delay and no
153
+     * smoothing */
154
+    additionalGain_scaling =
155
+        fMin(gain_scale, CntLeadingZeros(additionalGain) - 1);
156
+    additionalGain = scaleValue(additionalGain, additionalGain_scaling);
157
+
158
+    /* if it's not possible to fully apply gain_scale to additionalGain, apply
159
+     * it to the input signal */
160
+    additionalGain_scaling -= gain_scale;
161
+
162
+    if (additionalGain_scaling) {
163
+      scaleValuesSaturate(samplesIn, channels * nSamples,
164
+                          -additionalGain_scaling);
165
+    }
166
+
167
+    if (limiterEnabled) {
168
+      FDK_ASSERT(pGainPerSample != NULL);
169
+
170
+      for (i = 0; i < nSamples; i++) {
171
+        pGainPerSample[i] = additionalGain;
172
+      }
173
+    } else {
174
+      for (i = 0; i < channels * nSamples; i++) {
175
+        samplesIn[i] = FIXP_DBL2PCM_DEC(fMult(samplesIn[i], additionalGain));
176
+      }
177
+    }
178
+  } else {
179
+    UINT inc;
180
+    FIXP_DBL additionalGainUnfiltered;
181
+
182
+    inc = (stride == 1) ? channels : 1;
183
+
184
+    for (i = 0; i < nSamples; i++) {
185
+      if (i < gain_delay) {
186
+        additionalGainUnfiltered = hDrcInfo->additionalGainPrev;
187
+      } else {
188
+        additionalGainUnfiltered = pGain[0];
189
+      }
190
+
191
+      /* Smooth additionalGain */
192
+
193
+      /* [b,a] = butter(1, 0.01) */
194
+      static const FIXP_SGL b[] = {FL2FXCONST_SGL(0.015466 * 2.0),
195
+                                   FL2FXCONST_SGL(0.015466 * 2.0)};
196
+      static const FIXP_SGL a[] = {(FIXP_SGL)MAXVAL_SGL,
197
+                                   FL2FXCONST_SGL(-0.96907)};
198
+
199
+      additionalGain = -fMult(additionalGainSmoothState, a[1]) +
200
+                       fMultDiv2(additionalGainUnfiltered, b[0]) +
201
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdec_drc.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdec_drc.h Changed
85
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -109,6 +109,11 @@
11
 #include "channel.h"
12
 #include "FDK_bitstream.h"
13
 
14
+#define AACDEC_DRC_GAIN_SCALING (11) /* Scaling of DRC gains */
15
+#define AACDEC_DRC_GAIN_INIT_VALUE \
16
+  (FL2FXCONST_DBL(                 \
17
+      1.0f / (1 << AACDEC_DRC_GAIN_SCALING))) /* Init value for DRC gains */
18
+
19
 #define AACDEC_DRC_DFLT_EXPIRY_FRAMES \
20
   (0) /* Default DRC data expiry time in AAC frames   */
21
 
22
@@ -125,7 +130,6 @@
23
   TARGET_REF_LEVEL,
24
   DRC_BS_DELAY,
25
   DRC_DATA_EXPIRY_FRAME,
26
-  APPLY_NORMALIZATION,
27
   APPLY_HEAVY_COMPRESSION,
28
   DEFAULT_PRESENTATION_MODE,
29
   ENCODER_TARGET_LEVEL,
30
@@ -136,6 +140,8 @@
31
 /**
32
  * \brief DRC module interface functions
33
  */
34
+void aacDecoder_drcReset(HANDLE_AAC_DRC self);
35
+
36
 void aacDecoder_drcInit(HANDLE_AAC_DRC self);
37
 
38
 void aacDecoder_drcInitChannelData(CDrcChannelData *pDrcChannel);
39
@@ -189,4 +195,45 @@
40
 void aacDecoder_drcGetInfo(HANDLE_AAC_DRC self, SCHAR *pPresMode,
41
                            SCHAR *pProgRefLevel);
42
 
43
+/**
44
+ * \brief  Apply DRC Level Normalization.
45
+ *
46
+ *         This function prepares/applies the gain values for the DRC Level
47
+ * Normalization and returns the exponent of the time data. The following two
48
+ * cases are handled:
49
+ *
50
+ *         - Limiter enabled:
51
+ *           The input data must be interleaved.
52
+ *           One gain per sample is written to the buffer pGainPerSample.
53
+ *           If necessary the time data is rescaled.
54
+ *
55
+ *         - Limiter disabled:
56
+ *           The input data can be interleaved or deinterleaved.
57
+ *           The gain values are applied to the time data.
58
+ *           If necessary the time data is rescaled.
59
+ *
60
+ * \param hDrcInfo                     [i/o] handle to drc data structure.
61
+ * \param samplesIn                    [i/o] pointer to time data.
62
+ * \param pGain                        [i  ] pointer to gain to be applied to
63
+ * the time data.
64
+ * \param pGainPerSample               [o  ] pointer to the gain per sample to
65
+ * be applied to the time data in the limiter.
66
+ * \param gain_scale                   [i  ] exponent to be applied to the time
67
+ * data.
68
+ * \param gain_delay                   [i  ] delay[samples] with which the gains
69
+ * in pGain shall be applied (gain_delay <= nSamples).
70
+ * \param nSamples                     [i  ] number of samples per frame.
71
+ * \param channels                     [i  ] number of channels.
72
+ * \param stride                       [i  ] channel stride of time data.
73
+ * \param limiterEnabled               [i  ] 1 if limiter is enabled, otherwise
74
+ * 0.
75
+ *
76
+ * \return exponent of time data
77
+ */
78
+INT applyDrcLevelNormalization(HANDLE_AAC_DRC hDrcInfo, PCM_DEC *samplesIn,
79
+                               FIXP_DBL *pGain, FIXP_DBL *pGainPerSample,
80
+                               const INT gain_scale, const UINT gain_delay,
81
+                               const UINT nSamples, const UINT channels,
82
+                               const UINT stride, const UINT limiterEnabled);
83
+
84
 #endif /* AACDEC_DRC_H */
85
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdec_drc_types.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdec_drc_types.h Changed
32
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -168,7 +168,6 @@
11
 
12
   UINT expiryFrame;
13
   UCHAR bsDelayEnable;
14
-  UCHAR applyDigitalNorm;
15
 
16
   AACDEC_DRC_PARAMETER_HANDLING defaultPresentationMode;
17
   UCHAR encoderTargetLevel;
18
@@ -213,6 +212,13 @@
19
   uniDrcPrecedence; /* Flag for signalling that uniDrc is active and takes
20
                        precedence over legacy DRC */
21
 
22
+  UCHAR applyExtGain; /* Flag is 1 if extGain has to be applied, otherwise 0. */
23
+
24
+  FIXP_DBL additionalGainPrev; /* Gain of previous frame to be applied to the
25
+                                  time data */
26
+  FIXP_DBL additionalGainFilterState;  /* Filter state for the gain smoothing */
27
+  FIXP_DBL additionalGainFilterState1; /* Filter state for the gain smoothing */
28
+
29
 } CDrcInfo;
30
 
31
 typedef CDrcInfo *HANDLE_AAC_DRC;
32
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdec_hcr.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdec_hcr.cpp Changed
85
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -137,7 +137,7 @@
11
 static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
12
                                 INT quantSpecCoef, INT *pLeftStartOfSegment,
13
                                 SCHAR *pRemainingBitsInSegment,
14
-                                int *pNumDecodedBits);
15
+                                int *pNumDecodedBits, UINT *errorWord);
16
 
17
 static int DecodePCW_Sign(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
18
                           UINT codebookDim, const SCHAR *pQuantVal,
19
@@ -1179,8 +1179,8 @@
20
                   bs, pHcr->decInOut.bitstreamAnchor,
21
                   pQuantizedSpectralCoefficients
22
                       [quantizedSpectralCoefficientsIdx],
23
-                  pLeftStartOfSegment, pRemainingBitsInSegment,
24
-                  &numDecodedBits);
25
+                  pLeftStartOfSegment, pRemainingBitsInSegment, &numDecodedBits,
26
+                  &pHcr->decInOut.errorLog);
27
         }
28
         quantizedSpectralCoefficientsIdx++;
29
         if (quantizedSpectralCoefficientsIdx >= 1024) {
30
@@ -1195,8 +1195,8 @@
31
                   bs, pHcr->decInOut.bitstreamAnchor,
32
                   pQuantizedSpectralCoefficients
33
                       [quantizedSpectralCoefficientsIdx],
34
-                  pLeftStartOfSegment, pRemainingBitsInSegment,
35
-                  &numDecodedBits);
36
+                  pLeftStartOfSegment, pRemainingBitsInSegment, &numDecodedBits,
37
+                  &pHcr->decInOut.errorLog);
38
         }
39
         quantizedSpectralCoefficientsIdx++;
40
         if (quantizedSpectralCoefficientsIdx >= 1024) {
41
@@ -1386,7 +1386,7 @@
42
 static INT DecodeEscapeSequence(HANDLE_FDK_BITSTREAM bs, const INT bsAnchor,
43
                                 INT quantSpecCoef, INT *pLeftStartOfSegment,
44
                                 SCHAR *pRemainingBitsInSegment,
45
-                                int *pNumDecodedBits) {
46
+                                int *pNumDecodedBits, UINT *errorWord) {
47
   UINT i;
48
   INT sign;
49
   UINT escapeOnesCounter = 0;
50
@@ -1400,6 +1400,9 @@
51
                                        FROM_LEFT_TO_RIGHT);
52
     *pRemainingBitsInSegment -= 1;
53
     *pNumDecodedBits += 1;
54
+    if (*pRemainingBitsInSegment < 0) {
55
+      return Q_VALUE_INVALID;
56
+    }
57
 
58
     if (carryBit != 0) {
59
       escapeOnesCounter += 1;
60
@@ -1416,6 +1419,9 @@
61
                                        FROM_LEFT_TO_RIGHT);
62
     *pRemainingBitsInSegment -= 1;
63
     *pNumDecodedBits += 1;
64
+    if (*pRemainingBitsInSegment < 0) {
65
+      return Q_VALUE_INVALID;
66
+    }
67
 
68
     escape_word <<= 1;
69
     escape_word = escape_word | carryBit;
70
@@ -1423,8 +1429,12 @@
71
 
72
   sign = (quantSpecCoef >= 0) ? 1 : -1;
73
 
74
-  quantSpecCoef = sign * (((INT)1 << escapeOnesCounter) + escape_word);
75
-
76
+  if (escapeOnesCounter < 13) {
77
+    quantSpecCoef = sign * (((INT)1 << escapeOnesCounter) + escape_word);
78
+  } else {
79
+    *errorWord |= TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED;
80
+    quantSpecCoef = Q_VALUE_INVALID;
81
+  }
82
   return quantSpecCoef;
83
 }
84
 
85
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdec_hcrs.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdec_hcrs.cpp Changed
21
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -1324,6 +1324,10 @@
11
     /* count ones and store sum in escapePrefixUp */
12
     if (carryBit == 1) {
13
       escapePrefixUp += 1; /* update conter for ones */
14
+      if (escapePrefixUp > 8) {
15
+        pHcr->decInOut.errorLog |= STATE_ERROR_BODY_SIGN_ESC__ESC_PREFIX;
16
+        return BODY_SIGN_ESC__ESC_PREFIX;
17
+      }
18
 
19
       /* store updated counter in sideinfo of current codeword */
20
       pEscapeSequenceInfo[codewordOffset] &=
21
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdecoder.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdecoder.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -1225,6 +1225,8 @@
11
   pStreamInfo->drcProgRefLev =
12
       -1; /* set program reference level to not indicated */
13
   pStreamInfo->drcPresMode = -1; /* default: presentation mode not indicated */
14
+
15
+  pStreamInfo->outputLoudness = -1; /* default: no loudness metadata present */
16
 }
17
 
18
 /*!
19
@@ -1279,6 +1281,7 @@
20
   /* Set default frame delay */
21
   aacDecoder_drcSetParam(self->hDrcInfo, DRC_BS_DELAY,
22
                          CConcealment_GetDelay(&self->concealCommonData));
23
+  self->workBufferCore1 = (FIXP_DBL *)GetWorkBufferCore1();
24
 
25
   self->workBufferCore2 = GetWorkBufferCore2();
26
   if (self->workBufferCore2 == NULL) goto bail;
27
@@ -1303,7 +1306,8 @@
28
                                const int subStreamIndex) {
29
   int ch;
30
   int aacChannelOffset = 0, aacChannels = (8);
31
-  int numElements = (((8)) + (8)), elementOffset = 0;
32
+  int numElements = (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1),
33
+      elementOffset = 0;
34
 
35
   if (self == NULL) return;
36
 
37
@@ -1453,6 +1457,10 @@
38
     FreeDrcInfo(&self->hDrcInfo);
39
   }
40
 
41
+  if (self->workBufferCore1 != NULL) {
42
+    FreeWorkBufferCore1((CWorkBufferCore1 **)&self->workBufferCore1);
43
+  }
44
+
45
   /* Free WorkBufferCore2 */
46
   if (self->workBufferCore2 != NULL) {
47
     FreeWorkBufferCore2(&self->workBufferCore2);
48
@@ -1490,6 +1498,8 @@
49
   UCHAR downscaleFactor = self->downscaleFactor;
50
   UCHAR downscaleFactorInBS = self->downscaleFactorInBS;
51
 
52
+  self->aacOutDataHeadroom = (3);
53
+
54
   // set profile and check for supported aot
55
   // leave profile on default (=-1) for all other supported MPEG-4 aot's except
56
   // aot=2 (=AAC-LC)
57
@@ -1815,6 +1825,9 @@
58
       self->useLdQmfTimeAlign =
59
           asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign;
60
     }
61
+    if (self->sbrEnabled != asc->m_sbrPresentFlag) {
62
+      ascChanged = 1;
63
+    }
64
   }
65
 
66
   self->streamInfo.extAot = asc->m_extensionAudioObjectType;
67
@@ -1844,6 +1857,12 @@
68
           self->streamInfo.extSamplingRate / self->downscaleFactor;
69
     }
70
   }
71
+  if ((asc->m_aot == AOT_AAC_LC) && (asc->m_sbrPresentFlag == 1) &&
72
+      (asc->m_extensionSamplingFrequency > (2 * asc->m_samplingFrequency))) {
73
+    return AAC_DEC_UNSUPPORTED_SAMPLINGRATE; /* Core decoder supports at most a
74
+                                                1:2 upsampling for HE-AAC and
75
+                                                HE-AACv2 */
76
+  }
77
 
78
   /* --------- vcb11 ------------ */
79
   self->flags[streamIndex] |= (asc->m_vcb11Flag) ? AC_ER_VCB11 : 0;
80
@@ -1925,6 +1944,9 @@
81
           self->samplingRateInfo[0].samplingRate / self->downscaleFactor;
82
       self->streamInfo.aacSamplesPerFrame =
83
           asc->m_samplesPerFrame / self->downscaleFactor;
84
+      if (self->streamInfo.aacSampleRate <= 0) {
85
+        return AAC_DEC_UNSUPPORTED_SAMPLINGRATE;
86
+      }
87
     }
88
   }
89
 
90
@@ -2359,6 +2381,13 @@
91
       goto bail;
92
   }
93
 
94
+  if (*configChanged) {
95
+    if (asc->m_aot == AOT_USAC) {
96
+      self->hDrcInfo->enable = 0;
97
+      self->hDrcInfo->progRefLevelPresent = 0;
98
+    }
99
+  }
100
+
101
   if (asc->m_aot == AOT_USAC) {
102
     pcmLimiter_SetAttack(self->hLimiter, (5));
103
     pcmLimiter_SetThreshold(self->hLimiter, FL2FXCONST_DBL(0.89125094f));
104
@@ -2372,7 +2401,7 @@
105
 }
106
 
107
 LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
108
-    HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
109
+    HANDLE_AACDECODER self, const UINT flags, PCM_DEC *pTimeData,
110
     const INT timeDataSize, const int timeDataChannelOffset) {
111
   AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
112
 
113
@@ -3148,11 +3177,6 @@
114
       FDKmemcpy(drcChMap, self->chMapping, (8) * sizeof(UCHAR));
115
     }
116
 
117
-    /* Turn on/off DRC modules level normalization in digital domain depending
118
-     * on the limiter status. */
119
-    aacDecoder_drcSetParam(self->hDrcInfo, APPLY_NORMALIZATION,
120
-                           (self->limiterEnableCurr) ? 0 : 1);
121
-
122
     /* deactivate legacy DRC in case uniDrc is active, i.e. uniDrc payload is
123
      * present and one of DRC or Loudness Normalization is switched on */
124
     aacDecoder_drcSetParam(
125
@@ -3165,9 +3189,15 @@
126
         self->hDrcInfo, bs, self->pAacDecoderStaticChannelInfo,
127
         pce->ElementInstanceTag, drcChMap, aacChannels);
128
     if (mapped > 0) {
129
-      /* If at least one DRC thread has been mapped to a channel threre was DRC
130
-       * data in the bitstream. */
131
-      self->flags[streamIndex] |= AC_DRC_PRESENT;
132
+      if (!(self->flags[streamIndex] & (AC_USAC | AC_RSV603DA))) {
133
+        /* If at least one DRC thread has been mapped to a channel there was DRC
134
+         * data in the bitstream. */
135
+        self->flags[streamIndex] |= AC_DRC_PRESENT;
136
+      } else {
137
+        self->hDrcInfo->enable = 0;
138
+        self->hDrcInfo->progRefLevelPresent = 0;
139
+        ErrorStatus = AAC_DEC_UNSUPPORTED_FORMAT;
140
+      }
141
     }
142
 
143
     /* Create a reverse mapping table */
144
@@ -3297,9 +3327,11 @@
145
                 &pAacDecoderStaticChannelInfo->drcData);
146
           }
147
         }
148
+
149
         /* The DRC module demands to be called with the gain field holding the
150
          * gain scale. */
151
-        self->extGain[0] = (FIXP_DBL)TDL_GAIN_SCALING;
152
+        self->extGain[0] = (FIXP_DBL)AACDEC_DRC_GAIN_SCALING;
153
+
154
         /* DRC processing */
155
         aacDecoder_drcApply(
156
             self->hDrcInfo, self->hSbrDecoder, pAacDecoderChannelInfo,
157
@@ -3315,7 +3347,7 @@
158
         if (self->flushStatus && (self->flushCnt > 0) &&
159
             !(flags & AACDEC_CONCEAL)) {
160
           FDKmemclear(pTimeData + offset,
161
-                      sizeof(FIXP_PCM) * self->streamInfo.aacSamplesPerFrame);
162
+                      sizeof(PCM_DEC) * self->streamInfo.aacSamplesPerFrame);
163
         } else
164
           switch (pAacDecoderChannelInfo->renderMode) {
165
             case AACDEC_RENDER_IMDCT:
166
@@ -3327,7 +3359,7 @@
167
                    !frameOk_butConceal),
168
                   pAacDecoderChannelInfo->pComStaticData->pWorkBufferCore1
169
                       ->mdctOutTemp,
170
-                  self->elFlags[el], elCh);
171
+                  self->aacOutDataHeadroom, self->elFlags[el], elCh);
172
 
173
               self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
174
               break;
175
@@ -3348,7 +3380,7 @@
176
                   &self->samplingRateInfo[streamIndex],
177
                   (self->frameOK && !(flags & AACDEC_CONCEAL) &&
178
                    !frameOk_butConceal),
179
-                  flags, self->flags[streamIndex]);
180
+                  self->aacOutDataHeadroom, flags, self->flags[streamIndex]);
181
 
182
               self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
183
               break;
184
@@ -3360,7 +3392,8 @@
185
         if (!CConceal_TDFading_Applied[c]) {
186
           CConceal_TDFading_Applied[c] = CConcealment_TDFading(
187
               self->streamInfo.aacSamplesPerFrame,
188
-              &self->pAacDecoderStaticChannelInfo[c], pTimeData + offset, 0);
189
+              &self->pAacDecoderStaticChannelInfo[c], self->aacOutDataHeadroom,
190
+              pTimeData + offset, 0);
191
           if (c + 1 < (8) && c < aacChannels - 1) {
192
             /* update next TDNoise Seed to avoid muting in case of Parametric
193
              * Stereo */
194
@@ -3382,22 +3415,17 @@
195
       if ((aacChannels == 2) && bsPseudoLr) {
196
         int i, offset2;
197
         const FIXP_SGL invSqrt2 = FL2FXCONST_SGL(0.707106781186547f);
198
-        FIXP_PCM *pTD = pTimeData;
199
+        PCM_DEC *pTD = pTimeData;
200
 
201
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdecoder.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdecoder.h Changed
50
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -191,6 +191,9 @@
11
   INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved).
12
                           */
13
 
14
+  INT aacOutDataHeadroom; /*!< Headroom of the output time signal to prevent
15
+                             clipping */
16
+
17
   HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */
18
 
19
   SamplingRateInfo
20
@@ -235,6 +238,7 @@
21
   CAacDecoderStaticChannelInfo
22
       *pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */
23
 
24
+  FIXP_DBL *workBufferCore1;
25
   FIXP_DBL *workBufferCore2;
26
   PCM_DEC *pTimeData2;
27
   INT timeData2Size;
28
@@ -311,11 +315,10 @@
29
   UCHAR limiterEnableUser; /*!< The limiter configuration requested by the
30
                               library user */
31
   UCHAR limiterEnableCurr; /*!< The current limiter configuration.         */
32
+
33
   FIXP_DBL extGain[1]; /*!< Gain that must be applied to the output signal. */
34
   UINT extGainDelay;   /*!< Delay that must be accounted for extGain. */
35
 
36
-  INT_PCM pcmOutputBuffer[(8) * (1024 * 2)];
37
-
38
   HANDLE_DRC_DECODER hUniDrcDecoder;
39
   UCHAR multibandDrcPresent;
40
   UCHAR numTimeSlots;
41
@@ -427,7 +430,7 @@
42
   \return  error status
43
 */
44
 LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
45
-    HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
46
+    HANDLE_AACDECODER self, const UINT flags, PCM_DEC *pTimeData,
47
     const INT timeDataSize, const int timeDataChannelOffset);
48
 
49
 /* Free config dependent AAC memory */
50
fdk-aac-2.0.1.tar.gz/libAACdec/src/aacdecoder_lib.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/aacdecoder_lib.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -119,10 +119,10 @@
11
 
12
 /* Decoder library info */
13
 #define AACDECODER_LIB_VL0 3
14
-#define AACDECODER_LIB_VL1 0
15
+#define AACDECODER_LIB_VL1 2
16
 #define AACDECODER_LIB_VL2 0
17
 #define AACDECODER_LIB_TITLE "AAC Decoder Lib"
18
-#ifdef __ANDROID__
19
+#ifdef SUPPRESS_BUILD_DATE_INFO
20
 #define AACDECODER_LIB_BUILD_DATE ""
21
 #define AACDECODER_LIB_BUILD_TIME ""
22
 #else
23
@@ -823,11 +823,15 @@
24
     case AAC_DRC_ATTENUATION_FACTOR:
25
       /* DRC compression factor (where 0 is no and 127 is max compression) */
26
       errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_CUT_SCALE, value);
27
+      uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_COMPRESS,
28
+                                      value * (FL2FXCONST_DBL(0.5f / 127.0f)));
29
       break;
30
 
31
     case AAC_DRC_BOOST_FACTOR:
32
       /* DRC boost factor (where 0 is no and 127 is max boost) */
33
       errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_BOOST_SCALE, value);
34
+      uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_BOOST,
35
+                                      value * (FL2FXCONST_DBL(0.5f / 127.0f)));
36
       break;
37
 
38
     case AAC_DRC_REFERENCE_LEVEL:
39
@@ -871,6 +875,11 @@
40
       uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_EFFECT_TYPE,
41
                                       (FIXP_DBL)value);
42
       break;
43
+    case AAC_UNIDRC_ALBUM_MODE:
44
+      uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_ALBUM_MODE,
45
+                                      (FIXP_DBL)value);
46
+      break;
47
+
48
     case AAC_TPDEC_CLEAR_BUFFER:
49
       errTp = transportDec_SetParam(hTpDec, TPDEC_PARAM_RESET, 1);
50
       self->streamInfo.numLostAccessUnits = 0;
51
@@ -1124,35 +1133,31 @@
52
   return n;
53
 }
54
 
55
-LINKSPEC_CPP AAC_DECODER_ERROR
56
-aacDecoder_DecodeFrame(HANDLE_AACDECODER self, INT_PCM *pTimeData_extern,
57
-                       const INT timeDataSize_extern, const UINT flags) {
58
+LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_DecodeFrame(HANDLE_AACDECODER self,
59
+                                                      INT_PCM *pTimeData,
60
+                                                      const INT timeDataSize,
61
+                                                      const UINT flags) {
62
   AAC_DECODER_ERROR ErrorStatus;
63
   INT layer;
64
   INT nBits;
65
+  INT timeData2Size;
66
+  INT timeData3Size;
67
+  INT timeDataHeadroom;
68
   HANDLE_FDK_BITSTREAM hBs;
69
   int fTpInterruption = 0; /* Transport originated interruption detection. */
70
   int fTpConceal = 0;      /* Transport originated concealment. */
71
-  INT_PCM *pTimeData = NULL;
72
-  INT timeDataSize = 0;
73
   UINT accessUnit = 0;
74
   UINT numAccessUnits = 1;
75
   UINT numPrerollAU = 0;
76
-  int fEndAuNotAdjusted = 0;  /* The end of the access unit was not adjusted */
77
-  int applyCrossfade = 1;     /* flag indicates if flushing was possible */
78
-  FIXP_PCM *pTimeDataFixpPcm; /* Signal buffer for decoding process before PCM
79
-                                 processing */
80
-  INT timeDataFixpPcmSize;
81
-  PCM_DEC *pTimeDataPcmPost; /* Signal buffer for PCM post-processing */
82
-  INT timeDataPcmPostSize;
83
+  int fEndAuNotAdjusted = 0; /* The end of the access unit was not adjusted */
84
+  int applyCrossfade = 1;    /* flag indicates if flushing was possible */
85
+  PCM_DEC *pTimeData2;
86
+  PCM_AAC *pTimeData3;
87
 
88
   if (self == NULL) {
89
     return AAC_DEC_INVALID_HANDLE;
90
   }
91
 
92
-  pTimeData = self->pcmOutputBuffer;
93
-  timeDataSize = sizeof(self->pcmOutputBuffer) / sizeof(*self->pcmOutputBuffer);
94
-
95
   if (flags & AACDEC_INTR) {
96
     self->streamInfo.numLostAccessUnits = 0;
97
   }
98
@@ -1262,9 +1267,9 @@
99
     }
100
 
101
     /* Signal bit stream interruption to other modules if required. */
102
-    if (fTpInterruption || (flags & AACDEC_INTR)) {
103
+    if (fTpInterruption || ((flags & AACDEC_INTR) && (accessUnit == 0))) {
104
       aacDecoder_SignalInterruption(self);
105
-      if (!(flags & AACDEC_INTR)) {
106
+      if (!((flags & AACDEC_INTR) && (accessUnit == 0))) {
107
         ErrorStatus = AAC_DEC_TRANSPORT_SYNC_ERROR;
108
         goto bail;
109
       }
110
@@ -1308,19 +1313,23 @@
111
       /* Use limiter configuration as requested. */
112
       self->limiterEnableCurr = self->limiterEnableUser;
113
     }
114
-    /* reset limiter gain on a per frame basis */
115
-    self->extGain[0] = FL2FXCONST_DBL(1.0f / (float)(1 << TDL_GAIN_SCALING));
116
 
117
-    pTimeDataFixpPcm = pTimeData;
118
-    timeDataFixpPcmSize = timeDataSize;
119
+    /* reset DRC level normalization gain on a per frame basis */
120
+    self->extGain[0] = AACDEC_DRC_GAIN_INIT_VALUE;
121
+
122
+    pTimeData2 = self->pTimeData2;
123
+    timeData2Size = self->timeData2Size / sizeof(PCM_DEC);
124
+    pTimeData3 = (PCM_AAC *)self->pTimeData2;
125
+    timeData3Size = self->timeData2Size / sizeof(PCM_AAC);
126
 
127
     ErrorStatus = CAacDecoder_DecodeFrame(
128
         self,
129
         flags | (fTpConceal ? AACDEC_CONCEAL : 0) |
130
             ((self->flushStatus && !(flags & AACDEC_CONCEAL)) ? AACDEC_FLUSH
131
                                                               : 0),
132
-        pTimeDataFixpPcm + 0, timeDataFixpPcmSize,
133
-        self->streamInfo.aacSamplesPerFrame + 0);
134
+        pTimeData2 + 0, timeData2Size, self->streamInfo.aacSamplesPerFrame + 0);
135
+
136
+    timeDataHeadroom = self->aacOutDataHeadroom;
137
 
138
     /* if flushing for USAC DASH IPF was not possible go on with decoding
139
      * preroll */
140
@@ -1345,7 +1354,7 @@
141
         }
142
       }
143
 
144
-      /* If the current pTimeDataFixpPcm does not contain a valid signal, there
145
+      /* If the current pTimeData2 does not contain a valid signal, there
146
        * nothing else we can do, so bail. */
147
       if (!IS_OUTPUT_VALID(ErrorStatus)) {
148
         goto bail;
149
@@ -1359,10 +1368,10 @@
150
       self->streamInfo.numChannels = self->streamInfo.aacNumChannels;
151
 
152
       {
153
-        FDK_Delay_Apply(&self->usacResidualDelay,
154
-                        pTimeDataFixpPcm +
155
-                            1 * (self->streamInfo.aacSamplesPerFrame + 0) + 0,
156
-                        self->streamInfo.frameSize, 0);
157
+        FDK_Delay_Apply(
158
+            &self->usacResidualDelay,
159
+            pTimeData2 + 1 * (self->streamInfo.aacSamplesPerFrame + 0) + 0,
160
+            self->streamInfo.frameSize, 0);
161
       }
162
 
163
       /* Setting of internal MPS state; may be reset in CAacDecoder_SyncQmfMode
164
@@ -1409,8 +1418,6 @@
165
         }
166
       }
167
 
168
-      self->qmfDomain.globalConf.TDinput = pTimeData;
169
-
170
       switch (FDK_QmfDomain_Configure(&self->qmfDomain)) {
171
         default:
172
         case QMF_DOMAIN_INIT_ERROR:
173
@@ -1467,18 +1474,18 @@
174
         sbrDecoder_SetParam(self->hSbrDecoder, SBR_SKIP_QMF,
175
                             (self->mpsEnableCurr) ? 2 : 0);
176
 
177
-        INT_PCM *input;
178
-        input = (INT_PCM *)self->workBufferCore2;
179
-        FDKmemcpy(input, pTimeData,
180
-                  sizeof(INT_PCM) * (self->streamInfo.numChannels) *
181
+        PCM_AAC *input;
182
+        input = (PCM_AAC *)self->workBufferCore2;
183
+        FDKmemcpy(input, pTimeData3,
184
+                  sizeof(PCM_AAC) * (self->streamInfo.numChannels) *
185
                       (self->streamInfo.frameSize));
186
 
187
         /* apply SBR processing */
188
-        sbrError = sbrDecoder_Apply(self->hSbrDecoder, input, pTimeData,
189
-                                    timeDataSize, &self->streamInfo.numChannels,
190
-                                    &self->streamInfo.sampleRate,
191
-                                    &self->mapDescr, self->chMapIndex,
192
-                                    self->frameOK, &self->psPossible);
193
+        sbrError = sbrDecoder_Apply(
194
+            self->hSbrDecoder, input, pTimeData3, timeData3Size,
195
+            &self->streamInfo.numChannels, &self->streamInfo.sampleRate,
196
+            &self->mapDescr, self->chMapIndex, self->frameOK, &self->psPossible,
197
+            self->aacOutDataHeadroom, &timeDataHeadroom);
198
 
199
         if (sbrError == SBRDEC_OK) {
200
           /* Update data in streaminfo structure. Assume that the SBR upsampling
201
fdk-aac-2.0.1.tar.gz/libAACdec/src/block.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/block.cpp Changed
49
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -1015,9 +1015,9 @@
11
 
12
 void CBlock_FrequencyToTime(
13
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
14
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
15
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC outSamples[],
16
     const SHORT frameLen, const int frameOk, FIXP_DBL *pWorkBuffer1,
17
-    UINT elFlags, INT elCh) {
18
+    const INT aacOutDataHeadroom, UINT elFlags, INT elCh) {
19
   int fr, fl, tl, nSpec;
20
 
21
 #if defined(FDK_ASSERT_ENABLE)
22
@@ -1213,6 +1213,7 @@
23
         bass_pf_1sf_delay(p2_synth, pitch, pit_gain, frameLen,
24
                           (LpdSfd + 2) * L_SUBFR + BPF_SFD * L_SUBFR,
25
                           frameLen - (LpdSfd + 4) * L_SUBFR, outSamples,
26
+                          aacOutDataHeadroom,
27
                           pAacDecoderStaticChannelInfo->mem_bpf);
28
       }
29
 
30
@@ -1236,7 +1237,8 @@
31
                          ? MLT_FLAG_CURR_ALIAS_SYMMETRY
32
                          : 0);
33
 
34
-      scaleValuesSaturate(outSamples, tmp, frameLen, MDCT_OUT_HEADROOM);
35
+      scaleValuesSaturate(outSamples, tmp, frameLen,
36
+                          MDCT_OUT_HEADROOM - aacOutDataHeadroom);
37
     }
38
   }
39
 
40
@@ -1251,7 +1253,7 @@
41
 #include "ldfiltbank.h"
42
 void CBlock_FrequencyToTimeLowDelay(
43
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
44
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
45
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC outSamples[],
46
     const short frameLen) {
47
   InvMdctTransformLowDelay_fdk(
48
       SPEC_LONG(pAacDecoderChannelInfo->pSpectralCoefficient),
49
fdk-aac-2.0.1.tar.gz/libAACdec/src/block.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/block.h Changed
30
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -218,16 +218,16 @@
11
  */
12
 void CBlock_FrequencyToTime(
13
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
14
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
15
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC outSamples[],
16
     const SHORT frameLen, const int frameOk, FIXP_DBL *pWorkBuffer1,
17
-    UINT elFlags, INT elCh);
18
+    const INT aacOutDataHeadroom, UINT elFlags, INT elCh);
19
 
20
 /**
21
  * \brief Transform double lapped MDCT (AAC-ELD) spectral data into time domain.
22
  */
23
 void CBlock_FrequencyToTimeLowDelay(
24
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
25
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
26
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC outSamples[],
27
     const short frameLen);
28
 
29
 AAC_DECODER_ERROR CBlock_InverseQuantizeSpectralData(
30
fdk-aac-2.0.1.tar.gz/libAACdec/src/conceal.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/conceal.cpp Changed
152
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -226,7 +226,7 @@
11
 
12
 /* TimeDomainFading */
13
 static void CConcealment_TDFadePcmAtt(int start, int len, FIXP_DBL fadeStart,
14
-                                      FIXP_DBL fadeStop, FIXP_PCM *pcmdata);
15
+                                      FIXP_DBL fadeStop, PCM_DEC *pcmdata);
16
 static void CConcealment_TDFadeFillFadingStations(FIXP_DBL *fadingStations,
17
                                                   int *fadingSteps,
18
                                                   FIXP_DBL fadeStop,
19
@@ -242,7 +242,9 @@
20
 
21
 static int CConcealment_TDNoise_Random(ULONG *seed);
22
 static void CConcealment_TDNoise_Apply(CConcealmentInfo *const pConcealmentInfo,
23
-                                       const int len, FIXP_PCM *const pcmdata);
24
+                                       const int len,
25
+                                       const INT aacOutDataHeadroom,
26
+                                       PCM_DEC *const pcmdata);
27
 
28
 static BLOCK_TYPE CConcealment_GetWinSeq(int prevWinSeq) {
29
   BLOCK_TYPE newWinSeq = BLOCK_LONG;
30
@@ -1228,7 +1230,6 @@
31
   int sfb, line = 0;
32
   int fac_shift;
33
   int fac_mod;
34
-  FIXP_DBL accu;
35
 
36
   for (sfb = 0; sfb < sfbCnt; sfb++) {
37
     fac_shift =
38
@@ -1236,15 +1237,11 @@
39
     fac_mod = fac_shift & 3;
40
     fac_shift = (fac_shift >> 2) + 1;
41
     fac_shift += *pSpecScalePrv - fixMax(*pSpecScalePrv, *pSpecScaleAct);
42
+    fac_shift = fMax(fMin(fac_shift, DFRACT_BITS - 1), -(DFRACT_BITS - 1));
43
 
44
     for (; line < pSfbOffset[sfb + 1]; line++) {
45
-      accu = fMult(*(spectrum + line), facMod4Table[fac_mod]);
46
-      if (fac_shift < 0) {
47
-        accu >>= -fac_shift;
48
-      } else {
49
-        accu <<= fac_shift;
50
-      }
51
-      *(spectrum + line) = accu;
52
+      FIXP_DBL accu = fMult(*(spectrum + line), facMod4Table[fac_mod]);
53
+      *(spectrum + line) = scaleValue(accu, fac_shift);
54
     }
55
   }
56
   *pSpecScaleOut = fixMax(*pSpecScalePrv, *pSpecScaleAct);
57
@@ -1618,7 +1615,7 @@
58
     }
59
 
60
     if (packedSign & 0x1) {
61
-      spec[i] = -spec[i];
62
+      spec[i] = -fMax(spec[i], (FIXP_DBL)(MINVAL_DBL + 1));
63
     }
64
     packedSign >>= 1;
65
 
66
@@ -1849,7 +1846,7 @@
67
 
68
 INT CConcealment_TDFading(
69
     int len, CAacDecoderStaticChannelInfo **ppAacDecoderStaticChannelInfo,
70
-    FIXP_PCM *pcmdata, FIXP_PCM *pcmdata_1) {
71
+    const INT aacOutDataHeadroom, PCM_DEC *pcmdata, PCM_DEC *pcmdata_1) {
72
   /*
73
   Do the fading in Time domain based on concealment states and core mode
74
   */
75
@@ -1962,7 +1959,8 @@
76
       start += len;
77
     }
78
   }
79
-  CConcealment_TDNoise_Apply(pConcealmentInfo, len, pcmdata);
80
+  CConcealment_TDNoise_Apply(pConcealmentInfo, len, aacOutDataHeadroom,
81
+                             pcmdata);
82
 
83
   /* Save end-of-frame attenuation and fading type */
84
   pConcealmentInfo->lastFadingType = fadingType;
85
@@ -1974,12 +1972,11 @@
86
 
87
 /* attenuate pcmdata in Time Domain Fading process */
88
 static void CConcealment_TDFadePcmAtt(int start, int len, FIXP_DBL fadeStart,
89
-                                      FIXP_DBL fadeStop, FIXP_PCM *pcmdata) {
90
+                                      FIXP_DBL fadeStop, PCM_DEC *pcmdata) {
91
   int i;
92
   FIXP_DBL dStep;
93
   FIXP_DBL dGain;
94
   FIXP_DBL dGain_apply;
95
-  int bitshift = (DFRACT_BITS - SAMPLE_BITS);
96
 
97
   /* set start energy */
98
   dGain = fadeStart;
99
@@ -1992,7 +1989,7 @@
100
      */
101
     dGain_apply = fMax((FIXP_DBL)0, dGain);
102
     /* finally, attenuate samples */
103
-    pcmdata[i] = (FIXP_PCM)((fMult(pcmdata[i], (dGain_apply))) >> bitshift);
104
+    pcmdata[i] = FIXP_DBL2PCM_DEC(fMult(pcmdata[i], dGain_apply));
105
   }
106
 }
107
 
108
@@ -2055,9 +2052,11 @@
109
 }
110
 
111
 static void CConcealment_TDNoise_Apply(CConcealmentInfo *const pConcealmentInfo,
112
-                                       const int len, FIXP_PCM *const pcmdata) {
113
-  FIXP_PCM *states = pConcealmentInfo->TDNoiseStates;
114
-  FIXP_PCM noiseVal;
115
+                                       const int len,
116
+                                       const INT aacOutDataHeadroom,
117
+                                       PCM_DEC *const pcmdata) {
118
+  PCM_DEC *states = pConcealmentInfo->TDNoiseStates;
119
+  PCM_DEC noiseVal;
120
   FIXP_DBL noiseValLong;
121
   FIXP_SGL *coef = pConcealmentInfo->TDNoiseCoef;
122
   FIXP_DBL TDNoiseAtt;
123
@@ -2075,18 +2074,20 @@
124
       /* create filtered noise */
125
       states[2] = states[1];
126
       states[1] = states[0];
127
-      states[0] = ((FIXP_PCM)CConcealment_TDNoise_Random(&seed));
128
+      states[0] =
129
+          FIXP_DBL2PCM_DEC((FIXP_DBL)CConcealment_TDNoise_Random(&seed));
130
       noiseValLong = fMult(states[0], coef[0]) + fMult(states[1], coef[1]) +
131
                      fMult(states[2], coef[2]);
132
-      noiseVal = FX_DBL2FX_PCM(fMult(noiseValLong, TDNoiseAtt));
133
+      noiseVal = FIXP_DBL2PCM_DEC(fMult(noiseValLong, TDNoiseAtt) >>
134
+                                  aacOutDataHeadroom);
135
 
136
       /* add filtered noise - check for clipping, before */
137
-      if (noiseVal > (FIXP_PCM)0 &&
138
-          pcmdata[ii] > (FIXP_PCM)MAXVAL_FIXP_PCM - noiseVal) {
139
-        noiseVal = noiseVal * (FIXP_PCM)-1;
140
-      } else if (noiseVal < (FIXP_PCM)0 &&
141
-                 pcmdata[ii] < (FIXP_PCM)MINVAL_FIXP_PCM - noiseVal) {
142
-        noiseVal = noiseVal * (FIXP_PCM)-1;
143
+      if (noiseVal > (PCM_DEC)0 &&
144
+          pcmdata[ii] > (PCM_DEC)MAXVAL_PCM_DEC - noiseVal) {
145
+        noiseVal = noiseVal * (PCM_DEC)-1;
146
+      } else if (noiseVal < (PCM_DEC)0 &&
147
+                 pcmdata[ii] < (PCM_DEC)MINVAL_PCM_DEC - noiseVal) {
148
+        noiseVal = noiseVal * (PCM_DEC)-1;
149
       }
150
 
151
       pcmdata[ii] += noiseVal;
152
fdk-aac-2.0.1.tar.gz/libAACdec/src/conceal.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/conceal.h Changed
18
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -147,6 +147,6 @@
11
 
12
 INT CConcealment_TDFading(
13
     int len, CAacDecoderStaticChannelInfo **ppAacDecoderStaticChannelInfo,
14
-    FIXP_PCM *pcmdata, FIXP_PCM *pcmdata_1);
15
+    const INT aacOutDataHeadroom, PCM_DEC *pcmdata, PCM_DEC *pcmdata_1);
16
 
17
 #endif /* #ifndef CONCEAL_H */
18
fdk-aac-2.0.1.tar.gz/libAACdec/src/conceal_types.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/conceal_types.h Changed
19
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -194,7 +194,7 @@
11
   FIXP_DBL last_tcx_gain;
12
   INT last_tcx_gain_e;
13
   ULONG TDNoiseSeed;
14
-  FIXP_PCM TDNoiseStates[3];
15
+  PCM_DEC TDNoiseStates[3];
16
   FIXP_SGL TDNoiseCoef[3];
17
   FIXP_SGL TDNoiseAtt;
18
 
19
fdk-aac-2.0.1.tar.gz/libAACdec/src/ldfiltbank.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/ldfiltbank.cpp Changed
138
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -112,17 +112,20 @@
11
 #if defined(__arm__)
12
 #endif
13
 
14
-static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
15
+static void multE2_DinvF_fdk(PCM_DEC *output, FIXP_DBL *x, const FIXP_WTB *fb,
16
                              FIXP_DBL *z, const int N) {
17
   int i;
18
 
19
-  /*  scale for FIXP_DBL -> INT_PCM conversion. */
20
-  const int scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM;
21
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
22
+  /*  scale for FIXP_DBL -> PCM_DEC conversion:       */
23
+  const int scale = (DFRACT_BITS - PCM_OUT_BITS) - LDFB_HEADROOM + (3);
24
+
25
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
26
   FIXP_DBL rnd_val_wts0 = (FIXP_DBL)0;
27
   FIXP_DBL rnd_val_wts1 = (FIXP_DBL)0;
28
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - WTS0 - 1) > 0)
29
   if (-WTS0 - 1 + scale)
30
     rnd_val_wts0 = (FIXP_DBL)(1 << (-WTS0 - 1 + scale - 1));
31
+#endif
32
   if (-WTS1 - 1 + scale)
33
     rnd_val_wts1 = (FIXP_DBL)(1 << (-WTS1 - 1 + scale - 1));
34
 #endif
35
@@ -131,24 +134,26 @@
36
     FIXP_DBL z0, z2, tmp;
37
 
38
     z2 = x[N / 2 + i];
39
-    z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
40
+    z0 = fAddSaturate(z2,
41
+                      (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)));
42
 
43
-    z[N / 2 + i] = x[N / 2 - 1 - i] +
44
-                   (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
45
+    z[N / 2 + i] = fAddSaturate(
46
+        x[N / 2 - 1 - i],
47
+        (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1)));
48
 
49
     tmp = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
50
            fMultDiv2(z[i], fb[N + N / 2 + i]));
51
 
52
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
53
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
54
     FDK_ASSERT((-WTS1 - 1 + scale) >= 0);
55
     FDK_ASSERT(tmp <= ((FIXP_DBL)0x7FFFFFFF -
56
                        rnd_val_wts1)); /* rounding must not cause overflow */
57
-    output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
58
+    output[(N * 3 / 4 - 1 - i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
59
         tmp + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
60
 #else
61
     FDK_ASSERT((WTS1 + 1 - scale) >= 0);
62
     output[(N * 3 / 4 - 1 - i)] =
63
-        (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
64
+        (PCM_DEC)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
65
 #endif
66
 
67
     z[i] = z0;
68
@@ -159,32 +164,34 @@
69
     FIXP_DBL z0, z2, tmp0, tmp1;
70
 
71
     z2 = x[N / 2 + i];
72
-    z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
73
+    z0 = fAddSaturate(z2,
74
+                      (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)));
75
 
76
-    z[N / 2 + i] = x[N / 2 - 1 - i] +
77
-                   (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
78
+    z[N / 2 + i] = fAddSaturate(
79
+        x[N / 2 - 1 - i],
80
+        (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1)));
81
 
82
     tmp0 = (fMultDiv2(z[N / 2 + i], fb[N / 2 - 1 - i]) +
83
             fMultDiv2(z[i], fb[N / 2 + i]));
84
     tmp1 = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
85
             fMultDiv2(z[i], fb[N + N / 2 + i]));
86
 
87
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
88
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
89
     FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
90
     FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
91
                         rnd_val_wts0)); /* rounding must not cause overflow */
92
     FDK_ASSERT(tmp1 <= ((FIXP_DBL)0x7FFFFFFF -
93
                         rnd_val_wts1)); /* rounding must not cause overflow */
94
-    output[(i - N / 4)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
95
+    output[(i - N / 4)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
96
         tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
97
-    output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
98
+    output[(N * 3 / 4 - 1 - i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
99
         tmp1 + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
100
 #else
101
     FDK_ASSERT((WTS0 + 1 - scale) >= 0);
102
     output[(i - N / 4)] =
103
-        (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
104
+        (PCM_DEC)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
105
     output[(N * 3 / 4 - 1 - i)] =
106
-        (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
107
+        (PCM_DEC)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
108
 #endif
109
     z[i] = z0;
110
     z[N + i] = z2;
111
@@ -194,22 +201,22 @@
112
   for (i = 0; i < N / 4; i++) {
113
     FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N / 2 + i]);
114
 
115
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
116
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
117
     FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
118
     FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
119
                         rnd_val_wts0)); /* rounding must not cause overflow */
120
-    output[(N * 3 / 4 + i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
121
+    output[(N * 3 / 4 + i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
122
         tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
123
 #else
124
     FDK_ASSERT((WTS0 + 1 - scale) >= 0);
125
     output[(N * 3 / 4 + i)] =
126
-        (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
127
+        (PCM_DEC)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
128
 #endif
129
   }
130
 }
131
 
132
 int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctData, const int mdctData_e,
133
-                                 FIXP_PCM *output, FIXP_DBL *fs_buffer,
134
+                                 PCM_DEC *output, FIXP_DBL *fs_buffer,
135
                                  const int N) {
136
   const FIXP_WTB *coef;
137
   FIXP_DBL gain = (FIXP_DBL)0;
138
fdk-aac-2.0.1.tar.gz/libAACdec/src/ldfiltbank.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/ldfiltbank.h Changed
22
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -104,9 +104,10 @@
11
 #define LDFILTBANK_H
12
 
13
 #include "common_fix.h"
14
+#include "aac_rom.h"
15
 
16
 int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctdata_m, const int mdctdata_e,
17
-                                 FIXP_PCM *mdctOut, FIXP_DBL *fs_buffer,
18
+                                 PCM_DEC *mdctOut, FIXP_DBL *fs_buffer,
19
                                  const int frameLength);
20
 
21
 #endif
22
fdk-aac-2.0.1.tar.gz/libAACdec/src/stereo.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/stereo.cpp Changed
125
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -807,19 +807,17 @@
11
                   for (int i = 0; i < windowLen; i++) {
12
                     dmx_re_prev[i] =
13
                         ((staticSpectralCoeffsL[index_offset + i] >>
14
-                          srLeftChan) +
15
+                          fMin(DFRACT_BITS - 1, srLeftChan + 1)) +
16
                          (staticSpectralCoeffsR[index_offset + i] >>
17
-                          srRightChan)) >>
18
-                        1;
19
+                          fMin(DFRACT_BITS - 1, srRightChan + 1)));
20
                   }
21
                 } else {
22
                   for (int i = 0; i < windowLen; i++) {
23
                     dmx_re_prev[i] =
24
                         ((staticSpectralCoeffsL[index_offset + i] >>
25
-                          srLeftChan) -
26
+                          fMin(DFRACT_BITS - 1, srLeftChan + 1)) -
27
                          (staticSpectralCoeffsR[index_offset + i] >>
28
-                          srRightChan)) >>
29
-                        1;
30
+                          fMin(DFRACT_BITS - 1, srRightChan + 1)));
31
                   }
32
                 }
33
               }
34
@@ -854,12 +852,13 @@
35
           if (window == 0) {
36
             if (dmx_re_prev_e < frameMaxScale) {
37
               if (mainband_flag == 0) {
38
-                scaleValues(dmx_re_prev, store_dmx_re_prev, windowLen,
39
-                            -(frameMaxScale - dmx_re_prev_e));
40
+                scaleValues(
41
+                    dmx_re_prev, store_dmx_re_prev, windowLen,
42
+                    -fMin(DFRACT_BITS - 1, (frameMaxScale - dmx_re_prev_e)));
43
               } else {
44
-                for (int i = 0; i < windowLen; i++) {
45
-                  dmx_re_prev[i] >>= (frameMaxScale - dmx_re_prev_e);
46
-                }
47
+                scaleValues(
48
+                    dmx_re_prev, windowLen,
49
+                    -fMin(DFRACT_BITS - 1, (frameMaxScale - dmx_re_prev_e)));
50
               }
51
             } else {
52
               if (mainband_flag == 0) {
53
@@ -873,10 +872,9 @@
54
             FDK_ASSERT(pAacDecoderChannelInfo[L]->icsInfo.WindowSequence ==
55
                        BLOCK_SHORT);
56
             if (specScaleL[window - 1] < frameMaxScale) {
57
-              for (int i = 0; i < windowLen; i++) {
58
-                dmx_re[windowLen * (window - 1) + i] >>=
59
-                    (frameMaxScale - specScaleL[window - 1]);
60
-              }
61
+              scaleValues(&dmx_re[windowLen * (window - 1)], windowLen,
62
+                          -fMin(DFRACT_BITS - 1,
63
+                                (frameMaxScale - specScaleL[window - 1])));
64
             } else {
65
               specScaleL[window] = specScaleL[window - 1];
66
               specScaleR[window] = specScaleR[window - 1];
67
@@ -991,7 +989,7 @@
68
         }   /* if ( pJointStereoData->complex_coef == 1 ) */
69
 
70
         /* 4. upmix process */
71
-        INT pred_dir = cplxPredictionData->pred_dir ? -1 : 1;
72
+        LONG pred_dir = cplxPredictionData->pred_dir ? -1 : 1;
73
         /* 0.1 in Q-3.34 */
74
         const FIXP_DBL pointOne = 0x66666666; /* 0.8 */
75
         /* Shift value for the downmix */
76
@@ -1041,34 +1039,24 @@
77
                 the downmix. "dmx_re" and "specL" are two different pointers
78
                 pointing to separate arrays, which may or may not contain the
79
                 same data (with different scaling).
80
-              */
81
-
82
-              /* help1: alpha_re[i] * dmx_re[i] */
83
-              FIXP_DBL help1 = fMultDiv2(alpha_re_tmp, *p2dmxRe++);
84
 
85
-              /* tmp: dmx_im[i] */
86
-              FIXP_DBL tmp = (*p2dmxIm++) << shift_dmx;
87
-
88
-              /* help2: alpha_im[i] * dmx_im[i] */
89
-              FIXP_DBL help2 = fMultDiv2(alpha_im_tmp, tmp);
90
-
91
-              /* help3: alpha_re[i] * dmx_re[i] + alpha_im[i] * dmx_im[i] */
92
-              FIXP_DBL help3 = help1 + help2;
93
+                specL[i] =   + (specL[i] + side);
94
+                specR[i] = -/+ (specL[i] - side);
95
+              */
96
+              FIXP_DBL side, left, right;
97
 
98
-              /* side (= help4) = specR[i] - (dmx_re[i] * specL[i] + alpha_im[i]
99
-               * * dmx_im[i]) */
100
-              FIXP_DBL help4 = *p2CoeffR - scaleValue(help3, help3_shift);
101
+              side = fMultAddDiv2(fMultDiv2(alpha_re_tmp, *p2dmxRe++),
102
+                                  alpha_im_tmp, (*p2dmxIm++) << shift_dmx);
103
+              side = ((*p2CoeffR) >> 2) -
104
+                     (FIXP_DBL)SATURATE_SHIFT(side, -(help3_shift - 2),
105
+                                              DFRACT_BITS - 2);
106
 
107
-              /* We calculate the left and right output by using the helper
108
-               * function */
109
-              /* specR[i] = -/+ (specL[i] - side); */
110
-              *p2CoeffR =
111
-                  (FIXP_DBL)((LONG)(*p2CoeffL - help4) * (LONG)pred_dir);
112
-              p2CoeffR++;
113
+              left = ((*p2CoeffL) >> 2) + side;
114
+              right = ((*p2CoeffL) >> 2) - side;
115
+              right = (FIXP_DBL)((LONG)right * pred_dir);
116
 
117
-              /* specL[i] = specL[i] + side; */
118
-              *p2CoeffL = *p2CoeffL + help4;
119
-              p2CoeffL++;
120
+              *p2CoeffL++ = SATURATE_LEFT_SHIFT_ALT(left, 2, DFRACT_BITS);
121
+              *p2CoeffR++ = SATURATE_LEFT_SHIFT_ALT(right, 2, DFRACT_BITS);
122
             }
123
           }
124
 
125
fdk-aac-2.0.1.tar.gz/libAACdec/src/usacdec_acelp.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/usacdec_acelp.cpp Changed
82
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -131,7 +131,7 @@
11
   int i;
12
 
13
   for (i = 0; i < L; i++) {
14
-    out[i] = in[i] - fMult(PREEMPH_FAC, in[i - 1]);
15
+    out[i] = fAddSaturate(in[i], -fMult(PREEMPH_FAC, in[i - 1]));
16
   }
17
 
18
   return;
19
@@ -465,7 +465,9 @@
20
 /* Note: code[L_SUBFR] and exc2[L_SUBFR] share the same memory!
21
          If exc2[i] is written, code[i] will be destroyed!
22
 */
23
-#define SF (SF_CODE + SF_GAIN_C + 1 - SF_EXC)
24
+#define SF_HEADROOM (1)
25
+#define SF (SF_CODE + SF_GAIN_C + 1 - SF_EXC - SF_HEADROOM)
26
+#define SF_GAIN_P2 (SF_GAIN_P - SF_HEADROOM)
27
 
28
   int i;
29
   FIXP_DBL tmp, cpe, code_smooth_prev, code_smooth;
30
@@ -477,8 +479,8 @@
31
   cpe = (period_fac >> (2 - SF_PFAC)) + FL2FXCONST_DBL(0.25f);
32
 
33
   /* u'(n) */
34
-  tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P + 1); /* v(0)*g_p */
35
-  *exc++ = tmp + (fMultDiv2(code[0], gain_code) << SF);
36
+  tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P2 + 1); /* v(0)*g_p */
37
+  *exc++ = (tmp + (fMultDiv2(code[0], gain_code) << SF)) << SF_HEADROOM;
38
 
39
   /* u(n) */
40
   code_smooth_prev = fMultDiv2(*code++, gain_code_smoothed)
41
@@ -487,15 +489,15 @@
42
   code_smooth = fMultDiv2(code_i, gain_code_smoothed) << SF; /* c(1) * g_sc */
43
   tmp += code_smooth_prev; /* tmp = v(0)*g_p + c(0)*g_sc */
44
   cpe_code_smooth = fMultDiv2(cpe, code_smooth);
45
-  *exc2++ = tmp - cpe_code_smooth;
46
+  *exc2++ = (tmp - cpe_code_smooth) << SF_HEADROOM;
47
   cpe_code_smooth_prev = fMultDiv2(cpe, code_smooth_prev);
48
 
49
   i = L_SUBFR - 2;
50
   do /* ARM926: 22 cycles per iteration */
51
   {
52
     /* u'(n) */
53
-    tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P + 1);
54
-    *exc++ = tmp + (fMultDiv2(code_i, gain_code) << SF);
55
+    tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P2 + 1);
56
+    *exc++ = (tmp + (fMultDiv2(code_i, gain_code) << SF)) << SF_HEADROOM;
57
     /* u(n) */
58
     tmp += code_smooth; /* += g_sc * c(i) */
59
     tmp -= cpe_code_smooth_prev;
60
@@ -503,16 +505,17 @@
61
     code_i = *code++;
62
     code_smooth = fMultDiv2(code_i, gain_code_smoothed) << SF;
63
     cpe_code_smooth = fMultDiv2(cpe, code_smooth);
64
-    *exc2++ = tmp - cpe_code_smooth; /* tmp - c_pe * g_sc * c(i+1) */
65
+    *exc2++ = (tmp - cpe_code_smooth)
66
+              << SF_HEADROOM; /* tmp - c_pe * g_sc * c(i+1) */
67
   } while (--i != 0);
68
 
69
   /* u'(n) */
70
-  tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P + 1);
71
-  *exc = tmp + (fMultDiv2(code_i, gain_code) << SF);
72
+  tmp = fMultDiv2(*exc, gain_pit) << (SF_GAIN_P2 + 1);
73
+  *exc = (tmp + (fMultDiv2(code_i, gain_code) << SF)) << SF_HEADROOM;
74
   /* u(n) */
75
   tmp += code_smooth;
76
   tmp -= cpe_code_smooth_prev;
77
-  *exc2++ = tmp;
78
+  *exc2++ = tmp << SF_HEADROOM;
79
 
80
   return;
81
 }
82
fdk-aac-2.0.1.tar.gz/libAACdec/src/usacdec_fac.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/usacdec_fac.cpp Changed
114
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -344,7 +344,7 @@
11
       /* Overlap Add */
12
       x0 = -fMult(*pOvl--, pWindow[i].v.re);
13
 
14
-      *pOut0 += IMDCT_SCALE_DBL(x0);
15
+      *pOut0 = fAddSaturate(*pOut0, IMDCT_SCALE_DBL(x0));
16
       pOut0++;
17
     }
18
   } else {
19
@@ -354,7 +354,7 @@
20
       /* Overlap Add */
21
       x0 = fMult(*pOvl--, pWindow[i].v.re);
22
 
23
-      *pOut0 += IMDCT_SCALE_DBL(x0);
24
+      *pOut0 = fAddSaturate(*pOut0, IMDCT_SCALE_DBL(x0));
25
       pOut0++;
26
     }
27
   }
28
@@ -362,7 +362,7 @@
29
       0) { /* this should only happen for ACELP -> TCX20 -> ACELP transition */
30
     FIXP_DBL *pOut = pOut0 - fl / 2; /* fl/2 == fac_length */
31
     for (i = 0; i < fl / 2; i++) {
32
-      pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
33
+      pOut[i] = fAddSaturate(pOut[i], IMDCT_SCALE_DBL(hMdct->pFacZir[i]));
34
     }
35
     hMdct->pFacZir = NULL;
36
   }
37
@@ -493,9 +493,7 @@
38
           /* Div2 is compensated by table scaling */
39
           x = fMultDiv2(pTmp2[i], FacWindowZir[w]);
40
           x += fMultDiv2(pTmp1[-i - 1], FacWindowSynth[w]);
41
-          x += pFAC_and_FAC_ZIR[i];
42
-          pOut1[i] = x;
43
-
44
+          pOut1[i] = fAddSaturate(x, pFAC_and_FAC_ZIR[i]);
45
           w++;
46
         }
47
       }
48
@@ -552,7 +550,7 @@
49
     FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
50
                 pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
51
                (pOut1 >= output && pOut1 < output + 1024));
52
-    *pOut1 += IMDCT_SCALE_DBL(-x1);
53
+    *pOut1 = fAddSaturate(*pOut1, IMDCT_SCALE_DBL(-x1));
54
     pOut1--;
55
   }
56
 
57
@@ -578,7 +576,7 @@
58
     FIXP_DBL x = -(*pCurr--);
59
     /* 5) (item 4) Synthesis filter Zir component, FAC ZIR (another one). */
60
     if (i < f_len) {
61
-      x += *pF++;
62
+      x = fAddSaturate(x, *pF++);
63
     }
64
 
65
     FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
66
@@ -668,9 +666,9 @@
67
       for (i = 0; i < fl / 2; i++) {
68
         FIXP_DBL x0, x1;
69
 
70
-        cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
71
-        *pOut0 = IMDCT_SCALE_DBL(x0);
72
-        *pOut1 = IMDCT_SCALE_DBL(-x1);
73
+        cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
74
+        *pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
75
+        *pOut1 = IMDCT_SCALE_DBL_LSH1(-x1);
76
         pOut0++;
77
         pOut1--;
78
       }
79
@@ -680,9 +678,9 @@
80
         for (i = 0; i < fl / 2; i++) {
81
           FIXP_DBL x0, x1;
82
 
83
-          cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
84
-          *pOut0 = IMDCT_SCALE_DBL(x0);
85
-          *pOut1 = IMDCT_SCALE_DBL(x1);
86
+          cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
87
+          *pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
88
+          *pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
89
           pOut0++;
90
           pOut1--;
91
         }
92
@@ -691,9 +689,9 @@
93
         for (i = 0; i < fl / 2; i++) {
94
           FIXP_DBL x0, x1;
95
 
96
-          cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
97
-          *pOut0 = IMDCT_SCALE_DBL(x0);
98
-          *pOut1 = IMDCT_SCALE_DBL(x1);
99
+          cplxMultDiv2(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
100
+          *pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
101
+          *pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
102
           pOut0++;
103
           pOut1--;
104
         }
105
@@ -705,7 +703,7 @@
106
       FIXP_DBL *pOut = pOut0 - fl / 2;
107
       FDK_ASSERT(fl / 2 <= 128);
108
       for (i = 0; i < fl / 2; i++) {
109
-        pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
110
+        pOut[i] = fAddSaturate(pOut[i], IMDCT_SCALE_DBL(hMdct->pFacZir[i]));
111
       }
112
       hMdct->pFacZir = NULL;
113
     }
114
fdk-aac-2.0.1.tar.gz/libAACdec/src/usacdec_lpc.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/usacdec_lpc.cpp Changed
98
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -231,7 +231,7 @@
11
 void RE8_PPV(FIXP_ZF x[], SHORT y[], int r) {
12
   int i, y0[8], y1[8];
13
   FIXP_ZF x1[8], tmp;
14
-  FIXP_DBL e;
15
+  INT64 e;
16
 
17
   /* find the nearest neighbor y0 of x in 2D8 */
18
   nearest_neighbor_2D8(x, y0);
19
@@ -245,16 +245,16 @@
20
   }
21
 
22
   /* compute e0=||x-y0||^2 and e1=||x-y1||^2 */
23
-  e = (FIXP_DBL)0;
24
+  e = 0;
25
   for (i = 0; i < 8; i++) {
26
     tmp = x[i] - INT2ZF(y0[i], 0);
27
-    e += fPow2Div2(
28
+    e += (INT64)fPow2Div2(
29
         tmp << r); /* shift left to ensure that no fract part bits get lost. */
30
     tmp = x[i] - INT2ZF(y1[i], 0);
31
-    e -= fPow2Div2(tmp << r);
32
+    e -= (INT64)fPow2Div2(tmp << r);
33
   }
34
   /* select best candidate y0 or y1 to minimize distortion */
35
-  if (e < (FIXP_DBL)0) {
36
+  if (e < 0) {
37
     for (i = 0; i < 8; i++) {
38
       y[i] = y0[i];
39
     }
40
@@ -565,7 +565,8 @@
41
   /* add non-weighted residual LSF vector to LSF1st */
42
   for (i = 0; i < M_LP_FILTER_ORDER; i++) {
43
     w = (LONG)fMultDiv2(factor, sqrtFixp(fMult(d[i], d[i + 1])));
44
-    lsfq[i] = fAddSaturate(lsfq[i], FX_DBL2FX_LPC((FIXP_DBL)(w * (LONG)xq[i])));
45
+    lsfq[i] = fAddSaturate(lsfq[i],
46
+                           FX_DBL2FX_LPC((FIXP_DBL)((INT64)w * (LONG)xq[i])));
47
   }
48
 
49
   return;
50
@@ -1138,9 +1139,12 @@
51
   for (i = 2; i <= n; i++) {
52
     plsp += 2;
53
     b = -FX_LPC2FX_DBL(*plsp);
54
-    f[i] = ((fMultDiv2(b, f[i - 1]) << 1) + (f[i - 2])) << 1;
55
+    f[i] = SATURATE_LEFT_SHIFT((fMultDiv2(b, f[i - 1]) + (f[i - 2] >> 1)), 2,
56
+                               DFRACT_BITS);
57
     for (j = i - 1; j > 1; j--) {
58
-      f[j] = f[j] + (fMultDiv2(b, f[j - 1]) << 2) + f[j - 2];
59
+      f[j] = SATURATE_LEFT_SHIFT(
60
+          ((f[j] >> 2) + fMultDiv2(b, f[j - 1]) + (f[j - 2] >> 2)), 2,
61
+          DFRACT_BITS);
62
     }
63
     f[1] = f[1] + (b >> (SF_F - 1));
64
   }
65
@@ -1167,6 +1171,9 @@
66
   /*-----------------------------------------------------*
67
    *  Multiply F1(z) by (1+z^-1) and F2(z) by (1-z^-1)   *
68
    *-----------------------------------------------------*/
69
+  scaleValues(f1, NC + 1, -2);
70
+  scaleValues(f2, NC + 1, -2);
71
+
72
   for (i = NC; i > 0; i--) {
73
     f1[i] += f1[i - 1];
74
     f2[i] -= f2[i - 1];
75
@@ -1175,13 +1182,8 @@
76
   FIXP_DBL aDBL[M_LP_FILTER_ORDER];
77
 
78
   for (i = 1, k = M_LP_FILTER_ORDER - 1; i <= NC; i++, k--) {
79
-    FIXP_DBL tmp1, tmp2;
80
-
81
-    tmp1 = f1[i] >> 1;
82
-    tmp2 = f2[i] >> 1;
83
-
84
-    aDBL[i - 1] = (tmp1 + tmp2);
85
-    aDBL[k] = (tmp1 - tmp2);
86
+    aDBL[i - 1] = f1[i] + f2[i];
87
+    aDBL[k] = f1[i] - f2[i];
88
   }
89
 
90
   int headroom_a = getScalefactor(aDBL, M_LP_FILTER_ORDER);
91
@@ -1190,5 +1192,5 @@
92
     a[i] = FX_DBL2FX_LPC(aDBL[i] << headroom_a);
93
   }
94
 
95
-  *a_exp = 8 - headroom_a;
96
+  *a_exp = SF_F + (2 - 1) - headroom_a;
97
 }
98
fdk-aac-2.0.1.tar.gz/libAACdec/src/usacdec_lpd.cpp -> fdk-aac-2.0.2.tar.gz/libAACdec/src/usacdec_lpd.cpp Changed
123
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -122,17 +122,21 @@
11
 
12
 #include "ac_arith_coder.h"
13
 
14
-void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
15
-            const FIXP_SGL *filt, INT stop, int len) {
16
+void filtLP(const FIXP_DBL *syn, PCM_DEC *syn_out, FIXP_DBL *noise,
17
+            const FIXP_SGL *filt, const INT aacOutDataHeadroom, INT stop,
18
+            int len) {
19
   INT i, j;
20
   FIXP_DBL tmp;
21
 
22
+  FDK_ASSERT((aacOutDataHeadroom - 1) >= -(MDCT_OUTPUT_SCALE));
23
+
24
   for (i = 0; i < stop; i++) {
25
     tmp = fMultDiv2(noise[i], filt[0]);  // Filt in Q-1.16
26
     for (j = 1; j <= len; j++) {
27
-      tmp += fMultDiv2((noise[i - j] + noise[i + j]), filt[j]);
28
+      tmp += fMult((noise[i - j] >> 1) + (noise[i + j] >> 1), filt[j]);
29
     }
30
-    syn_out[i] = (FIXP_PCM)(IMDCT_SCALE(syn[i] - tmp));
31
+    syn_out[i] = (PCM_DEC)(
32
+        IMDCT_SCALE((syn[i] >> 1) - (tmp >> 1), aacOutDataHeadroom - 1));
33
   }
34
 }
35
 
36
@@ -142,8 +146,10 @@
37
     FIXP_DBL *pit_gain,
38
     const int frame_length, /* (i) : frame length (should be 768|1024) */
39
     const INT l_frame,
40
-    const INT l_next, /* (i) : look ahead for symmetric filtering           */
41
-    FIXP_PCM *synth_out, /* (o) : filtered synthesis (with delay of 1 subfr) */
42
+    const INT l_next,   /* (i) : look ahead for symmetric filtering           */
43
+    PCM_DEC *synth_out, /* (o) : filtered synthesis (with delay of 1 subfr)   */
44
+    const INT aacOutDataHeadroom, /* (i) : headroom of the output time signal to
45
+                                     prevent clipping */
46
     FIXP_DBL mem_bpf[]) /* i/o : memory state [L_FILT+L_SUBFR]                */
47
 {
48
   INT i, sf, i_subfr, T, T2, lg;
49
@@ -335,17 +341,22 @@
50
 
51
       {
52
         for (i = 0; i < lg; i++) {
53
-          /* scaled with SF_SYNTH + gain_sf + 1 */
54
+          /* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
55
+           * one additional shift of syn values + fMult => fMultDiv2 */
56
           noise_in[i] =
57
-              (fMult(gainSGL, syn[i + i_subfr] - (syn[i + i_subfr - T] >> 1) -
58
-                                  (syn[i + i_subfr + T] >> 1))) >>
59
-              s1;
60
+              scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
61
+                                                (syn[i + i_subfr - T] >> 2) -
62
+                                                (syn[i + i_subfr + T] >> 2)),
63
+                         2 - s1);
64
         }
65
 
66
         for (i = lg; i < L_SUBFR; i++) {
67
-          /* scaled with SF_SYNTH + gain_sf + 1 */
68
+          /* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
69
+           * one additional shift of syn values + fMult => fMultDiv2 */
70
           noise_in[i] =
71
-              (fMult(gainSGL, syn[i + i_subfr] - syn[i + i_subfr - T])) >> s1;
72
+              scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
73
+                                                (syn[i + i_subfr - T] >> 1)),
74
+                         2 - s1);
75
         }
76
       }
77
     } else {
78
@@ -364,7 +375,7 @@
79
 
80
     {
81
       filtLP(&syn[i_subfr - L_SUBFR], &synth_out[i_subfr], noise,
82
-             fdk_dec_filt_lp, L_SUBFR, L_FILT);
83
+             fdk_dec_filt_lp, aacOutDataHeadroom, L_SUBFR, L_FILT);
84
     }
85
   }
86
 
87
@@ -377,9 +388,9 @@
88
     /* Output scaling of the BPF memory */
89
     scaleValues(mem_bpf, (L_FILT + L_SUBFR), -1);
90
     /* Copy the rest of the signal (after the fac) */
91
-    scaleValuesSaturate((FIXP_PCM *)&synth_out[l_frame],
92
-                        (FIXP_DBL *)&syn[l_frame - L_SUBFR],
93
-                        (frame_length - l_frame), MDCT_OUT_HEADROOM);
94
+    scaleValuesSaturate(
95
+        (PCM_DEC *)&synth_out[l_frame], (FIXP_DBL *)&syn[l_frame - L_SUBFR],
96
+        (frame_length - l_frame), MDCT_OUT_HEADROOM - aacOutDataHeadroom);
97
   }
98
 
99
   return;
100
@@ -1546,9 +1557,9 @@
101
 
102
 AAC_DECODER_ERROR CLpd_RenderTimeSignal(
103
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
104
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM *pTimeData,
105
-    INT lFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk, UINT flags,
106
-    UINT strmFlags) {
107
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC *pTimeData,
108
+    INT lFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk,
109
+    const INT aacOutDataHeadroom, UINT flags, UINT strmFlags) {
110
   UCHAR *mod = pAacDecoderChannelInfo->data.usac.mod;
111
   AAC_DECODER_ERROR error = AAC_DEC_OK;
112
   int k, i_offset;
113
@@ -2011,7 +2022,8 @@
114
     {
115
       bass_pf_1sf_delay(p2_synth, pitch, pit_gain, lFrame, lFrame / facFB,
116
                         mod[nbDiv - 1] ? (SynDelay - (lDiv / 2)) : SynDelay,
117
-                        pTimeData, pAacDecoderStaticChannelInfo->mem_bpf);
118
+                        pTimeData, aacOutDataHeadroom,
119
+                        pAacDecoderStaticChannelInfo->mem_bpf);
120
     }
121
   }
122
 
123
fdk-aac-2.0.1.tar.gz/libAACdec/src/usacdec_lpd.h -> fdk-aac-2.0.2.tar.gz/libAACdec/src/usacdec_lpd.h Changed
57
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -140,13 +140,14 @@
11
  * \param pTimeData pointer to output buffer
12
  * \param samplesPerFrame amount of output samples
13
  * \param pSamplingRateInfo holds the sampling rate information
14
- * \param pWorkBuffer1 pointer to work buffer for temporal data
15
+ * \param aacOutDataHeadroom headroom of the output time signal to prevent
16
+ * clipping
17
  */
18
 AAC_DECODER_ERROR CLpd_RenderTimeSignal(
19
     CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
20
-    CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM *pTimeData,
21
+    CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC *pTimeData,
22
     INT samplesPerFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk,
23
-    UINT flags, UINT strmFlags);
24
+    const INT aacOutDataHeadroom, UINT flags, UINT strmFlags);
25
 
26
 static inline INT CLpd_FAC_getLength(int fNotShortBlock, int fac_length_long) {
27
   if (fNotShortBlock) {
28
@@ -156,8 +157,9 @@
29
   }
30
 }
31
 
32
-void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
33
-            const FIXP_SGL *filt, INT stop, int len);
34
+void filtLP(const FIXP_DBL *syn, PCM_DEC *syn_out, FIXP_DBL *noise,
35
+            const FIXP_SGL *filt, const INT aacOutDataHeadroom, INT stop,
36
+            int len);
37
 
38
 /**
39
  * \brief perform a low-frequency pitch enhancement on time domain signal
40
@@ -171,13 +173,14 @@
41
  * \param[in] l_frame length of filtering, must be multiple of L_SUBFR
42
  * \param[in] l_next length of allowed look ahead on syn[i], i < l_frame+l_next
43
  * \param[out] synth_out pointer to time domain output signal
44
+ * \param[in] headroom of the output time signal to prevent clipping
45
  * \param[in,out] mem_bpf pointer to filter memory (L_FILT+L_SUBFR)
46
  */
47
 
48
 void bass_pf_1sf_delay(FIXP_DBL syn[], const INT T_sf[], FIXP_DBL *pit_gain,
49
                        const int frame_length, const INT l_frame,
50
-                       const INT l_next, FIXP_PCM *synth_out,
51
-                       FIXP_DBL mem_bpf[]);
52
+                       const INT l_next, PCM_DEC *synth_out,
53
+                       const INT aacOutDataHeadroom, FIXP_DBL mem_bpf[]);
54
 
55
 /**
56
  * \brief random sign generator for FD and TCX noise filling
57
fdk-aac-2.0.1.tar.gz/libAACenc/include/aacenc_lib.h -> fdk-aac-2.0.2.tar.gz/libAACenc/include/aacenc_lib.h Changed
168
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -149,12 +149,6 @@
11
 All header files are provided for usage in C/C++ programs. The AAC encoder
12
 library API functions are located in aacenc_lib.h.
13
 
14
-In binary releases the encoder core resides in statically linkable libraries
15
-called for example libAACenc.a/libFDK.a (LINUX) or FDK_fastaaclib.lib (MS Visual
16
-C++) for the plain AAC-LC core encoder and libSBRenc.a (LINUX) or
17
-FDK_sbrEncLib.lib (MS Visual C++) for the SBR (Spectral Band Replication) and PS
18
-(Parametric Stereo) modules.
19
-
20
 \section CallingSequence Calling Sequence
21
 
22
 For encoding of ISO/MPEG-2/4 AAC bitstreams the following sequence is mandatory.
23
@@ -326,25 +320,19 @@
24
 \endcode
25
 
26
 \section writeOutData Output Bitstream Data
27
-If any AAC bitstream data is available, write it to output file or device. This
28
-can be done once the following condition is true: \code if
29
-(outargs.numOutBytes>0) {
30
-
31
+If any AAC bitstream data is available, write it to output file or device as
32
+follows. \code if (outargs.numOutBytes>0) { FDKfwrite(outputBuffer,
33
+outargs.numOutBytes, 1, pOutFile);
34
 }
35
 \endcode
36
 
37
-If you use file I/O then for example call mpegFileWrite_Write() from the library
38
-libMpegFileWrite \code mpegFileWrite_Write(hMpegFile, outputBuffer,
39
-outargs.numOutBytes, aacEncoder_GetParam(hAacEncoder, AACENC_GRANULE_LENGTH));
40
-\endcode
41
-
42
 \section cfgMetaData Meta Data Configuration
43
 
44
 If the present library is configured with Metadata support, it is possible to
45
 insert meta data side info into the generated audio bitstream while encoding.
46
 
47
 To work with meta data the encoder instance has to be \ref encOpen "allocated"
48
-with meta data support. The meta data mode must be be configured with the
49
+with meta data support. The meta data mode must be configured with the
50
 ::AACENC_METADATA_MODE parameter and aacEncoder_SetParam() function. \code
51
 aacEncoder_SetParam(hAacEncoder, AACENC_METADATA_MODE, 0-3); \endcode
52
 
53
@@ -427,7 +415,7 @@
54
 return chMode;
55
 \endcode
56
 
57
-\subsection bitreservoir Bitreservoir Configuration
58
+\subsection peakbitrate Peak Bitrate Configuration
59
 In AAC, the default bitreservoir configuration depends on the chosen bitrate per
60
 frame and the number of effective channels. The size can be determined as below.
61
 \f[
62
@@ -436,17 +424,10 @@
63
 Due to audio quality concerns it is not recommended to change the bitreservoir
64
 size to a lower value than the default setting! However, for minimizing the
65
 delay for streaming applications or for achieving a constant size of the
66
-bitstream packages in each frame, it may be necessaray to change the
67
-bitreservoir size. This can be done with the ::AACENC_PEAK_BITRATE parameter.
68
-\code
69
+bitstream packages in each frame, it may be necessaray to limit the maximum bits
70
+per frame size. This can be done with the ::AACENC_PEAK_BITRATE parameter. \code
71
 aacEncoder_SetParam(hAacEncoder, AACENC_PEAK_BITRATE, value);
72
 \endcode
73
-By setting ::AACENC_BITRATEMODE to fixed framing, the bitreservoir is disabled.
74
-A disabled bitreservoir results in a constant size for each bitstream package.
75
-Please note that especially at lower bitrates a disabled bitreservoir can
76
-downgrade the audio quality considerably! The default bitreservoir configuration
77
-can be achieved as follows. \code aacEncoder_SetParam(hAacEncoder,
78
-AACENC_BITRESERVOIR, -1); \endcode
79
 
80
 To achieve acceptable audio quality with a reduced bitreservoir size setting at
81
 least 1000 bits per audio channel is recommended. For a multichannel audio file
82
@@ -455,31 +436,32 @@
83
 
84
 
85
 \subsection vbrmode Variable Bitrate Mode
86
-The encoder provides various Variable Bitrate Modes that differ in audio quality
87
-and average overall bitrate. The given values are averages over time, different
88
-encoder settings and strongly depend on the type of audio signal. The VBR
89
-configurations can be adjusted via ::AACENC_BITRATEMODE encoder parameter.
90
+The variable bitrate (VBR) mode coding adapts the bit consumption to the
91
+psychoacoustic requirements of the signal. The encoder ignores the user-defined
92
+bit rate and selects a suitable pre-defined configuration based on the provided
93
+AOT. The VBR mode 1 is tuned for HE-AACv2, for VBR mode 2, HE-AACv1 should be
94
+used. VBR modes 3-5 should be used with Low-Complexity AAC. When encoding
95
+AAC-ELD, the best mode is selected automatically.
96
+
97
+The bitrates given in the table are averages over time and different encoder
98
+settings. They strongly depend on the type of audio signal. The VBR
99
+configurations can be adjusted with the ::AACENC_BITRATEMODE encoder parameter.
100
 \verbatim
101
---------------------------------------------
102
- VBR_MODE | Approx. Bitrate in kbps/channel
103
-          |     AAC-LC    |  AAC-LD/AC_ELD
104
-----------+---------------+-----------------
105
-    VBR_1 |    32 -  48   |      32 -  56
106
-    VBR_2 |    40 -  56   |      40 -  64
107
-    VBR_3 |    48 -  64   |      48 -  72
108
-    VBR_4 |    64 -  80   |      64 -  88
109
-    VBR_5 |    96 - 120   |     112 - 144
110
+-----------------------------------------------
111
+ VBR_MODE | Approx. Bitrate in kbps for stereo
112
+          |     AAC-LC    |      AAC-ELD
113
+----------+---------------+--------------------
114
+    VBR_1 | 32 (HE-AACv2) |         48
115
+    VBR_2 | 72 (HE-AACv1) |         56
116
+    VBR_3 |      112      |         72
117
+    VBR_4 |      148      |        148
118
+    VBR_5 |      228      |        224
119
 --------------------------------------------
120
 \endverbatim
121
-The bitrate ranges apply for individual audio channels. In case of multichannel
122
-configurations the average bitrate might be estimated by multiplying with the
123
-number of effective channels. This corresponds to all audio input channels
124
-exclusively the low frequency channel. At configurations which are making use of
125
-downmix modules the AAC core channels respectively downmix channels shall be
126
-considered. For ::AACENC_AOT which are using SBR, the average bitrate can be
127
-estimated by using the ratio of 0.5 for dualrate SBR and 0.75 for downsampled
128
-SBR configurations.
129
-
130
+Note that these figures are valid for stereo encoding only. VBR modes 2-5 will
131
+yield much lower bit rates when encoding single-channel input. For
132
+configurations which are making use of downmix modules the AAC core channels
133
+respectively downmix channels shall be considered.
134
 
135
 \subsection encQual Audio Quality Considerations
136
 The default encoder configuration is suggested to be used. Encoder tools such as
137
@@ -967,9 +949,7 @@
138
 
139
 \subsection BEHAVIOUR_ESTIM_AVG_FRAMESIZES Estimating Average Frame Sizes
140
 
141
-A HE-AAC v1 or v2 audio frame contains 2048 PCM samples per channel (there is
142
-also one mode with 1920 samples per channel but this is only for special
143
-purposes such as DAB+ digital radio).
144
+A HE-AAC v1 or v2 audio frame contains 2048 PCM samples per channel.
145
 
146
 The number of HE-AAC frames \f$N\_FRAMES\f$ per second at 44.1 kHz is:
147
 
148
@@ -1027,7 +1007,7 @@
149
 
150
 #define AACENCODER_LIB_VL0 4
151
 #define AACENCODER_LIB_VL1 0
152
-#define AACENCODER_LIB_VL2 0
153
+#define AACENCODER_LIB_VL2 1
154
 
155
 /**
156
  *  AAC encoder error codes.
157
@@ -1086,9 +1066,7 @@
158
 typedef struct {
159
   UINT maxOutBufBytes; /*!< Maximum number of encoder bitstream bytes within one
160
                           frame. Size depends on maximum number of supported
161
-                          channels in encoder instance. For superframing (as
162
-                          used for example in DAB+), size has to be a multiple
163
-                          accordingly. */
164
+                          channels in encoder instance. */
165
 
166
   UINT maxAncBytes; /*!< Maximum number of ancillary data bytes which can be
167
                        inserted into bitstream within one frame. */
168
fdk-aac-2.0.1.tar.gz/libAACenc/src/aacEnc_ram.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/aacEnc_ram.cpp Changed
17
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -204,5 +204,5 @@
11
    * (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)) is sufficiently aligned,
12
    * so the cast is safe */
13
   return reinterpret_cast<QC_OUT_CHANNEL *>(reinterpret_cast<void *>(
14
-      dynamic_RAM + P_BUF_0 + n * sizeof(QC_OUT_CHANNEL)));
15
+      dynamic_RAM + P_BUF_0 + n * ALIGN_SIZE(sizeof(QC_OUT_CHANNEL))));
16
 }
17
fdk-aac-2.0.1.tar.gz/libAACenc/src/aacEnc_ram.h -> fdk-aac-2.0.2.tar.gz/libAACenc/src/aacEnc_ram.h Changed
19
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -198,7 +198,7 @@
11
  +++++++++++++++++++++++++++++++++++++++++++++++++++++
12
 */
13
 
14
-#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL) * (8)))
15
+#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)) * (8))
16
 #define BUF_SIZE_1                                                           \
17
   (ALIGN_SIZE(maxSize(maxSize(sizeof(PSY_DYNAMIC),                           \
18
                               (BIT_LOOK_UP_SIZE + MERGE_GAIN_LOOK_UP_SIZE)), \
19
fdk-aac-2.0.1.tar.gz/libAACenc/src/aacenc.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/aacenc.cpp Changed
104
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -114,6 +114,8 @@
11
 
12
 #include "genericStds.h"
13
 
14
+#define BITRES_MIN \
15
+  300 /* default threshold for using reduced/disabled bitres mode */
16
 #define BITRES_MAX_LD 4000
17
 #define BITRES_MIN_LD 500
18
 #define BITRATE_MAX_LD 70000 /* Max assumed bitrate for bitres calculation */
19
@@ -243,6 +245,46 @@
20
   return bitrate;
21
 }
22
 
23
+/*-----------------------------------------------------------------------------
24
+
25
+    functionname: FDKaacEnc_AdjustVBRBitrateMode
26
+    description:  Adjust bitrate mode to given bitrate parameter
27
+    input params: int vbrQuality (VBR0, VBR1, VBR2)
28
+                  bitrate
29
+                  channelMode
30
+    returns:      vbr bitrate mode
31
+
32
+ ------------------------------------------------------------------------------*/
33
+AACENC_BITRATE_MODE FDKaacEnc_AdjustVBRBitrateMode(
34
+    AACENC_BITRATE_MODE bitrateMode, INT bitrate, CHANNEL_MODE channelMode) {
35
+  AACENC_BITRATE_MODE newBitrateMode = bitrateMode;
36
+
37
+  if (bitrate != -1) {
38
+    const INT monoStereoMode =
39
+        (FDKaacEnc_GetMonoStereoMode(channelMode) == EL_MODE_STEREO) ? 1 : 0;
40
+    const INT nChannelsEff =
41
+        FDKaacEnc_GetChannelModeConfiguration(channelMode)->nChannelsEff;
42
+    newBitrateMode = AACENC_BR_MODE_INVALID;
43
+
44
+    for (int idx = (int)(sizeof(configTabVBR) / sizeof(*configTabVBR)) - 1;
45
+         idx >= 0; idx--) {
46
+      if (bitrate >=
47
+          configTabVBR[idx].chanBitrate[monoStereoMode] * nChannelsEff) {
48
+        if (configTabVBR[idx].chanBitrate[monoStereoMode] * nChannelsEff <
49
+            FDKaacEnc_GetVBRBitrate(bitrateMode, channelMode)) {
50
+          newBitrateMode = configTabVBR[idx].bitrateMode;
51
+        } else {
52
+          newBitrateMode = bitrateMode;
53
+        }
54
+        break;
55
+      }
56
+    }
57
+  }
58
+
59
+  return AACENC_BR_MODE_IS_VBR(newBitrateMode) ? newBitrateMode
60
+                                               : AACENC_BR_MODE_INVALID;
61
+}
62
+
63
 /**
64
  * \brief  Convert encoder bitreservoir value for transport library.
65
  *
66
@@ -395,7 +437,6 @@
67
   FIXP_DBL mbfac, bw_ratio;
68
   QC_INIT qcInit;
69
   INT averageBitsPerFrame = 0;
70
-  int bitresMin = 0; /* the bitreservoir is always big for AAC-LC */
71
   const CHANNEL_MODE prevChannelMode = hAacEnc->encoderMode;
72
 
73
   if (config == NULL) return AAC_ENC_INVALID_HANDLE;
74
@@ -550,7 +591,7 @@
75
         (config->minBitsPerFrame != -1) ? config->minBitsPerFrame : 0;
76
     qcInit.minBits = fixMin(qcInit.minBits, averageBitsPerFrame & ~7);
77
   } else {
78
-    INT bitreservoir = -1; /* default bitrservoir size*/
79
+    INT bitreservoir = -1; /* default bitreservoir size*/
80
     if (isLowDelay(config->audioObjectType)) {
81
       INT brPerChannel = config->bitRate / config->nChannels;
82
       brPerChannel = fMin(BITRATE_MAX_LD, fMax(BITRATE_MIN_LD, brPerChannel));
83
@@ -564,7 +605,6 @@
84
       bitreservoir = fMultI(slope, (INT)(BITRES_MAX_LD - BITRES_MIN_LD)) +
85
                      BITRES_MIN_LD;     /* interpolate */
86
       bitreservoir = bitreservoir & ~7; /* align to bytes */
87
-      bitresMin = BITRES_MIN_LD;
88
     }
89
 
90
     int maxBitres;
91
@@ -601,9 +641,10 @@
92
   qcInit.nSubFrames = config->nSubFrames;
93
   qcInit.padding.paddingRest = config->sampleRate;
94
 
95
-  if (qcInit.bitRes >= bitresMin * config->nChannels) {
96
+  if (qcInit.maxBits - qcInit.averageBits >=
97
+      ((qcInit.isLowDelay) ? BITRES_MIN_LD : BITRES_MIN) * config->nChannels) {
98
     qcInit.bitResMode = AACENC_BR_MODE_FULL; /* full bitreservoir */
99
-  } else if (qcInit.bitRes > 0) {
100
+  } else if (qcInit.maxBits > qcInit.averageBits) {
101
     qcInit.bitResMode = AACENC_BR_MODE_REDUCED; /* reduced bitreservoir */
102
   } else {
103
     qcInit.bitResMode = AACENC_BR_MODE_DISABLED; /* disabled bitreservoir */
104
fdk-aac-2.0.1.tar.gz/libAACenc/src/aacenc.h -> fdk-aac-2.0.2.tar.gz/libAACenc/src/aacenc.h Changed
30
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -336,6 +336,19 @@
11
 
12
 /*-----------------------------------------------------------------------------
13
 
14
+    functionname: FDKaacEnc_AdjustVBRBitrateMode
15
+    description:  Adjust bitrate mode to given bitrate parameter
16
+    input params: int vbrQuality (VBR0, VBR1, VBR2)
17
+                  bitrate
18
+                  channelMode
19
+    returns:      vbr bitrate mode
20
+
21
+ ------------------------------------------------------------------------------*/
22
+AACENC_BITRATE_MODE FDKaacEnc_AdjustVBRBitrateMode(
23
+    AACENC_BITRATE_MODE bitrateMode, INT bitrate, CHANNEL_MODE channelMode);
24
+
25
+/*-----------------------------------------------------------------------------
26
+
27
      functionname: FDKaacEnc_AacInitDefaultConfig
28
      description:  gives reasonable default configuration
29
      returns:      ---
30
fdk-aac-2.0.1.tar.gz/libAACenc/src/aacenc_lib.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/aacenc_lib.cpp Changed
89
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -110,9 +110,9 @@
11
 /* Encoder library info */
12
 #define AACENCODER_LIB_VL0 4
13
 #define AACENCODER_LIB_VL1 0
14
-#define AACENCODER_LIB_VL2 0
15
+#define AACENCODER_LIB_VL2 1
16
 #define AACENCODER_LIB_TITLE "AAC Encoder"
17
-#ifdef __ANDROID__
18
+#ifdef SUPPRESS_BUILD_DATE_INFO
19
 #define AACENCODER_LIB_BUILD_DATE ""
20
 #define AACENCODER_LIB_BUILD_TIME ""
21
 #else
22
@@ -446,6 +446,24 @@
23
   return sbrSignaling;
24
 }
25
 
26
+static inline INT getAssociatedChElement(SBR_ELEMENT_INFO *elInfoSbr,
27
+                                         CHANNEL_MAPPING *channelMapping) {
28
+  ELEMENT_INFO *elInfo = channelMapping->elInfo;
29
+  INT nElements = channelMapping->nElements;
30
+  INT associatedChElement = -1;
31
+  int i;
32
+
33
+  for (i = 0; i < nElements; i++) {
34
+    if (elInfoSbr->elType == elInfo[i].elType &&
35
+        elInfoSbr->instanceTag == elInfo[i].instanceTag) {
36
+      associatedChElement = i;
37
+      break;
38
+    }
39
+  }
40
+
41
+  return associatedChElement;
42
+}
43
+
44
 /****************************************************************************
45
                                Allocate Encoder
46
 ****************************************************************************/
47
@@ -1010,6 +1028,13 @@
48
     case AACENC_BR_MODE_VBR_3:
49
     case AACENC_BR_MODE_VBR_4:
50
     case AACENC_BR_MODE_VBR_5:
51
+      /* Adjust bitrate mode in case given peak bitrate is lower than expected
52
+       * VBR bitrate. */
53
+      if ((INT)config->userPeakBitrate != -1) {
54
+        hAacConfig->bitrateMode = FDKaacEnc_AdjustVBRBitrateMode(
55
+            hAacConfig->bitrateMode, config->userPeakBitrate,
56
+            hAacConfig->channelMode);
57
+      }
58
       /* Get bitrate in VBR configuration */
59
       /* In VBR mode; SBR-modul depends on bitrate, core encoder on bitrateMode.
60
        */
61
@@ -1761,6 +1786,10 @@
62
         hAacEncoder->inputBuffer +
63
         (hAacEncoder->inputBufferOffset + hAacEncoder->nSamplesRead) /
64
             hAacEncoder->aacConfig.nChannels;
65
+    newSamples -=
66
+        (newSamples %
67
+         hAacEncoder->extParam
68
+             .nChannels); /* process multiple samples of input channels */
69
 
70
     /* Copy new input samples to internal buffer */
71
     if (inBufDesc->bufElSizes[idx] == (INT)sizeof(INT_PCM)) {
72
@@ -1917,7 +1946,15 @@
73
           {
74
             hAacEncoder->extPayload[nExtensions].dataSize =
75
                 hAacEncoder->pSbrPayload->dataSize[nPayload][i];
76
-            hAacEncoder->extPayload[nExtensions].associatedChElement = i;
77
+            hAacEncoder->extPayload[nExtensions].associatedChElement =
78
+                getAssociatedChElement(
79
+                    &hAacEncoder->hEnvEnc->sbrElement[i]->elInfo,
80
+                    &hAacEncoder->hAacEnc->channelMapping);
81
+            if (hAacEncoder->extPayload[nExtensions].associatedChElement ==
82
+                -1) {
83
+              err = AACENC_ENCODE_ERROR;
84
+              goto bail;
85
+            }
86
           }
87
           hAacEncoder->extPayload[nExtensions].dataType =
88
               EXT_SBR_DATA; /* Once SBR Encoder supports SBR CRC set
89
fdk-aac-2.0.1.tar.gz/libAACenc/src/adj_thr.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/adj_thr.cpp Changed
43
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -591,13 +591,11 @@
11
           if (sfbEn > avgEn) {
12
             FIXP_DBL tmpMinSnrLdData;
13
             if (psyOutChannel[ch]->lastWindowSequence == LONG_WINDOW)
14
-              tmpMinSnrLdData =
15
-                  fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData),
16
-                         (FIXP_DBL)SnrLdMin1);
17
+              tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
18
+                                                  SnrLdMin1 - SnrLdFac);
19
             else
20
-              tmpMinSnrLdData =
21
-                  fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData),
22
-                         (FIXP_DBL)SnrLdMin3);
23
+              tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData,
24
+                                                  SnrLdMin3 - SnrLdFac);
25
 
26
             qcOutChan->sfbMinSnrLdData[sfbGrp + sfb] = fixMin(
27
                 qcOutChan->sfbMinSnrLdData[sfbGrp + sfb], tmpMinSnrLdData);
28
@@ -1304,14 +1302,6 @@
29
           if (sfbThrReducedLdData < FL2FXCONST_DBL(-0.5f))
30
             sfbThrReducedLdData = FL2FXCONST_DBL(-1.f);
31
 
32
-          /* minimum of 29 dB Ratio for Thresholds */
33
-          if ((sfbEnLdData + FL2FXCONST_DBL(1.0f)) >
34
-              FL2FXCONST_DBL(9.6336206 / LD_DATA_SCALING)) {
35
-            sfbThrReducedLdData = fixMax(
36
-                sfbThrReducedLdData,
37
-                sfbEnLdData - FL2FXCONST_DBL(9.6336206 / LD_DATA_SCALING));
38
-          }
39
-
40
           sfbThrReducedLdData = fixMax(MIN_LDTHRESH, sfbThrReducedLdData);
41
 
42
           qcOutChan->sfbThresholdLdData[sfbGrp + sfb] = sfbThrReducedLdData;
43
fdk-aac-2.0.1.tar.gz/libAACenc/src/bandwidth.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/bandwidth.cpp Changed
27
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -151,11 +151,11 @@
11
 
12
 static const BANDWIDTH_TAB_VBR bandWidthTableVBR[] = {
13
     {AACENC_BR_MODE_CBR, 0, 0},
14
-    {AACENC_BR_MODE_VBR_1, 13050, 13050},
15
-    {AACENC_BR_MODE_VBR_2, 13050, 13050},
16
-    {AACENC_BR_MODE_VBR_3, 14260, 14260},
17
-    {AACENC_BR_MODE_VBR_4, 15500, 15500},
18
-    {AACENC_BR_MODE_VBR_5, 48000, 48000},
19
+    {AACENC_BR_MODE_VBR_1, 13000, 13000},
20
+    {AACENC_BR_MODE_VBR_2, 13000, 13000},
21
+    {AACENC_BR_MODE_VBR_3, 15750, 15750},
22
+    {AACENC_BR_MODE_VBR_4, 16500, 16500},
23
+    {AACENC_BR_MODE_VBR_5, 19293, 19293},
24
     {AACENC_BR_MODE_SFR, 0, 0},
25
     {AACENC_BR_MODE_FF, 0, 0}
26
 
27
fdk-aac-2.0.1.tar.gz/libAACenc/src/intensity.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/intensity.cpp Changed
63
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -661,6 +661,7 @@
11
     for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) {
12
       INT sL, sR;
13
       FIXP_DBL inv_n;
14
+      INT mdct_spec_sf = MDCT_SPEC_SF;
15
 
16
       msMask[sfb + sfboffs] = 0;
17
       if (isMask[sfb + sfboffs] == 0) {
18
@@ -682,6 +683,12 @@
19
         }
20
       }
21
 
22
+      if (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs] >
23
+          1 << mdct_spec_sf) {
24
+        mdct_spec_sf++; /* This is for rare cases where the number of bins in a
25
+                           scale factor band is > 64 */
26
+      }
27
+
28
       inv_n = GetInvInt(
29
           (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >>
30
           1);  // scaled with 2 to compensate fMultDiv2() in subsequent loop
31
@@ -707,11 +714,11 @@
32
              j++) {
33
           d = ((mdctSpectrumLeft[j] << s0) >> 1) -
34
               ((mdctSpectrumRight[j] << s0) >> 1);
35
-          ed += fMultDiv2(d, d) >> (MDCT_SPEC_SF - 1);
36
+          ed += fMultDiv2(d, d) >> (mdct_spec_sf - 1);
37
         }
38
         msMask[sfb + sfboffs] = 1;
39
         tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], ed, &s1);
40
-        s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF;
41
+        s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
42
         if (s2 & 1) {
43
           tmp = tmp >> 1;
44
           s2 = s2 + 1;
45
@@ -747,13 +754,13 @@
46
              j++) {
47
           s = ((mdctSpectrumLeft[j] << s0) >> 1) +
48
               ((mdctSpectrumRight[j] << s0) >> 1);
49
-          es = fAddSaturate(es, fMultDiv2(s, s) >>
50
-                (MDCT_SPEC_SF -
51
-                 1));  // scaled 2*(mdctScale - s0 + 1) + MDCT_SPEC_SF
52
+          es += fMultDiv2(s, s) >>
53
+                (mdct_spec_sf -
54
+                 1);  // scaled 2*(mdctScale - s0 + 1) + mdct_spec_sf
55
         }
56
         msMask[sfb + sfboffs] = 0;
57
         tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], es, &s1);
58
-        s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF;
59
+        s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
60
         if (s2 & 1) {
61
           tmp = tmp >> 1;
62
           s2 = s2 + 1;
63
fdk-aac-2.0.1.tar.gz/libAACenc/src/qc_main.cpp -> fdk-aac-2.0.2.tar.gz/libAACenc/src/qc_main.cpp Changed
113
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -121,20 +121,15 @@
11
 
12
 static const TAB_VBR_QUAL_FACTOR tableVbrQualFactor[] = {
13
     {QCDATA_BR_MODE_VBR_1,
14
-     FL2FXCONST_DBL(0.160f)}, /* Approx. 32 -  48 (AC-LC),  32 -  56
15
-                                 (AAC-LD/ELD) kbps/channel */
16
+     FL2FXCONST_DBL(0.150f)}, /* Approx.  32 kbps mono   AAC-LC + SBR + PS */
17
     {QCDATA_BR_MODE_VBR_2,
18
-     FL2FXCONST_DBL(0.148f)}, /* Approx. 40 -  56 (AC-LC),  40 -  64
19
-                                 (AAC-LD/ELD) kbps/channel */
20
+     FL2FXCONST_DBL(0.162f)}, /* Approx.  64 kbps stereo AAC-LC + SBR      */
21
     {QCDATA_BR_MODE_VBR_3,
22
-     FL2FXCONST_DBL(0.135f)}, /* Approx. 48 -  64 (AC-LC),  48 -  72
23
-                                 (AAC-LD/ELD) kbps/channel */
24
+     FL2FXCONST_DBL(0.176f)}, /* Approx.  96 kbps stereo AAC-LC            */
25
     {QCDATA_BR_MODE_VBR_4,
26
-     FL2FXCONST_DBL(0.111f)}, /* Approx. 64 -  80 (AC-LC),  64 -  88
27
-                                 (AAC-LD/ELD) kbps/channel */
28
+     FL2FXCONST_DBL(0.120f)}, /* Approx. 128 kbps stereo AAC-LC            */
29
     {QCDATA_BR_MODE_VBR_5,
30
-     FL2FXCONST_DBL(0.070f)} /* Approx. 96 - 120 (AC-LC), 112 - 144
31
-                                (AAC-LD/ELD) kbps/channel */
32
+     FL2FXCONST_DBL(0.070f)} /* Approx. 192 kbps stereo AAC-LC            */
33
 };
34
 
35
 static INT isConstantBitrateMode(const QCDATA_BR_MODE bitrateMode) {
36
@@ -378,13 +373,8 @@
37
   hQC->invQuant = init->invQuant;
38
   hQC->maxIterations = init->maxIterations;
39
 
40
-  if (isConstantBitrateMode(hQC->bitrateMode)) {
41
-    /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir
42
-     */
43
-    hQC->bitResMode = init->bitResMode;
44
-  } else {
45
-    hQC->bitResMode = AACENC_BR_MODE_FULL; /* full bitreservoir */
46
-  }
47
+  /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */
48
+  hQC->bitResMode = init->bitResMode;
49
 
50
   hQC->padding.paddingRest = init->padding.paddingRest;
51
 
52
@@ -805,10 +795,15 @@
53
   INT avgTotalDynBits = 0; /* maximal allowed dynamic bits for all frames */
54
   INT totalAvailableBits = 0;
55
   INT nSubFrames = 1;
56
+  const INT isCBRAdjustment = (isConstantBitrateMode(hQC->bitrateMode) ||
57
+                               (hQC->bitResMode != AACENC_BR_MODE_FULL))
58
+                                  ? 1
59
+                                  : 0;
60
 
61
   /*-------------------------------------------- */
62
   /* redistribute total bitreservoir to elements */
63
-  ErrorStatus = FDKaacEnc_BitResRedistribution(hQC, cm, avgTotalBits);
64
+  ErrorStatus = FDKaacEnc_BitResRedistribution(
65
+      hQC, cm, (isCBRAdjustment == 0) ? hQC->maxBitsPerFrame : avgTotalBits);
66
   if (ErrorStatus != AAC_ENC_OK) {
67
     return ErrorStatus;
68
   }
69
@@ -836,33 +831,22 @@
70
 
71
   /*-------------------------------------------- */
72
   /*-------------------------------------------- */
73
-  if (isConstantBitrateMode(hQC->bitrateMode)) {
74
-    /* calc granted dynamic bits for sub frame and
75
-       distribute it to each element */
76
-    ErrorStatus = FDKaacEnc_prepareBitDistribution(
77
-        hQC, psyOut, qcOut, cm, qcElement, avgTotalBits, &totalAvailableBits,
78
-        &avgTotalDynBits);
79
-
80
-    if (ErrorStatus != AAC_ENC_OK) {
81
-      return ErrorStatus;
82
-    }
83
-  } else {
84
-    qcOut[0]->grantedDynBits =
85
-        ((hQC->maxBitsPerFrame - (hQC->globHdrBits)) & ~7) -
86
-        (qcOut[0]->globalExtBits + qcOut[0]->staticBits +
87
-         qcOut[0]->elementExtBits);
88
-    qcOut[0]->maxDynBits = qcOut[0]->grantedDynBits;
89
-
90
-    totalAvailableBits = hQC->maxBitsPerFrame;
91
-    avgTotalDynBits = 0;
92
+  /* calc granted dynamic bits for sub frame and
93
+     distribute it to each element */
94
+  ErrorStatus = FDKaacEnc_prepareBitDistribution(
95
+      hQC, psyOut, qcOut, cm, qcElement,
96
+      (isCBRAdjustment == 0) ? hQC->maxBitsPerFrame : avgTotalBits,
97
+      &totalAvailableBits, &avgTotalDynBits);
98
+
99
+  if (ErrorStatus != AAC_ENC_OK) {
100
+    return ErrorStatus;
101
   }
102
 
103
   /* for ( all sub frames ) ... */
104
   for (c = 0; c < nSubFrames; c++) {
105
     /* for CBR and VBR mode */
106
     FDKaacEnc_AdjustThresholds(hQC->hAdjThr, qcElement[c], qcOut[c],
107
-                               psyOut[c]->psyOutElement,
108
-                               isConstantBitrateMode(hQC->bitrateMode), cm);
109
+                               psyOut[c]->psyOutElement, isCBRAdjustment, cm);
110
 
111
   } /* -end- sub frame counter */
112
 
113
fdk-aac-2.0.1.tar.gz/libDRCdec/include/FDK_drcDecLib.h -> fdk-aac-2.0.2.tar.gz/libDRCdec/include/FDK_drcDecLib.h Changed
51
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -114,6 +114,8 @@
11
 extern "C" {
12
 #endif
13
 
14
+#define DRC_DEC_LOUDNESS_NOT_PRESENT (LONG)0x7FFFFFFE
15
+
16
 typedef struct s_drc_decoder* HANDLE_DRC_DECODER;
17
 typedef struct s_uni_drc_interface* HANDLE_UNI_DRC_INTERFACE;
18
 typedef struct s_selection_process_output* HANDLE_SEL_PROC_OUTPUT;
19
@@ -134,6 +136,7 @@
20
   DRC_DEC_EFFECT_TYPE,
21
   DRC_DEC_EFFECT_TYPE_FALLBACK_CODE,
22
   DRC_DEC_LOUDNESS_MEASUREMENT_METHOD,
23
+  DRC_DEC_ALBUM_MODE,
24
   /* set only system (not user) parameters */
25
   DRC_DEC_DOWNMIX_ID,
26
   DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED, /**< number of output channels
27
@@ -141,15 +144,20 @@
28
                                              choosing an appropriate
29
                                              downmixInstruction */
30
   DRC_DEC_BASE_CHANNEL_COUNT,
31
+  DRC_DEC_FRAME_SIZE,
32
+  DRC_DEC_SAMPLE_RATE,
33
   /* get only system parameters */
34
   DRC_DEC_IS_MULTIBAND_DRC_1,
35
   DRC_DEC_IS_MULTIBAND_DRC_2,
36
   DRC_DEC_IS_ACTIVE, /**< MPEG-D DRC payload is present and at least one of
37
                         Dynamic Range Control (DRC) or Loudness Normalization
38
                         (LN) is activated */
39
-  DRC_DEC_TARGET_CHANNEL_COUNT_SELECTED /**< number of output channels if
40
-                                           appropriate downmixInstruction exists
41
-                                         */
42
+  DRC_DEC_TARGET_CHANNEL_COUNT_SELECTED, /**< number of output channels if
43
+                                            appropriate downmixInstruction
44
+                                            exists */
45
+  DRC_DEC_OUTPUT_LOUDNESS /**< output loudness in dB, with exponent e = 7, or
46
+                             DRC_DEC_LOUDNESS_NOT_PRESENT if no loudness is
47
+                             contained in the bitstream */
48
 } DRC_DEC_USERPARAM;
49
 
50
 typedef enum {
51
fdk-aac-2.0.1.tar.gz/libDRCdec/src/FDK_drcDecLib.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/FDK_drcDecLib.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -112,7 +112,7 @@
11
 #define DRCDEC_LIB_VL1 1
12
 #define DRCDEC_LIB_VL2 0
13
 #define DRCDEC_LIB_TITLE "MPEG-D DRC Decoder Lib"
14
-#ifdef __ANDROID__
15
+#ifdef SUPPRESS_BUILD_DATE_INFO
16
 #define DRCDEC_LIB_BUILD_DATE ""
17
 #define DRCDEC_LIB_BUILD_TIME ""
18
 #else
19
@@ -145,6 +145,10 @@
20
   SEL_PROC_OUTPUT selProcOutput;
21
 } DRC_DECODER;
22
 
23
+static int _getGainStatus(HANDLE_UNI_DRC_GAIN hUniDrcGain) {
24
+  return hUniDrcGain->status;
25
+}
26
+
27
 static int isResetNeeded(HANDLE_DRC_DECODER hDrcDec,
28
                          const SEL_PROC_OUTPUT oldSelProcOutput) {
29
   int i, resetNeeded = 0;
30
@@ -173,13 +177,11 @@
31
   return resetNeeded;
32
 }
33
 
34
-static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
35
-  DRC_ERROR dErr = DE_OK;
36
-  DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
37
+static void startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) {
38
   int uniDrcConfigHasChanged = 0;
39
   SEL_PROC_OUTPUT oldSelProcOutput = hDrcDec->selProcOutput;
40
 
41
-  if (!hDrcDec->status) return DRC_DEC_NOT_READY;
42
+  if (!hDrcDec->status) return;
43
 
44
   if (hDrcDec->functionalRange & DRC_DEC_SELECTION) {
45
     uniDrcConfigHasChanged = hDrcDec->uniDrcConfig.diff;
46
@@ -189,10 +191,9 @@
47
        */
48
       hDrcDec->selProcOutput.numSelectedDrcSets = 0;
49
 
50
-      sErr = drcDec_SelectionProcess_Process(
51
+      drcDec_SelectionProcess_Process(
52
           hDrcDec->hSelectionProc, &(hDrcDec->uniDrcConfig),
53
           &(hDrcDec->loudnessInfoSet), &(hDrcDec->selProcOutput));
54
-      if (sErr) return DRC_DEC_OK;
55
 
56
       hDrcDec->selProcInputDiff = 0;
57
       hDrcDec->uniDrcConfig.diff = 0;
58
@@ -202,15 +203,12 @@
59
 
60
   if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
61
     if (isResetNeeded(hDrcDec, oldSelProcOutput) || uniDrcConfigHasChanged) {
62
-      dErr =
63
-          drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig),
64
-                                    hDrcDec->selProcOutput.numSelectedDrcSets,
65
-                                    hDrcDec->selProcOutput.selectedDrcSetIds,
66
-                                    hDrcDec->selProcOutput.selectedDownmixIds);
67
-      if (dErr) return DRC_DEC_OK;
68
+      drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig),
69
+                                hDrcDec->selProcOutput.numSelectedDrcSets,
70
+                                hDrcDec->selProcOutput.selectedDrcSetIds,
71
+                                hDrcDec->selProcOutput.selectedDownmixIds);
72
     }
73
   }
74
-  return DRC_DEC_OK;
75
 }
76
 
77
 DRC_DEC_ERROR
78
@@ -342,7 +340,13 @@
79
   }
80
 
81
   if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
82
-    dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec, frameSize, sampleRate);
83
+    dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE,
84
+                                       frameSize);
85
+    if (dErr) return DRC_DEC_NOT_OK;
86
+    dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE,
87
+                                       sampleRate);
88
+    if (dErr) return DRC_DEC_NOT_OK;
89
+    dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec);
90
     if (dErr) return DRC_DEC_NOT_OK;
91
   }
92
 
93
@@ -383,73 +387,99 @@
94
 FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec,
95
                     const DRC_DEC_USERPARAM requestType,
96
                     const FIXP_DBL requestValue) {
97
+  DRC_ERROR dErr = DE_OK;
98
   DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR;
99
+  int invalidParameter = 0;
100
 
101
   if (hDrcDec == NULL) return DRC_DEC_NOT_OPENED;
102
 
103
-  if (hDrcDec->functionalRange == DRC_DEC_GAIN)
104
-    return DRC_DEC_NOT_OK; /* not supported for DRC_DEC_GAIN. All parameters are
105
-                              handed over to selection process lib. */
106
+  if (hDrcDec->functionalRange & DRC_DEC_GAIN) {
107
+    switch (requestType) {
108
+      case DRC_DEC_SAMPLE_RATE:
109
+        dErr = drcDec_GainDecoder_SetParam(
110
+            hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE, (int)requestValue);
111
+        if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
112
+        break;
113
+      case DRC_DEC_FRAME_SIZE:
114
+        dErr = drcDec_GainDecoder_SetParam(
115
+            hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE, (int)requestValue);
116
+        if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
117
+        break;
118
+      default:
119
+        invalidParameter |= DRC_DEC_GAIN;
120
+    }
121
+  }
122
 
123
-  switch (requestType) {
124
-    case DRC_DEC_BOOST:
125
-      sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
126
-                                              SEL_PROC_BOOST, requestValue,
127
-                                              &(hDrcDec->selProcInputDiff));
128
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
129
-      break;
130
-    case DRC_DEC_COMPRESS:
131
-      sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
132
-                                              SEL_PROC_COMPRESS, requestValue,
133
-                                              &(hDrcDec->selProcInputDiff));
134
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
135
-      break;
136
-    case DRC_DEC_LOUDNESS_NORMALIZATION_ON:
137
-      sErr = drcDec_SelectionProcess_SetParam(
138
-          hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON,
139
-          requestValue, &(hDrcDec->selProcInputDiff));
140
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
141
-      break;
142
-    case DRC_DEC_TARGET_LOUDNESS:
143
-      sErr = drcDec_SelectionProcess_SetParam(
144
-          hDrcDec->hSelectionProc, SEL_PROC_TARGET_LOUDNESS, requestValue,
145
-          &(hDrcDec->selProcInputDiff));
146
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
147
-      break;
148
-    case DRC_DEC_EFFECT_TYPE:
149
-      sErr = drcDec_SelectionProcess_SetParam(
150
-          hDrcDec->hSelectionProc, SEL_PROC_EFFECT_TYPE, requestValue,
151
-          &(hDrcDec->selProcInputDiff));
152
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
153
-      break;
154
-    case DRC_DEC_DOWNMIX_ID:
155
-      sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
156
-                                              SEL_PROC_DOWNMIX_ID, requestValue,
157
-                                              &(hDrcDec->selProcInputDiff));
158
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
159
-      break;
160
-    case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED:
161
-      sErr = drcDec_SelectionProcess_SetParam(
162
-          hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT, requestValue,
163
-          &(hDrcDec->selProcInputDiff));
164
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
165
-      break;
166
-    case DRC_DEC_BASE_CHANNEL_COUNT:
167
-      sErr = drcDec_SelectionProcess_SetParam(
168
-          hDrcDec->hSelectionProc, SEL_PROC_BASE_CHANNEL_COUNT, requestValue,
169
-          &(hDrcDec->selProcInputDiff));
170
-      if (sErr) return DRC_DEC_NOT_OK;
171
-      break;
172
-    case DRC_DEC_LOUDNESS_MEASUREMENT_METHOD:
173
-      sErr = drcDec_SelectionProcess_SetParam(
174
-          hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
175
-          requestValue, &(hDrcDec->selProcInputDiff));
176
-      if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
177
-      break;
178
-    default:
179
-      return DRC_DEC_INVALID_PARAM;
180
+  if (hDrcDec->functionalRange & DRC_DEC_SELECTION) {
181
+    switch (requestType) {
182
+      case DRC_DEC_BOOST:
183
+        sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
184
+                                                SEL_PROC_BOOST, requestValue,
185
+                                                &(hDrcDec->selProcInputDiff));
186
+        if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
187
+        break;
188
+      case DRC_DEC_COMPRESS:
189
+        sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc,
190
+                                                SEL_PROC_COMPRESS, requestValue,
191
+                                                &(hDrcDec->selProcInputDiff));
192
+        if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
193
+        break;
194
+      case DRC_DEC_LOUDNESS_NORMALIZATION_ON:
195
+        sErr = drcDec_SelectionProcess_SetParam(
196
+            hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON,
197
+            requestValue, &(hDrcDec->selProcInputDiff));
198
+        if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE;
199
+        break;
200
+      case DRC_DEC_TARGET_LOUDNESS:
201
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_gainDecoder.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_gainDecoder.cpp Changed
65
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -170,11 +170,10 @@
11
 }
12
 
13
 DRC_ERROR
14
-drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
15
-                        const int sampleRate) {
16
+drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec) {
17
   DRC_ERROR err = DE_OK;
18
 
19
-  err = initGainDec(hGainDec, frameSize, sampleRate);
20
+  err = initGainDec(hGainDec);
21
   if (err) return err;
22
 
23
   initDrcGainBuffers(hGainDec->frameSize, &hGainDec->drcGainBuffers);
24
@@ -183,6 +182,25 @@
25
 }
26
 
27
 DRC_ERROR
28
+drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec,
29
+                            const GAIN_DEC_PARAM paramType,
30
+                            const int paramValue) {
31
+  switch (paramType) {
32
+    case GAIN_DEC_FRAME_SIZE:
33
+      if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE;
34
+      hGainDec->frameSize = paramValue;
35
+      break;
36
+    case GAIN_DEC_SAMPLE_RATE:
37
+      if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE;
38
+      hGainDec->deltaTminDefault = getDeltaTmin(paramValue);
39
+      break;
40
+    default:
41
+      return DE_PARAM_INVALID;
42
+  }
43
+  return DE_OK;
44
+}
45
+
46
+DRC_ERROR
47
 drcDec_GainDecoder_SetCodecDependentParameters(
48
     HANDLE_DRC_GAIN_DECODER hGainDec, const DELAY_MODE delayMode,
49
     const int timeDomainSupported,
50
@@ -279,9 +297,11 @@
51
   int seq, gainSequenceCount;
52
   DRC_COEFFICIENTS_UNI_DRC* pCoef =
53
       selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
54
-  if (pCoef == NULL) return DE_OK;
55
-
56
-  gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
57
+  if (pCoef && pCoef->gainSequenceCount) {
58
+    gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
59
+  } else {
60
+    gainSequenceCount = 1;
61
+  }
62
 
63
   for (seq = 0; seq < gainSequenceCount; seq++) {
64
     int lastNodeIndex = 0;
65
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_gainDecoder.h -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_gainDecoder.h Changed
34
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -134,6 +134,8 @@
11
   GAIN_DEC_DRC2_DRC3
12
 } GAIN_DEC_LOCATION;
13
 
14
+typedef enum { GAIN_DEC_FRAME_SIZE, GAIN_DEC_SAMPLE_RATE } GAIN_DEC_PARAM;
15
+
16
 typedef struct {
17
   FIXP_DBL gainLin; /* e = 7 */
18
   SHORT time;
19
@@ -195,8 +197,12 @@
20
 drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec);
21
 
22
 DRC_ERROR
23
-drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
24
-                        const int sampleRate);
25
+drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec);
26
+
27
+DRC_ERROR
28
+drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec,
29
+                            const GAIN_DEC_PARAM paramType,
30
+                            const int paramValue);
31
 
32
 DRC_ERROR
33
 drcDec_GainDecoder_SetCodecDependentParameters(
34
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_reader.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_reader.cpp Changed
120
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -185,17 +185,22 @@
11
     uniDrcConfigPresent = FDKreadBits(hBs, 1);
12
     if (uniDrcConfigPresent) {
13
       err = drcDec_readUniDrcConfig(hBs, hUniDrcConfig);
14
-      if (err) return err;
15
+      if (err) {
16
+        /* clear config, if parsing error occured */
17
+        FDKmemclear(hUniDrcConfig, sizeof(UNI_DRC_CONFIG));
18
+        hUniDrcConfig->diff = 1;
19
+      }
20
     }
21
     err = drcDec_readLoudnessInfoSet(hBs, hLoudnessInfoSet);
22
-    if (err) return err;
23
+    if (err) {
24
+      /* clear config, if parsing error occured */
25
+      FDKmemclear(hLoudnessInfoSet, sizeof(LOUDNESS_INFO_SET));
26
+      hLoudnessInfoSet->diff = 1;
27
+    }
28
   }
29
 
30
-  if (hUniDrcGain != NULL) {
31
-    err = drcDec_readUniDrcGain(hBs, hUniDrcConfig, frameSize, deltaTminDefault,
32
-                                hUniDrcGain);
33
-    if (err) return err;
34
-  }
35
+  err = drcDec_readUniDrcGain(hBs, hUniDrcConfig, frameSize, deltaTminDefault,
36
+                              hUniDrcGain);
37
 
38
   return err;
39
 }
40
@@ -479,10 +484,13 @@
41
   int seq, gainSequenceCount;
42
   DRC_COEFFICIENTS_UNI_DRC* pCoef =
43
       selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
44
-  if (pCoef == NULL) return DE_OK;
45
-  if (hUniDrcGain == NULL) return DE_OK; /* hUniDrcGain not initialized yet */
46
-
47
-  gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
48
+  if (hUniDrcGain == NULL) return DE_NOT_OK;
49
+  hUniDrcGain->status = 0;
50
+  if (pCoef) {
51
+    gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
52
+  } else {
53
+    gainSequenceCount = 0;
54
+  }
55
 
56
   for (seq = 0; seq < gainSequenceCount; seq++) {
57
     UCHAR index = pCoef->gainSetIndexForGainSequence[seq];
58
@@ -510,6 +518,9 @@
59
     if (err) return err;
60
   }
61
 
62
+  if (err == DE_OK && gainSequenceCount > 0) {
63
+    hUniDrcGain->status = 1;
64
+  }
65
   return err;
66
 }
67
 
68
@@ -903,7 +914,7 @@
69
       firFilterOrder;
70
   int uniqueEqSubbandGainsCount, eqSubbandGainRepresentation,
71
       eqSubbandGainCount;
72
-  EQ_SUBBAND_GAIN_FORMAT eqSubbandGainFormat;
73
+  int eqSubbandGainFormat;
74
 
75
   eqDelayMaxPresent = FDKreadBits(hBs, 1);
76
   if (eqDelayMaxPresent) {
77
@@ -944,7 +955,7 @@
78
   uniqueEqSubbandGainsCount = FDKreadBits(hBs, 6);
79
   if (uniqueEqSubbandGainsCount > 0) {
80
     eqSubbandGainRepresentation = FDKreadBits(hBs, 1);
81
-    eqSubbandGainFormat = (EQ_SUBBAND_GAIN_FORMAT)FDKreadBits(hBs, 4);
82
+    eqSubbandGainFormat = FDKreadBits(hBs, 4);
83
     switch (eqSubbandGainFormat) {
84
       case GF_QMF32:
85
         eqSubbandGainCount = 32;
86
@@ -1010,6 +1021,7 @@
87
   int additionalDrcSetIdPresent, additionalDrcSetIdCount;
88
   int dependsOnEqSetPresent, eqChannelGroupCount, tdFilterCascadePresent,
89
       subbandGainsPresent, eqTransitionDurationPresent;
90
+  UCHAR eqChannelGroupForChannel[8];
91
 
92
   FDKpushFor(hBs, 6); /* eqSetId */
93
   FDKpushFor(hBs, 4); /* eqSetComplexityLevel */
94
@@ -1059,7 +1071,6 @@
95
 
96
   eqChannelGroupCount = 0;
97
   for (c = 0; c < channelCount; c++) {
98
-    UCHAR eqChannelGroupForChannel[8];
99
     int newGroup = 1;
100
     if (c >= 8) return DE_MEMORY_ERROR;
101
     eqChannelGroupForChannel[c] = FDKreadBits(hBs, 7);
102
@@ -1130,7 +1141,7 @@
103
     drcCharacteristicLeftPresent = FDKreadBits(hBs, 1);
104
     if (drcCharacteristicLeftPresent) {
105
       pCoef->characteristicLeftCount = FDKreadBits(hBs, 4);
106
-      if ((pCoef->characteristicLeftCount + 1) > 8) return DE_MEMORY_ERROR;
107
+      if ((pCoef->characteristicLeftCount + 1) > 16) return DE_MEMORY_ERROR;
108
       for (i = 0; i < pCoef->characteristicLeftCount; i++) {
109
         err = _readCustomDrcCharacteristic(
110
             hBs, CS_LEFT, &(pCoef->characteristicLeftFormat[i + 1]),
111
@@ -1141,7 +1152,7 @@
112
     drcCharacteristicRightPresent = FDKreadBits(hBs, 1);
113
     if (drcCharacteristicRightPresent) {
114
       pCoef->characteristicRightCount = FDKreadBits(hBs, 4);
115
-      if ((pCoef->characteristicRightCount + 1) > 8) return DE_MEMORY_ERROR;
116
+      if ((pCoef->characteristicRightCount + 1) > 16) return DE_MEMORY_ERROR;
117
       for (i = 0; i < pCoef->characteristicRightCount; i++) {
118
         err = _readCustomDrcCharacteristic(
119
             hBs, CS_RIGHT, &(pCoef->characteristicRightFormat[i + 1]),
120
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_selectionProcess.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_selectionProcess.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -103,8 +103,6 @@
11
 #include "drcDec_selectionProcess.h"
12
 #include "drcDec_tools.h"
13
 
14
-#define UNDEFINED_LOUDNESS_VALUE (FIXP_DBL) MAXVAL_DBL
15
-
16
 typedef enum {
17
   DETR_NONE = 0,
18
   DETR_NIGHT = 1,
19
@@ -555,6 +553,11 @@
20
       diff |= _compAssign(&pSelProcInput->loudnessMeasurementMethod,
21
                           requestValueInt);
22
       break;
23
+    case SEL_PROC_ALBUM_MODE:
24
+      if ((requestValueInt < 0) || (requestValueInt > 1))
25
+        return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
26
+      diff |= _compAssign(&pSelProcInput->albumMode, requestValueInt);
27
+      break;
28
     case SEL_PROC_DOWNMIX_ID:
29
       diff |=
30
           _compAssign(&pSelProcInput->targetConfigRequestType, TCRT_DOWNMIX_ID);
31
@@ -598,14 +601,21 @@
32
       if ((requestValue < (FIXP_DBL)0) ||
33
           (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1))))
34
         return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
35
-      diff |= _compAssign(&pSelProcInput->boost, FX_DBL2FX_SGL(requestValue));
36
+      diff |= _compAssign(
37
+          &pSelProcInput->boost,
38
+          FX_DBL2FX_SGL(
39
+              requestValue +
40
+              (FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */
41
       break;
42
     case SEL_PROC_COMPRESS:
43
       if ((requestValue < (FIXP_DBL)0) ||
44
           (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1))))
45
         return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE;
46
-      diff |=
47
-          _compAssign(&pSelProcInput->compress, FX_DBL2FX_SGL(requestValue));
48
+      diff |= _compAssign(
49
+          &pSelProcInput->compress,
50
+          FX_DBL2FX_SGL(
51
+              requestValue +
52
+              (FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */
53
       break;
54
     default:
55
       return DRCDEC_SELECTION_PROCESS_INVALID_PARAM;
56
@@ -741,8 +751,8 @@
57
   hSelProcInput->loudnessNormalizationOn = 1;
58
   hSelProcInput->targetLoudness = FL2FXCONST_DBL(-24.0f / (float)(1 << 7));
59
   hSelProcInput->loudnessDeviationMax = DEFAULT_LOUDNESS_DEVIATION_MAX;
60
-  hSelProcInput->loudnessMeasurementMethod = MDR_DEFAULT;
61
-  hSelProcInput->loudnessMeasurementSystem = MSR_DEFAULT;
62
+  hSelProcInput->loudnessMeasurementMethod = MDR_ANCHOR_LOUDNESS;
63
+  hSelProcInput->loudnessMeasurementSystem = MSR_EXPERT_PANEL;
64
   hSelProcInput->loudnessMeasurementPreProc = LPR_DEFAULT;
65
   hSelProcInput->deviceCutOffFrequency = 500;
66
   hSelProcInput->loudnessNormalizationGainDbMax =
67
@@ -944,17 +954,31 @@
68
   return DRCDEC_SELECTION_PROCESS_NO_ERROR;
69
 }
70
 
71
-/* #5: The number of DRC bands is supported. */
72
+/* #5: The number of DRC bands is supported. Moreover, gainSetIndex and
73
+ * gainSequenceIndex are within the allowed range. */
74
 static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement5(
75
     DRC_INSTRUCTIONS_UNI_DRC* pDrcInstructionUniDrc,
76
     DRC_COEFFICIENTS_UNI_DRC* pCoef, int* pMatchFound) {
77
-  int i;
78
+  int b, i;
79
 
80
   *pMatchFound = 1;
81
 
82
+  if (pDrcInstructionUniDrc->drcSetId < 0) /* virtual DRC sets are okay */
83
+  {
84
+    return DRCDEC_SELECTION_PROCESS_NO_ERROR;
85
+  }
86
+
87
   if (pCoef == NULL) /* check for parametricDRC */
88
   {
89
-    *pMatchFound = 1;
90
+    *pMatchFound = 0; /* parametricDRC not supported */
91
+    return DRCDEC_SELECTION_PROCESS_NO_ERROR;
92
+  }
93
+
94
+  if (pCoef->drcLocation !=
95
+      pDrcInstructionUniDrc
96
+          ->drcLocation) /* drcLocation must be LOCATION_SELECTED */
97
+  {
98
+    *pMatchFound = 0;
99
     return DRCDEC_SELECTION_PROCESS_NO_ERROR;
100
   }
101
 
102
@@ -962,10 +986,14 @@
103
     int indexDrcCoeff = pDrcInstructionUniDrc->gainSetIndexForChannelGroup[i];
104
     int bandCount = 0;
105
 
106
+    if (indexDrcCoeff >= 12) {
107
+      *pMatchFound = 0;
108
+      return DRCDEC_SELECTION_PROCESS_NO_ERROR;
109
+    }
110
+
111
     if (indexDrcCoeff > pCoef->gainSetCount - 1) /* check for parametricDRC */
112
     {
113
-      *pMatchFound = 1;
114
-      return DRCDEC_SELECTION_PROCESS_NO_ERROR;
115
+      continue;
116
     }
117
 
118
     GAIN_SET* gainSet = &(pCoef->gainSet[indexDrcCoeff]);
119
@@ -974,6 +1002,14 @@
120
     if (bandCount > 4) {
121
       *pMatchFound = 0;
122
     }
123
+
124
+    for (b = 0; b < bandCount; b++) {
125
+      if ((gainSet->gainSequenceIndex[b] >= 12) ||
126
+          (gainSet->gainSequenceIndex[b] >= pCoef->gainSequenceCount)) {
127
+        *pMatchFound = 0;
128
+        return DRCDEC_SELECTION_PROCESS_NO_ERROR;
129
+      }
130
+    }
131
   }
132
 
133
   return DRCDEC_SELECTION_PROCESS_NO_ERROR;
134
@@ -1066,6 +1102,19 @@
135
   return retVal;
136
 }
137
 
138
+static int _drcSetIsUsable(HANDLE_UNI_DRC_CONFIG hUniDrcConfig,
139
+                           DRC_INSTRUCTIONS_UNI_DRC* pInst) {
140
+  int usable = 0;
141
+  DRC_COEFFICIENTS_UNI_DRC* pCoef =
142
+      selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
143
+
144
+  /* check if ID is unique */
145
+  if (selectDrcInstructions(hUniDrcConfig, pInst->drcSetId) != pInst) return 0;
146
+  /* sanity check on drcInstructions */
147
+  _preSelectionRequirement5(pInst, pCoef, &usable);
148
+  return usable;
149
+}
150
+
151
 /* #8: The range of the target loudness specified for a DRC set has to include
152
  * the requested decoder target loudness. */
153
 static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement8(
154
@@ -1085,9 +1134,8 @@
155
 
156
   FIXP_DBL loudnessDeviationMax =
157
       ((FIXP_DBL)hSelProcInput->loudnessDeviationMax) << (DFRACT_BITS - 1 - 7);
158
-  ;
159
 
160
-  if (hSelProcInput->loudnessNormalizationOn) {
161
+  {
162
     retVal = _getLoudness(hLoudnessInfoSet, hSelProcInput->albumMode,
163
                           hSelProcInput->loudnessMeasurementMethod,
164
                           hSelProcInput->loudnessMeasurementSystem,
165
@@ -1096,9 +1144,10 @@
166
                           hSelProcInput->downmixIdRequested[downmixIdIndex],
167
                           &loudnessNormalizationGainDb, &loudness);
168
     if (retVal) return (retVal);
169
-  } else {
170
+  }
171
+
172
+  if (!hSelProcInput->loudnessNormalizationOn) {
173
     loudnessNormalizationGainDb = (FIXP_DBL)0;
174
-    loudness = UNDEFINED_LOUDNESS_VALUE;
175
   }
176
 
177
   retVal = _getSignalPeakLevel(
178
@@ -2019,6 +2068,7 @@
179
       pSelectionData->loudnessNormalizationGainDbAdjusted +
180
       hSelProcInput->loudnessNormalizationGainModificationDb;
181
   hSelProcOutput->outputPeakLevelDb = pSelectionData->outputPeakLevel;
182
+  hSelProcOutput->outputLoudness = pSelectionData->outputLoudness;
183
 
184
   hSelProcOutput->boost = boost;
185
   hSelProcOutput->compress = compress;
186
@@ -2039,8 +2089,11 @@
187
     int dependsOnDrcSetID = pSelectionData->pInst->dependsOnDrcSet;
188
 
189
     for (i = 0; i < hUniDrcConfig->drcInstructionsCountInclVirtual; i++) {
190
-      if (hUniDrcConfig->drcInstructionsUniDrc[i].drcSetId ==
191
-          dependsOnDrcSetID) {
192
+      DRC_INSTRUCTIONS_UNI_DRC* pInst =
193
+          &(hUniDrcConfig->drcInstructionsUniDrc[i]);
194
+      if (!_drcSetIsUsable(hUniDrcConfig, pInst)) continue;
195
+
196
+      if (pInst->drcSetId == dependsOnDrcSetID) {
197
         hSelProcOutput->selectedDrcSetIds[hSelProcOutput->numSelectedDrcSets] =
198
             hUniDrcConfig->drcInstructionsUniDrc[i].drcSetId;
199
         hSelProcOutput->selectedDownmixIds[hSelProcOutput->numSelectedDrcSets] =
200
@@ -2059,6 +2112,7 @@
201
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_selectionProcess.h -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_selectionProcess.h Changed
27
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -111,6 +111,8 @@
11
 
12
 typedef struct s_drcdec_selection_process* HANDLE_DRC_SELECTION_PROCESS;
13
 
14
+#define UNDEFINED_LOUDNESS_VALUE (FIXP_DBL)(MAXVAL_DBL - 1)
15
+
16
 typedef enum {
17
   DRCDEC_SELECTION_PROCESS_NO_ERROR = 0,
18
 
19
@@ -146,6 +148,7 @@
20
   SEL_PROC_EFFECT_TYPE,
21
   SEL_PROC_EFFECT_TYPE_FALLBACK_CODE,
22
   SEL_PROC_LOUDNESS_MEASUREMENT_METHOD,
23
+  SEL_PROC_ALBUM_MODE,
24
   SEL_PROC_DOWNMIX_ID,
25
   SEL_PROC_TARGET_LAYOUT,
26
   SEL_PROC_TARGET_CHANNEL_COUNT,
27
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcDec_types.h -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcDec_types.h Changed
27
 
1
@@ -130,6 +130,9 @@
2
 
3
   UCHAR uniDrcGainExtPresent;
4
   UNI_DRC_GAIN_EXTENSION uniDrcGainExtension;
5
+
6
+  /* derived data */
7
+  UCHAR status;
8
 } UNI_DRC_GAIN, *HANDLE_UNI_DRC_GAIN;
9
 
10
 /****************/
11
@@ -249,11 +252,11 @@
12
   UCHAR drcFrameSizePresent;
13
   USHORT drcFrameSize;
14
   UCHAR characteristicLeftCount;
15
-  UCHAR characteristicLeftFormat[8];
16
-  CUSTOM_DRC_CHAR customCharacteristicLeft[8];
17
+  UCHAR characteristicLeftFormat[16];
18
+  CUSTOM_DRC_CHAR customCharacteristicLeft[16];
19
   UCHAR characteristicRightCount;
20
-  UCHAR characteristicRightFormat[8];
21
-  CUSTOM_DRC_CHAR customCharacteristicRight[8];
22
+  UCHAR characteristicRightFormat[16];
23
+  CUSTOM_DRC_CHAR customCharacteristicRight[16];
24
   UCHAR
25
   gainSequenceCount;  /* unsaturated value, i.e. as provided in bitstream */
26
   UCHAR gainSetCount; /* saturated to 12 */
27
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcGainDec_init.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcGainDec_init.cpp Changed
52
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -184,24 +184,11 @@
11
 }
12
 
13
 DRC_ERROR
14
-initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
15
-            const int sampleRate) {
16
+initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec) {
17
   int i, j, k;
18
 
19
-  if (frameSize < 1) {
20
-    return DE_NOT_OK;
21
-  }
22
-
23
-  hGainDec->frameSize = frameSize;
24
-
25
-  if (hGainDec->frameSize * 1000 < sampleRate) {
26
-    return DE_NOT_OK;
27
-  }
28
-
29
-  hGainDec->deltaTminDefault = getDeltaTmin(sampleRate);
30
-  if (hGainDec->deltaTminDefault > hGainDec->frameSize) {
31
-    return DE_NOT_OK;
32
-  }
33
+  /* sanity check */
34
+  if (hGainDec->deltaTminDefault > hGainDec->frameSize) return DE_NOT_OK;
35
 
36
   for (i = 0; i < MAX_ACTIVE_DRCS; i++) {
37
     for (j = 0; j < 8; j++) {
38
@@ -336,9 +323,11 @@
39
   for (a = 0; a < hGainDec->nActiveDrcs; a++) {
40
     hGainDec->activeDrc[a].activeDrcOffset = accGainElementCount;
41
     accGainElementCount += hGainDec->activeDrc[a].gainElementCount;
42
+    if (accGainElementCount > 12) {
43
+      hGainDec->nActiveDrcs = a;
44
+      return DE_NOT_OK;
45
+    }
46
   }
47
 
48
-  if (accGainElementCount > 12) return DE_NOT_OK;
49
-
50
   return DE_OK;
51
 }
52
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcGainDec_init.h -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcGainDec_init.h Changed
20
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -104,8 +104,7 @@
11
 #define DRCGAINDEC_INIT_H
12
 
13
 DRC_ERROR
14
-initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize,
15
-            const int sampleRate);
16
+initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec);
17
 
18
 void initDrcGainBuffers(const int frameSize, DRC_GAIN_BUFFERS* drcGainBuffers);
19
 
20
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcGainDec_preprocess.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcGainDec_preprocess.cpp Changed
36
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -285,6 +285,9 @@
11
                   &e_tmp2);
12
   invExp = fDivNorm(FL2FXCONST_DBL(1.0f / (float)(1 << 1)), exp, &e_invExp);
13
   e_invExp += 1 - 5;
14
+  if (tmp2 < (FIXP_DBL)0) {
15
+    return DE_NOT_OK;
16
+  }
17
   denom = fPow(tmp2, e_tmp2, invExp, e_invExp, &e_denom);
18
   *out = fDivNormSigned(tmp, denom, &e_out);
19
   e_out += 7 - e_denom;
20
@@ -676,7 +679,6 @@
21
       nDrcBands = pActiveDrc->bandCountForChannelGroup[g];
22
       for (b = 0; b < nDrcBands; b++) {
23
         DRC_ERROR err = DE_OK;
24
-        if (gainSetIndex >= 12) return DE_PARAM_OUT_OF_RANGE;
25
         GAIN_SET* pGainSet = &(pCoef->gainSet[gainSetIndex]);
26
         int seq = pGainSet->gainSequenceIndex[b];
27
         DRC_CHARACTERISTIC* pDChar = &(pGainSet->drcCharacteristic[b]);
28
@@ -695,7 +697,6 @@
29
         err = _prepareDrcCharacteristic(pDChar, pCoef, b, &nodeMod);
30
         if (err) return err;
31
 
32
-        if (seq >= 12) return DE_PARAM_OUT_OF_RANGE;
33
         /* copy a node buffer and convert from dB to linear */
34
         pLnb->nNodes[lnbp] = fMin((int)hUniDrcGain->nNodes[seq], 16);
35
         for (i = 0; i < pLnb->nNodes[lnbp]; i++) {
36
fdk-aac-2.0.1.tar.gz/libDRCdec/src/drcGainDec_process.cpp -> fdk-aac-2.0.2.tar.gz/libDRCdec/src/drcGainDec_process.cpp Changed
10
 
1
@@ -308,8 +308,6 @@
2
               pLinearNodeBuffer[pActiveDrc->lnbIndexForChannel[c][lnbIx] + b]);
3
         else
4
           pLnbPrevious = pDummyLnb;
5
-        if (pLnbPrevious->nNodes[lnbIx] <= 0 || pLnbPrevious->nNodes[lnbIx] > 16)
6
-          return DE_NOT_OK;
7
         nodePrevious =
8
             pLnbPrevious->linearNode[lnbIx][pLnbPrevious->nNodes[lnbIx] - 1];
9
         nodePrevious.time -= hGainDec->frameSize;
10
fdk-aac-2.0.1.tar.gz/libFDK/include/FDK_qmf_domain.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/FDK_qmf_domain.h Changed
71
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -123,11 +123,10 @@
11
 #define QMF_WB_SECTION_SIZE (1024 * 2)
12
 
13
 H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore1, FIXP_DBL)
14
-H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore2, FIXP_DBL)
15
 H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore3, FIXP_DBL)
16
 H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore4, FIXP_DBL)
17
-H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore5, FIXP_DBL)
18
 H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore6, FIXP_DBL)
19
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore7, FIXP_DBL)
20
 
21
 #define QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS (64)
22
 #define QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS (QMF_MAX_SYNTHESIS_BANDS)
23
@@ -145,15 +144,15 @@
24
 #define QMF_DOMAIN_OV_TIMESLOTS_16 (3)
25
 #define QMF_DOMAIN_OV_TIMESLOTS_32 (6)
26
 
27
-H_ALLOC_MEM(AnaQmfStates, FIXP_QAS)
28
+H_ALLOC_MEM(AnaQmfStates, FIXP_DBL)
29
 H_ALLOC_MEM(SynQmfStates, FIXP_QSS)
30
 H_ALLOC_MEM(QmfSlotsReal, FIXP_DBL *)
31
 H_ALLOC_MEM(QmfSlotsImag, FIXP_DBL *)
32
 H_ALLOC_MEM(QmfOverlapBuffer, FIXP_DBL)
33
 
34
-H_ALLOC_MEM(AnaQmfStates16, FIXP_QAS)
35
-H_ALLOC_MEM(AnaQmfStates24, FIXP_QAS)
36
-H_ALLOC_MEM(AnaQmfStates32, FIXP_QAS)
37
+H_ALLOC_MEM(AnaQmfStates16, FIXP_DBL)
38
+H_ALLOC_MEM(AnaQmfStates24, FIXP_DBL)
39
+H_ALLOC_MEM(AnaQmfStates32, FIXP_DBL)
40
 H_ALLOC_MEM(QmfSlotsReal16, FIXP_DBL *)
41
 H_ALLOC_MEM(QmfSlotsReal32, FIXP_DBL *)
42
 H_ALLOC_MEM(QmfSlotsImag16, FIXP_DBL *)
43
@@ -161,8 +160,6 @@
44
 H_ALLOC_MEM(QmfOverlapBuffer16, FIXP_DBL)
45
 H_ALLOC_MEM(QmfOverlapBuffer32, FIXP_DBL)
46
 
47
-#define QDOM_PCM INT_PCM
48
-
49
 /**
50
  * Structure to hold the configuration data which is global whithin a QMF domain
51
  * instance.
52
@@ -182,9 +179,6 @@
53
                   park a channel if only one processing channel is
54
                   available. */
55
   UCHAR parkChannel_requested;
56
-  QDOM_PCM
57
-  *TDinput; /*!< Pointer to time domain data used as input for the QMF
58
-               analysis. */
59
   FIXP_DBL *
60
       pWorkBuffer[QMF_MAX_WB_SECTIONS]; /*!< Pointerarray to volatile memory. */
61
   UINT flags; /*!< Flags to be set on all QMF analysis/synthesis filter
62
@@ -244,7 +238,7 @@
63
                                 (workBuf_nTimeSlots * workBuf_nBands * CMPLX_MOD). */
64
   USHORT workBufferOffset;   /*!< Offset within work buffer. */
65
   USHORT workBufferSectSize; /*!< Size of work buffer section. */
66
-  FIXP_QAS *
67
+  FIXP_DBL *
68
       pAnaQmfStates; /*!< Pointer to QMF analysis states (persistent memory). */
69
   FIXP_DBL
70
   *pOverlapBuffer;        /*!< Pointer to QMF overlap/delay memory (persistent
71
fdk-aac-2.0.1.tar.gz/libFDK/include/fixpoint_math.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/fixpoint_math.h Changed
84
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -171,6 +171,19 @@
11
  * \return non-zero if (a_m*2^a_e) < (b_m*2^b_e), 0 otherwise
12
  */
13
 FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e) {
14
+  INT n;
15
+
16
+  n = fixnorm_D(a_m);
17
+  a_m <<= n;
18
+  a_e -= n;
19
+
20
+  n = fixnorm_D(b_m);
21
+  b_m <<= n;
22
+  b_e -= n;
23
+
24
+  if (a_m == (FIXP_DBL)0) a_e = b_e;
25
+  if (b_m == (FIXP_DBL)0) b_e = a_e;
26
+
27
   if (a_e > b_e) {
28
     return ((b_m >> fMin(a_e - b_e, DFRACT_BITS - 1)) > a_m);
29
   } else {
30
@@ -179,6 +192,19 @@
31
 }
32
 
33
 FDK_INLINE INT fIsLessThan(FIXP_SGL a_m, INT a_e, FIXP_SGL b_m, INT b_e) {
34
+  INT n;
35
+
36
+  n = fixnorm_S(a_m);
37
+  a_m <<= n;
38
+  a_e -= n;
39
+
40
+  n = fixnorm_S(b_m);
41
+  b_m <<= n;
42
+  b_e -= n;
43
+
44
+  if (a_m == (FIXP_SGL)0) a_e = b_e;
45
+  if (b_m == (FIXP_SGL)0) b_e = a_e;
46
+
47
   if (a_e > b_e) {
48
     return ((b_m >> fMin(a_e - b_e, FRACT_BITS - 1)) > a_m);
49
   } else {
50
@@ -545,15 +571,20 @@
51
   m = fMultNorm(a, (FIXP_DBL)b, &m_e);
52
 
53
   if (m_e < (INT)0) {
54
-    if (m_e > (INT)-DFRACT_BITS) {
55
+    if (m_e > (INT) - (DFRACT_BITS - 1)) {
56
       mi = (m >> (-m_e));
57
       if ((LONG)m & ((1 << (-m_e)) - 1)) {
58
         mi = mi + (FIXP_DBL)1;
59
       }
60
     } else {
61
-      mi = (FIXP_DBL)1;
62
-      if (m < (FIXP_DBL)0) {
63
-        mi = (FIXP_DBL)0;
64
+      if (m > (FIXP_DBL)0) {
65
+        mi = (FIXP_DBL)1;
66
+      } else {
67
+        if ((m_e == -(DFRACT_BITS - 1)) && (m == (FIXP_DBL)MINVAL_DBL)) {
68
+          mi = (FIXP_DBL)-1;
69
+        } else {
70
+          mi = (FIXP_DBL)0;
71
+        }
72
       }
73
     }
74
   } else {
75
@@ -744,7 +775,7 @@
76
 
77
 /**
78
  * \brief return (base_m * 2^base_e) ^ N
79
- * \param base_m mantissa of the base
80
+ * \param base_m mantissa of the base. Must not be negative.
81
  * \param base_e exponent of the base
82
  * \param N power to be calculated of the base
83
  * \param result_e pointer to a INT where the exponent of the result will be
84
fdk-aac-2.0.1.tar.gz/libFDK/include/mdct.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/mdct.h Changed
34
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -106,18 +106,16 @@
11
 #include "common_fix.h"
12
 
13
 #define MDCT_OUT_HEADROOM 2 /* Output additional headroom */
14
-#define PCM_OUT_BITS SAMPLE_BITS
15
+
16
+#define PCM_OUT_BITS DFRACT_BITS
17
 #define PCM_OUT_HEADROOM 8 /* Must have the same values as DMXH_HEADROOM */
18
 
19
-#define MDCT_OUTPUT_SCALE (-MDCT_OUT_HEADROOM + (DFRACT_BITS - SAMPLE_BITS))
20
+#define MDCT_OUTPUT_SCALE (-MDCT_OUT_HEADROOM + (DFRACT_BITS - PCM_OUT_BITS))
21
 /* Refer to "Output word length" in ISO/IEC 14496-3:2008(E) 23.2.3.6 */
22
 #define MDCT_OUTPUT_GAIN 16
23
 
24
-#if (MDCT_OUTPUT_SCALE >= 0)
25
-#define IMDCT_SCALE(x) SATURATE_RIGHT_SHIFT(x, MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
26
-#else
27
-#define IMDCT_SCALE(x) SATURATE_LEFT_SHIFT(x, -MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
28
-#endif
29
+#define IMDCT_SCALE(x, s) \
30
+  SATURATE_RIGHT_SHIFT((x), ((s) + MDCT_OUTPUT_SCALE), PCM_OUT_BITS)
31
 #define IMDCT_SCALE_DBL(x) (FIXP_DBL)(x)
32
 #define IMDCT_SCALE_DBL_LSH1(x) SATURATE_LEFT_SHIFT_ALT((x), 1, DFRACT_BITS)
33
 
34
fdk-aac-2.0.1.tar.gz/libFDK/include/mips/abs_mips.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/mips/abs_mips.h Changed
10
 
1
@@ -107,7 +107,7 @@
2
 
3
 #if defined(__GNUC__) && defined(__mips__)
4
 
5
-#if defined(__mips_dsp)
6
+#if defined(__mips_dsp) && !defined(__mips16)
7
 #define FUNCTION_fixabs_D
8
 #define FUNCTION_fixabs_I
9
 #define FUNCTION_fixabs_S
10
fdk-aac-2.0.1.tar.gz/libFDK/include/mips/scale_mips.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/mips/scale_mips.h Changed
10
 
1
@@ -103,7 +103,7 @@
2
 #ifndef SCALE_MIPS_H
3
 #define SCALE_MIPS_H
4
 
5
-#if defined(__mips_dsp)
6
+#if defined(__mips_dsp) && !defined(__mips16)
7
 
8
 /*!
9
  *
10
fdk-aac-2.0.1.tar.gz/libFDK/include/qmf.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/qmf.h Changed
177
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -116,6 +116,7 @@
11
 
12
 #define FIXP_QAS FIXP_PCM
13
 #define QAS_BITS SAMPLE_BITS
14
+#define INT_PCM_QMFIN INT_PCM
15
 
16
 #define FIXP_QSS FIXP_DBL
17
 #define QSS_BITS DFRACT_BITS
18
@@ -201,66 +202,70 @@
19
 
20
 typedef struct QMF_FILTER_BANK *HANDLE_QMF_FILTER_BANK;
21
 
22
+int qmfInitAnalysisFilterBank(
23
+    HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
24
+    FIXP_QAS *pFilterStates,      /*!< Pointer to filter state buffer */
25
+    int noCols,                   /*!< Number of time slots  */
26
+    int lsb,                      /*!< Number of lower bands */
27
+    int usb,                      /*!< Number of upper bands */
28
+    int no_channels,              /*!< Number of critically sampled bands */
29
+    int flags);                   /*!< Flags */
30
+#if SAMPLE_BITS == 16
31
+
32
+int qmfInitAnalysisFilterBank(
33
+    HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
34
+    FIXP_DBL *pFilterStates,      /*!< Pointer to filter state buffer */
35
+    int noCols,                   /*!< Number of time slots  */
36
+    int lsb,                      /*!< Number of lower bands */
37
+    int usb,                      /*!< Number of upper bands */
38
+    int no_channels,              /*!< Number of critically sampled bands */
39
+    int flags);                   /*!< Flags */
40
+#endif
41
+
42
 void qmfAnalysisFiltering(
43
     HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank   */
44
     FIXP_DBL **qmfReal,            /*!< Pointer to real subband slots */
45
     FIXP_DBL **qmfImag,            /*!< Pointer to imag subband slots */
46
     QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data     */
47
-    const LONG *timeIn,            /*!< Time signal */
48
+    const INT_PCM *timeIn,         /*!< Time signal */
49
     const int timeIn_e,            /*!< Exponent of audio data        */
50
     const int stride,              /*!< Stride factor of audio data   */
51
-    FIXP_DBL *pWorkBuffer          /*!< pointer to temporary working buffer */
52
+    FIXP_DBL *pWorkBuffer          /*!< pointer to temporal working buffer */
53
 );
54
+#if SAMPLE_BITS == 16
55
 
56
 void qmfAnalysisFiltering(
57
     HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank   */
58
     FIXP_DBL **qmfReal,            /*!< Pointer to real subband slots */
59
     FIXP_DBL **qmfImag,            /*!< Pointer to imag subband slots */
60
     QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data     */
61
-    const INT_PCM *timeIn,         /*!< Time signal */
62
+    const LONG *timeIn,            /*!< Time signal */
63
     const int timeIn_e,            /*!< Exponent of audio data        */
64
     const int stride,              /*!< Stride factor of audio data   */
65
-    FIXP_DBL *pWorkBuffer          /*!< pointer to temporal working buffer */
66
-);
67
-
68
-void qmfSynthesisFiltering(
69
-    HANDLE_QMF_FILTER_BANK synQmf,       /*!< Handle of Qmf Synthesis Bank  */
70
-    FIXP_DBL **QmfBufferReal,            /*!< Pointer to real subband slots */
71
-    FIXP_DBL **QmfBufferImag,            /*!< Pointer to imag subband slots */
72
-    const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data     */
73
-    const int ov_len,                    /*!< Length of band overlap        */
74
-    INT_PCM *timeOut,                    /*!< Time signal */
75
-    const INT stride,                    /*!< Stride factor of audio data   */
76
-    FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer. It must be
77
-                             aligned */
78
+    FIXP_DBL *pWorkBuffer          /*!< pointer to temporary working buffer */
79
 );
80
-
81
-int qmfInitAnalysisFilterBank(
82
-    HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
83
-    FIXP_QAS *pFilterStates,      /*!< Pointer to filter state buffer */
84
-    int noCols,                   /*!< Number of time slots  */
85
-    int lsb,                      /*!< Number of lower bands */
86
-    int usb,                      /*!< Number of upper bands */
87
-    int no_channels,              /*!< Number of critically sampled bands */
88
-    int flags);                   /*!< Flags */
89
+#endif
90
 
91
 void qmfAnalysisFilteringSlot(
92
     HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank  */
93
     FIXP_DBL *qmfReal,             /*!< Low and High band, real */
94
     FIXP_DBL *qmfImag,             /*!< Low and High band, imag */
95
-    const LONG *timeIn,            /*!< Pointer to input */
96
+    const INT_PCM *timeIn,         /*!< Pointer to input */
97
     const int stride,              /*!< stride factor of input */
98
-    FIXP_DBL *pWorkBuffer          /*!< pointer to temporary working buffer */
99
+    FIXP_DBL *pWorkBuffer          /*!< pointer to temporal working buffer */
100
 );
101
+#if SAMPLE_BITS == 16
102
 
103
 void qmfAnalysisFilteringSlot(
104
     HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank  */
105
     FIXP_DBL *qmfReal,             /*!< Low and High band, real */
106
     FIXP_DBL *qmfImag,             /*!< Low and High band, imag */
107
-    const INT_PCM *timeIn,         /*!< Pointer to input */
108
+    const LONG *timeIn,            /*!< Pointer to input */
109
     const int stride,              /*!< stride factor of input */
110
-    FIXP_DBL *pWorkBuffer          /*!< pointer to temporal working buffer */
111
+    FIXP_DBL *pWorkBuffer          /*!< pointer to temporary working buffer */
112
 );
113
+#endif
114
+
115
 int qmfInitSynthesisFilterBank(
116
     HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
117
     FIXP_QSS *pFilterStates,      /*!< Pointer to filter state buffer */
118
@@ -270,12 +275,46 @@
119
     int no_channels,              /*!< Number of critically sampled bands */
120
     int flags);                   /*!< Flags */
121
 
122
+void qmfSynthesisFiltering(
123
+    HANDLE_QMF_FILTER_BANK synQmf,       /*!< Handle of Qmf Synthesis Bank  */
124
+    FIXP_DBL **QmfBufferReal,            /*!< Pointer to real subband slots */
125
+    FIXP_DBL **QmfBufferImag,            /*!< Pointer to imag subband slots */
126
+    const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data     */
127
+    const int ov_len,                    /*!< Length of band overlap        */
128
+    INT_PCM *timeOut,                    /*!< Time signal */
129
+    const INT stride,                    /*!< Stride factor of audio data   */
130
+    FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer. It must be
131
+                             aligned */
132
+);
133
+#if SAMPLE_BITS == 16
134
+
135
+void qmfSynthesisFiltering(
136
+    HANDLE_QMF_FILTER_BANK synQmf,       /*!< Handle of Qmf Synthesis Bank  */
137
+    FIXP_DBL **QmfBufferReal,            /*!< Pointer to real subband slots */
138
+    FIXP_DBL **QmfBufferImag,            /*!< Pointer to imag subband slots */
139
+    const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data     */
140
+    const int ov_len,                    /*!< Length of band overlap        */
141
+    LONG *timeOut,                       /*!< Time signal */
142
+    const int timeOut_e,                 /*!< Target exponent for timeOut  */
143
+    FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer */
144
+);
145
+#endif
146
+
147
 void qmfSynthesisFilteringSlot(HANDLE_QMF_FILTER_BANK synQmf,
148
                                const FIXP_DBL *realSlot,
149
                                const FIXP_DBL *imagSlot,
150
                                const int scaleFactorLowBand,
151
                                const int scaleFactorHighBand, INT_PCM *timeOut,
152
                                const int timeOut_e, FIXP_DBL *pWorkBuffer);
153
+#if SAMPLE_BITS == 16
154
+
155
+void qmfSynthesisFilteringSlot(HANDLE_QMF_FILTER_BANK synQmf,
156
+                               const FIXP_DBL *realSlot,
157
+                               const FIXP_DBL *imagSlot,
158
+                               const int scaleFactorLowBand,
159
+                               const int scaleFactorHighBand, LONG *timeOut,
160
+                               const int timeOut_e, FIXP_DBL *pWorkBuffer);
161
+#endif
162
 
163
 void qmfChangeOutScalefactor(
164
     HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
165
@@ -291,11 +330,5 @@
166
     FIXP_DBL outputGain,           /*!< New gain for output data (mantissa) */
167
     int outputGainScale            /*!< New gain for output data (exponent) */
168
 );
169
-void qmfSynPrototypeFirSlot(
170
-    HANDLE_QMF_FILTER_BANK qmf,
171
-    FIXP_DBL *RESTRICT realSlot, /*!< Input: Pointer to real Slot */
172
-    FIXP_DBL *RESTRICT imagSlot, /*!< Input: Pointer to imag Slot */
173
-    INT_PCM *RESTRICT timeOut,   /*!< Time domain data */
174
-    const int timeOut_e);
175
 
176
 #endif /*ifndef QMF_H       */
177
fdk-aac-2.0.1.tar.gz/libFDK/include/qmf_pcm.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/qmf_pcm.h Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -402,4 +402,220 @@
11
                               timeOut + (i * L * stride), stride, pWorkBuffer);
12
   } /* no_col loop  i  */
13
 }
14
+
15
+/*!
16
+ *
17
+ * \brief Create QMF filter bank instance
18
+ *
19
+ *
20
+ * \return 0 if successful
21
+ *
22
+ */
23
+int qmfInitAnalysisFilterBank(
24
+    HANDLE_QMF_FILTER_BANK h_Qmf, /*!< Returns handle */
25
+    FIXP_QAS *pFilterStates,      /*!< Handle to filter states */
26
+    int noCols,                   /*!< Number of timeslots per frame */
27
+    int lsb,                      /*!< lower end of QMF */
28
+    int usb,                      /*!< upper end of QMF */
29
+    int no_channels,              /*!< Number of channels (bands) */
30
+    int flags)                    /*!< Low Power flag */
31
+{
32
+  int err = qmfInitFilterBank(h_Qmf, pFilterStates, noCols, lsb, usb,
33
+                              no_channels, flags, 0);
34
+  if (!(flags & QMF_FLAG_KEEP_STATES) && (h_Qmf->FilterStates != NULL)) {
35
+    FDKmemclear(h_Qmf->FilterStates,
36
+                (2 * QMF_NO_POLY - 1) * h_Qmf->no_channels * sizeof(FIXP_QAS));
37
+  }
38
+
39
+  FDK_ASSERT(h_Qmf->no_channels >= h_Qmf->lsb);
40
+
41
+  return err;
42
+}
43
+
44
+#ifndef FUNCTION_qmfAnaPrototypeFirSlot
45
+/*!
46
+  \brief Perform Analysis Prototype Filtering on a single slot of input data.
47
+*/
48
+static void qmfAnaPrototypeFirSlot(
49
+    FIXP_DBL *analysisBuffer,
50
+    INT no_channels, /*!< Number channels of analysis filter */
51
+    const FIXP_PFT *p_filter, INT p_stride, /*!< Stride of analysis filter    */
52
+    FIXP_QAS *RESTRICT pFilterStates) {
53
+  INT k;
54
+
55
+  FIXP_DBL accu;
56
+  const FIXP_PFT *RESTRICT p_flt = p_filter;
57
+  FIXP_DBL *RESTRICT pData_0 = analysisBuffer + 2 * no_channels - 1;
58
+  FIXP_DBL *RESTRICT pData_1 = analysisBuffer;
59
+
60
+  FIXP_QAS *RESTRICT sta_0 = (FIXP_QAS *)pFilterStates;
61
+  FIXP_QAS *RESTRICT sta_1 =
62
+      (FIXP_QAS *)pFilterStates + (2 * QMF_NO_POLY * no_channels) - 1;
63
+  INT pfltStep = QMF_NO_POLY * (p_stride);
64
+  INT staStep1 = no_channels << 1;
65
+  INT staStep2 = (no_channels << 3) - 1; /* Rewind one less */
66
+
67
+  /* FIR filters 127..64 0..63 */
68
+  for (k = 0; k < no_channels; k++) {
69
+    accu = fMultDiv2(p_flt[0], *sta_1);
70
+    sta_1 -= staStep1;
71
+    accu += fMultDiv2(p_flt[1], *sta_1);
72
+    sta_1 -= staStep1;
73
+    accu += fMultDiv2(p_flt[2], *sta_1);
74
+    sta_1 -= staStep1;
75
+    accu += fMultDiv2(p_flt[3], *sta_1);
76
+    sta_1 -= staStep1;
77
+    accu += fMultDiv2(p_flt[4], *sta_1);
78
+    *pData_1++ = (accu << 1);
79
+    sta_1 += staStep2;
80
+
81
+    p_flt += pfltStep;
82
+    accu = fMultDiv2(p_flt[0], *sta_0);
83
+    sta_0 += staStep1;
84
+    accu += fMultDiv2(p_flt[1], *sta_0);
85
+    sta_0 += staStep1;
86
+    accu += fMultDiv2(p_flt[2], *sta_0);
87
+    sta_0 += staStep1;
88
+    accu += fMultDiv2(p_flt[3], *sta_0);
89
+    sta_0 += staStep1;
90
+    accu += fMultDiv2(p_flt[4], *sta_0);
91
+    *pData_0-- = (accu << 1);
92
+    sta_0 -= staStep2;
93
+  }
94
+}
95
+#endif /* !defined(FUNCTION_qmfAnaPrototypeFirSlot) */
96
+
97
+#ifndef FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric
98
+/*!
99
+  \brief Perform Analysis Prototype Filtering on a single slot of input data.
100
+*/
101
+static void qmfAnaPrototypeFirSlot_NonSymmetric(
102
+    FIXP_DBL *analysisBuffer,
103
+    int no_channels, /*!< Number channels of analysis filter */
104
+    const FIXP_PFT *p_filter, int p_stride, /*!< Stride of analysis filter    */
105
+    FIXP_QAS *RESTRICT pFilterStates) {
106
+  const FIXP_PFT *RESTRICT p_flt = p_filter;
107
+  int p, k;
108
+
109
+  for (k = 0; k < 2 * no_channels; k++) {
110
+    FIXP_DBL accu = (FIXP_DBL)0;
111
+
112
+    p_flt += QMF_NO_POLY * (p_stride - 1);
113
+
114
+    /*
115
+      Perform FIR-Filter
116
+    */
117
+    for (p = 0; p < QMF_NO_POLY; p++) {
118
+      accu += fMultDiv2(*p_flt++, pFilterStates[2 * no_channels * p]);
119
+    }
120
+    analysisBuffer[2 * no_channels - 1 - k] = (accu << 1);
121
+    pFilterStates++;
122
+  }
123
+}
124
+#endif /* FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric */
125
+
126
+/*
127
+ * \brief Perform one QMF slot analysis of the time domain data of timeIn
128
+ *        with specified stride and stores the real part of the subband
129
+ *        samples in rSubband, and the imaginary part in iSubband
130
+ *
131
+ *        Note: anaQmf->lsb can be greater than anaQmf->no_channels in case
132
+ *        of implicit resampling (USAC with reduced 3/4 core frame length).
133
+ */
134
+void qmfAnalysisFilteringSlot(
135
+    HANDLE_QMF_FILTER_BANK anaQmf,        /*!< Handle of Qmf Synthesis Bank  */
136
+    FIXP_DBL *qmfReal,                    /*!< Low and High band, real */
137
+    FIXP_DBL *qmfImag,                    /*!< Low and High band, imag */
138
+    const INT_PCM_QMFIN *RESTRICT timeIn, /*!< Pointer to input */
139
+    const int stride,                     /*!< stride factor of input */
140
+    FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */
141
+) {
142
+  int offset = anaQmf->no_channels * (QMF_NO_POLY * 2 - 1);
143
+  /*
144
+    Feed time signal into oldest anaQmf->no_channels states
145
+  */
146
+  {
147
+    FIXP_QAS *FilterStatesAnaTmp = ((FIXP_QAS *)anaQmf->FilterStates) + offset;
148
+
149
+    /* Feed and scale actual time in slot */
150
+    for (int i = anaQmf->no_channels >> 1; i != 0; i--) {
151
+      /* Place INT_PCM value left aligned in scaledTimeIn */
152
+      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
153
+      timeIn += stride;
154
+      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
155
+      timeIn += stride;
156
+    }
157
+  }
158
+
159
+  if (anaQmf->flags & QMF_FLAG_NONSYMMETRIC) {
160
+    qmfAnaPrototypeFirSlot_NonSymmetric(pWorkBuffer, anaQmf->no_channels,
161
+                                        anaQmf->p_filter, anaQmf->p_stride,
162
+                                        (FIXP_QAS *)anaQmf->FilterStates);
163
+  } else {
164
+    qmfAnaPrototypeFirSlot(pWorkBuffer, anaQmf->no_channels, anaQmf->p_filter,
165
+                           anaQmf->p_stride, (FIXP_QAS *)anaQmf->FilterStates);
166
+  }
167
+
168
+  if (anaQmf->flags & QMF_FLAG_LP) {
169
+    if (anaQmf->flags & QMF_FLAG_CLDFB)
170
+      qmfForwardModulationLP_odd(anaQmf, pWorkBuffer, qmfReal);
171
+    else
172
+      qmfForwardModulationLP_even(anaQmf, pWorkBuffer, qmfReal);
173
+
174
+  } else {
175
+    qmfForwardModulationHQ(anaQmf, pWorkBuffer, qmfReal, qmfImag);
176
+  }
177
+  /*
178
+    Shift filter states
179
+
180
+    Should be realized with modulo addressing on a DSP instead of a true buffer
181
+    shift
182
+  */
183
+  FDKmemmove(anaQmf->FilterStates,
184
+             (FIXP_QAS *)anaQmf->FilterStates + anaQmf->no_channels,
185
+             offset * sizeof(FIXP_QAS));
186
+}
187
+
188
+/*!
189
+ *
190
+ * \brief Perform complex-valued subband filtering of the time domain
191
+ *        data of timeIn and stores the real part of the subband
192
+ *        samples in rAnalysis, and the imaginary part in iAnalysis
193
+ * The qmf coefficient table is symmetric. The symmetry is expoited by
194
+ * shrinking the coefficient table to half the size. The addressing mode
195
+ * takes care of the symmetries.
196
+ *
197
+ *
198
+ * \sa PolyphaseFiltering
199
+ */
200
+void qmfAnalysisFiltering(
201
fdk-aac-2.0.1.tar.gz/libFDK/include/scale.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/scale.h Changed
36
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -123,21 +123,19 @@
11
 #if (SAMPLE_BITS == 16)
12
 void scaleValues(FIXP_PCM *dst, const FIXP_DBL *src, INT len, INT scalefactor);
13
 #endif
14
-void scaleValues(FIXP_PCM *dst, const FIXP_SGL *src, INT len, INT scalefactor);
15
+void scaleValues(FIXP_SGL *dst, const FIXP_SGL *src, INT len, INT scalefactor);
16
 void scaleCplxValues(FIXP_DBL *r_dst, FIXP_DBL *i_dst, const FIXP_DBL *r_src,
17
                      const FIXP_DBL *i_src, INT len, INT scalefactor);
18
 void scaleValuesWithFactor(FIXP_DBL *vector, FIXP_DBL factor, INT len,
19
                            INT scalefactor);
20
 void scaleValuesSaturate(FIXP_DBL *vector, INT len, INT scalefactor);
21
-void scaleValuesSaturate(FIXP_DBL *dst, FIXP_DBL *src, INT len,
22
+void scaleValuesSaturate(FIXP_DBL *dst, const FIXP_DBL *src, INT len,
23
                          INT scalefactor);
24
-void scaleValuesSaturate(FIXP_SGL *dst, FIXP_DBL *src, INT len,
25
+void scaleValuesSaturate(FIXP_SGL *dst, const FIXP_DBL *src, INT len,
26
                          INT scalefactor);
27
-void scaleValuesSaturate(INT_PCM *dst, FIXP_DBL *src, INT len, INT scalefactor);
28
 void scaleValuesSaturate(FIXP_SGL *vector, INT len, INT scalefactor);
29
-void scaleValuesSaturate(FIXP_SGL *dst, FIXP_SGL *src, INT len,
30
+void scaleValuesSaturate(FIXP_SGL *dst, const FIXP_SGL *src, INT len,
31
                          INT scalefactor);
32
-void scaleValuesSaturate(INT_PCM *dst, INT_PCM *src, INT len, INT scalefactor);
33
 INT getScalefactorShort(const SHORT *vector, INT len);
34
 INT getScalefactorPCM(const INT_PCM *vector, INT len, INT stride);
35
 INT getScalefactor(const FIXP_DBL *vector, INT len);
36
fdk-aac-2.0.1.tar.gz/libFDK/include/scramble.h -> fdk-aac-2.0.2.tar.gz/libFDK/include/scramble.h Changed
10
 
1
@@ -108,7 +108,7 @@
2
 #if defined(__arm__)
3
 #include "arm/scramble_arm.h"
4
 
5
-#elif defined(__mips__) && defined(__mips_dsp)
6
+#elif defined(__mips__) && defined(__mips_dsp) && !defined(__mips16)
7
 #include "mips/scramble_mips.h"
8
 
9
 #endif
10
fdk-aac-2.0.1.tar.gz/libFDK/src/FDK_bitbuffer.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/FDK_bitbuffer.cpp Changed
31
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -368,7 +368,10 @@
11
 
12
   UINT bTotal = 0;
13
 
14
-  UINT bToRead = (hBitBuf->bufBits - hBitBuf->ValidBits) >> 3;
15
+  UINT bToRead =
16
+      fMin(hBitBuf->bufBits,
17
+           (UINT)fMax(0, ((INT)hBitBuf->bufBits - (INT)hBitBuf->ValidBits))) >>
18
+      3;
19
   UINT noOfBytes =
20
       fMin(bToRead,
21
            *bytesValid);  //(bToRead < *bytesValid) ? bToRead : *bytesValid ;
22
@@ -384,7 +387,7 @@
23
               bToRead * sizeof(UCHAR));
24
 
25
     /* add noOfBits to number of valid bits in buffer */
26
-    hBitBuf->ValidBits += bToRead << 3;
27
+    hBitBuf->ValidBits = (UINT)((INT)hBitBuf->ValidBits + (INT)(bToRead << 3));
28
     bTotal += bToRead;
29
     inputBuffer += bToRead;
30
 
31
fdk-aac-2.0.1.tar.gz/libFDK/src/FDK_core.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/FDK_core.cpp Changed
23
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -104,10 +104,10 @@
11
 
12
 /* FDK tools library info */
13
 #define FDK_TOOLS_LIB_VL0 3
14
-#define FDK_TOOLS_LIB_VL1 0
15
+#define FDK_TOOLS_LIB_VL1 1
16
 #define FDK_TOOLS_LIB_VL2 0
17
 #define FDK_TOOLS_LIB_TITLE "FDK Tools"
18
-#ifdef __ANDROID__
19
+#ifdef SUPPRESS_BUILD_DATE_INFO
20
 #define FDK_TOOLS_LIB_BUILD_DATE ""
21
 #define FDK_TOOLS_LIB_BUILD_TIME ""
22
 #else
23
fdk-aac-2.0.1.tar.gz/libFDK/src/FDK_decorrelate.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/FDK_decorrelate.cpp Changed
158
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -227,7 +227,7 @@
11
 }
12
 
13
 #define DUCKER_MAX_NRG_SCALE (24)
14
-#define DUCKER_HEADROOM_BITS (3)
15
+#define DUCKER_HEADROOM_BITS (2)
16
 
17
 #define FILTER_SF (2)
18
 
19
@@ -606,10 +606,6 @@
20
       dataImagIn += start;
21
       dataRealOut += start;
22
       dataImagOut += start;
23
-#ifdef FUNCTION_DecorrFilterApplyPASS_func1
24
-      DecorrFilterApplyPASS_func1(i, dataRealIn, dataImagIn, dataRealOut,
25
-                                  dataImagOut, pDelayBuffer, offset);
26
-#else
27
       do {
28
         FIXP_DBL delay_re, delay_im, real, imag;
29
 
30
@@ -623,7 +619,6 @@
31
         *dataImagOut++ = delay_im;
32
         pDelayBuffer += offset;
33
       } while (--i != 0);
34
-#endif
35
     }
36
   }
37
 
38
@@ -1061,24 +1056,15 @@
39
     FIXP_DBL maxVal = FL2FXCONST_DBL(-1.0f);
40
 
41
     if (maxVal == FL2FXCONST_DBL(-1.0f)) {
42
-#ifdef FUNCTION_DuckerCalcEnergy_func2
43
-      maxVal = DuckerCalcEnergy_func2(inputReal, inputImag, startHybBand,
44
-                                      maxHybBand, maxHybridBand);
45
-#else
46
-      FIXP_DBL localMaxVal = FL2FXCONST_DBL(0.0f);
47
-      for (qs = startHybBand; qs <= maxHybBand; qs++) {
48
-        localMaxVal |= fAbs(inputReal[qs]);
49
-        localMaxVal |= fAbs(inputImag[qs]);
50
-      }
51
-      for (; qs <= maxHybridBand; qs++) {
52
-        localMaxVal |= fAbs(inputReal[qs]);
53
-      }
54
-      maxVal = localMaxVal;
55
-#endif
56
+      clz = fMin(getScalefactor(&inputReal[startHybBand],
57
+                                fMax(0, maxHybridBand - startHybBand + 1)),
58
+                 getScalefactor(&inputImag[startHybBand],
59
+                                fMax(0, maxHybBand - startHybBand + 1)));
60
+    } else {
61
+      clz = CntLeadingZeros(maxVal) - 1;
62
     }
63
 
64
-    clz = fixMax(0, CntLeadingZeros(maxVal) - DUCKER_HEADROOM_BITS);
65
-    clz = fixMin(clz, DUCKER_MAX_NRG_SCALE);
66
+    clz = fMin(fMax(0, clz - DUCKER_HEADROOM_BITS), DUCKER_MAX_NRG_SCALE);
67
     *nrgScale = (SCHAR)clz << 1;
68
 
69
     /* Initialize pb since it would stay uninitialized for the case startHybBand
70
@@ -1086,9 +1072,10 @@
71
     pb = SpatialDecGetProcessingBand(maxHybBand, self->mapHybBands2ProcBands);
72
     for (qs = startHybBand; qs <= maxHybBand; qs++) {
73
       pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
74
-      energy[pb] =
75
-          fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) +
76
-                                       fPow2Div2(inputImag[qs] << clz));
77
+      energy[pb] = SATURATE_LEFT_SHIFT(
78
+          (energy[pb] >> 1) + (fPow2Div2(inputReal[qs] << clz) >> 1) +
79
+              (fPow2Div2(inputImag[qs] << clz) >> 1),
80
+          1, DFRACT_BITS);
81
     }
82
     pb++;
83
 
84
@@ -1112,43 +1099,29 @@
85
     maxVal = inputMaxVal;
86
 
87
     if (maxVal == FL2FXCONST_DBL(-1.0f)) {
88
-#ifdef FUNCTION_DuckerCalcEnergy_func2
89
-      maxVal = DuckerCalcEnergy_func2(inputReal, inputImag, startHybBand,
90
-                                      maxHybBand, maxHybridBand);
91
-#else
92
-      FIXP_DBL localMaxVal = FL2FXCONST_DBL(0.0f);
93
-      for (qs = startHybBand; qs <= maxHybBand; qs++) {
94
-        localMaxVal |= fAbs(inputReal[qs]);
95
-        localMaxVal |= fAbs(inputImag[qs]);
96
-      }
97
-      for (; qs <= maxHybridBand; qs++) {
98
-        localMaxVal |= fAbs(inputReal[qs]);
99
-      }
100
-      maxVal = localMaxVal;
101
-#endif
102
+      clz = fMin(getScalefactor(&inputReal[startHybBand],
103
+                                fMax(0, maxHybridBand - startHybBand + 1)),
104
+                 getScalefactor(&inputImag[startHybBand],
105
+                                fMax(0, maxHybBand - startHybBand + 1)));
106
+    } else {
107
+      clz = CntLeadingZeros(maxVal) - 1;
108
     }
109
 
110
-    clz = fixMax(0, CntLeadingZeros(maxVal) - DUCKER_HEADROOM_BITS);
111
-    clz = fixMin(clz, DUCKER_MAX_NRG_SCALE);
112
+    clz = fMin(fMax(0, clz - DUCKER_HEADROOM_BITS), DUCKER_MAX_NRG_SCALE);
113
     *nrgScale = (SCHAR)clz << 1;
114
 
115
-#ifdef FUNCTION_DuckerCalcEnergy_func4
116
-    DuckerCalcEnergy_func4(inputReal, inputImag, energy,
117
-                           self->mapHybBands2ProcBands, clz, startHybBand,
118
-                           maxHybBand, maxHybridBand);
119
-#else
120
     for (qs = startHybBand; qs <= maxHybBand; qs++) {
121
       int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
122
-      energy[pb] =
123
-          fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) +
124
-                                       fPow2Div2(inputImag[qs] << clz));
125
+      energy[pb] = SATURATE_LEFT_SHIFT(
126
+          (energy[pb] >> 1) + (fPow2Div2(inputReal[qs] << clz) >> 1) +
127
+              (fPow2Div2(inputImag[qs] << clz) >> 1),
128
+          1, DFRACT_BITS);
129
     }
130
 
131
     for (; qs <= maxHybridBand; qs++) {
132
       int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
133
       energy[pb] = fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz));
134
     }
135
-#endif /* FUNCTION_DuckerCalcEnergy_func4 */
136
   }
137
 
138
   {
139
@@ -1295,10 +1268,6 @@
140
       }
141
     }
142
 
143
-#ifdef FUNCTION_DuckerApply_func1
144
-    qs = DuckerApply_func1(qs, hybBands, qs_next, outputReal, outputImag,
145
-                           duckGain);
146
-#else
147
     /* general gain*output section */
148
     if (qs < hybBands) {           /* true for about 39% */
149
       for (; qs < qs_next; qs++) { /* runs about 2 times */
150
@@ -1310,7 +1279,6 @@
151
         outputReal[qs] = fMultDiv2(outputReal[qs], duckGain) << 2;
152
       }
153
     }
154
-#endif
155
   } /* pb */
156
 
157
   self->headroomSmoothDirRevNrg =
158
fdk-aac-2.0.1.tar.gz/libFDK/src/FDK_hybrid.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/FDK_hybrid.cpp Changed
70
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -142,11 +142,12 @@
11
   } /* How to arrange the packed values. */
12
 
13
 struct FDK_HYBRID_SETUP {
14
-  UCHAR nrQmfBands;   /*!< Number of QMF bands to be converted to hybrid. */
15
-  UCHAR nHybBands[3]; /*!< Number of Hybrid bands generated by nrQmfBands. */
16
-  SCHAR kHybrid[3];   /*!< Filter configuration of each QMF band. */
17
-  UCHAR protoLen;     /*!< Prototype filter length. */
18
-  UCHAR filterDelay;  /*!< Delay caused by hybrid filter. */
19
+  UCHAR nrQmfBands;     /*!< Number of QMF bands to be converted to hybrid. */
20
+  UCHAR nHybBands[3];   /*!< Number of Hybrid bands generated by nrQmfBands. */
21
+  UCHAR synHybScale[3]; /*!< Headroom needed in hybrid synthesis filterbank. */
22
+  SCHAR kHybrid[3];     /*!< Filter configuration of each QMF band. */
23
+  UCHAR protoLen;       /*!< Prototype filter length. */
24
+  UCHAR filterDelay;    /*!< Delay caused by hybrid filter. */
25
   const INT
26
       *pReadIdxTable; /*!< Helper table to access input data ringbuffer. */
27
 };
28
@@ -156,12 +157,12 @@
29
                                            9, 10, 11, 12, 0, 1,  2,  3, 4,
30
                                            5, 6,  7,  8,  9, 10, 11, 12};
31
 
32
-static const FDK_HYBRID_SETUP setup_3_16 = {3,  {8, 4, 4},    {8, 4, 4},
33
-                                            13, (13 - 1) / 2, ringbuffIdxTab};
34
-static const FDK_HYBRID_SETUP setup_3_12 = {3,  {8, 2, 2},    {8, 2, 2},
35
-                                            13, (13 - 1) / 2, ringbuffIdxTab};
36
-static const FDK_HYBRID_SETUP setup_3_10 = {3,  {6, 2, 2},    {-8, -2, 2},
37
-                                            13, (13 - 1) / 2, ringbuffIdxTab};
38
+static const FDK_HYBRID_SETUP setup_3_16 = {
39
+    3, {8, 4, 4}, {4, 3, 3}, {8, 4, 4}, 13, (13 - 1) / 2, ringbuffIdxTab};
40
+static const FDK_HYBRID_SETUP setup_3_12 = {
41
+    3, {8, 2, 2}, {4, 2, 2}, {8, 2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab};
42
+static const FDK_HYBRID_SETUP setup_3_10 = {
43
+    3, {6, 2, 2}, {3, 2, 2}, {-8, -2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab};
44
 
45
 static const FIXP_HTP HybFilterCoef8[] = {
46
     HTCP(0x10000000, 0x00000000), HTCP(0x0df26407, 0xfa391882),
47
@@ -477,17 +478,18 @@
48
    */
49
   for (k = 0; k < nrQmfBandsLF; k++) {
50
     const int nHybBands = hSynthesisHybFilter->pSetup->nHybBands[k];
51
+    const int scale = hSynthesisHybFilter->pSetup->synHybScale[k];
52
 
53
     FIXP_DBL accu1 = FL2FXCONST_DBL(0.f);
54
     FIXP_DBL accu2 = FL2FXCONST_DBL(0.f);
55
 
56
     /* Perform hybrid filtering. */
57
     for (n = 0; n < nHybBands; n++) {
58
-      accu1 += pHybridReal[hybOffset + n];
59
-      accu2 += pHybridImag[hybOffset + n];
60
+      accu1 += pHybridReal[hybOffset + n] >> scale;
61
+      accu2 += pHybridImag[hybOffset + n] >> scale;
62
     }
63
-    pQmfReal[k] = accu1;
64
-    pQmfImag[k] = accu2;
65
+    pQmfReal[k] = SATURATE_LEFT_SHIFT(accu1, scale, DFRACT_BITS);
66
+    pQmfImag[k] = SATURATE_LEFT_SHIFT(accu2, scale, DFRACT_BITS);
67
 
68
     hybOffset += nHybBands;
69
   }
70
fdk-aac-2.0.1.tar.gz/libFDK/src/FDK_qmf_domain.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/FDK_qmf_domain.cpp Changed
126
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -106,35 +106,31 @@
11
 #include "common_fix.h"
12
 
13
 #define WORKBUFFER1_TAG 0
14
-#define WORKBUFFER2_TAG 1
15
-
16
 #define WORKBUFFER3_TAG 4
17
 #define WORKBUFFER4_TAG 5
18
-#define WORKBUFFER5_TAG 6
19
 #define WORKBUFFER6_TAG 7
20
+#define WORKBUFFER7_TAG 8
21
 
22
 C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore1, FIXP_DBL, QMF_WB_SECTION_SIZE,
23
                     SECT_DATA_L1, WORKBUFFER1_TAG)
24
-C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore2, FIXP_DBL, QMF_WB_SECTION_SIZE,
25
-                    SECT_DATA_L2, WORKBUFFER2_TAG)
26
 C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore3, FIXP_DBL, QMF_WB_SECTION_SIZE,
27
                     SECT_DATA_L2, WORKBUFFER3_TAG)
28
 C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore4, FIXP_DBL, QMF_WB_SECTION_SIZE,
29
                     SECT_DATA_L2, WORKBUFFER4_TAG)
30
-C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore5, FIXP_DBL, QMF_WB_SECTION_SIZE,
31
-                    SECT_DATA_L2, WORKBUFFER5_TAG)
32
 C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore6, FIXP_DBL, QMF_WB_SECTION_SIZE,
33
                     SECT_DATA_L2, WORKBUFFER6_TAG)
34
+C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore7, FIXP_DBL, QMF_WB_SECTION_SIZE,
35
+                    SECT_DATA_L2, WORKBUFFER7_TAG)
36
 
37
 /*! Analysis states buffer. <br>
38
     Dimension: #((8) + (1))                                                   */
39
-C_ALLOC_MEM2(AnaQmfStates, FIXP_QAS, 10 * QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS,
40
-             ((8) + (1)))
41
+C_AALLOC_MEM2(AnaQmfStates, FIXP_DBL, 10 * QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS,
42
+              ((8) + (1)))
43
 
44
 /*! Synthesis states buffer. <br>
45
     Dimension: #((8) + (1))                                                  */
46
-C_ALLOC_MEM2(SynQmfStates, FIXP_QSS, 9 * QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS,
47
-             ((8) + (1)))
48
+C_AALLOC_MEM2(SynQmfStates, FIXP_QSS, 9 * QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS,
49
+              ((8) + (1)))
50
 
51
 /*! Pointer to real qmf data for each time slot. <br>
52
     Dimension: #((8) + (1))                                                   */
53
@@ -156,18 +152,17 @@
54
 
55
 /*! Analysis states buffer. <br>
56
     Dimension: #((8) + (1))                                                   */
57
-C_ALLOC_MEM2(AnaQmfStates16, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_16,
58
-             ((8) + (1)))
59
-
60
+C_AALLOC_MEM2(AnaQmfStates16, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_16,
61
+              ((8) + (1)))
62
 /*! Analysis states buffer. <br>
63
     Dimension: #((8) + (1))                                                   */
64
-C_ALLOC_MEM2(AnaQmfStates24, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_24,
65
-             ((8) + (1)))
66
+C_AALLOC_MEM2(AnaQmfStates24, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_24,
67
+              ((8) + (1)))
68
 
69
 /*! Analysis states buffer. <br>
70
     Dimension: #((8) + (1))                                                   */
71
-C_ALLOC_MEM2(AnaQmfStates32, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_32,
72
-             ((8) + (1)))
73
+C_AALLOC_MEM2(AnaQmfStates32, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_32,
74
+              ((8) + (1)))
75
 
76
 /*! Pointer to real qmf data for each time slot. <br>
77
     Dimension: #((8) + (1))                                                   */
78
@@ -642,10 +637,10 @@
79
 
80
   if (pQmfOutImag == NULL) {
81
     for (; b < fMin(lsb, stop_band); b++) {
82
-      pQmfOutReal[b] = scaleValue(real[b], lb_sf);
83
+      pQmfOutReal[b] = scaleValueSaturate(real[b], lb_sf);
84
     }
85
     for (; b < fMin(usb, stop_band); b++) {
86
-      pQmfOutReal[b] = scaleValue(real[b], hb_sf);
87
+      pQmfOutReal[b] = scaleValueSaturate(real[b], hb_sf);
88
     }
89
     for (; b < stop_band; b++) {
90
       pQmfOutReal[b] = (FIXP_DBL)0;
91
@@ -653,12 +648,12 @@
92
   } else {
93
     FDK_ASSERT(imag != NULL);
94
     for (; b < fMin(lsb, stop_band); b++) {
95
-      pQmfOutReal[b] = scaleValue(real[b], lb_sf);
96
-      pQmfOutImag[b] = scaleValue(imag[b], lb_sf);
97
+      pQmfOutReal[b] = scaleValueSaturate(real[b], lb_sf);
98
+      pQmfOutImag[b] = scaleValueSaturate(imag[b], lb_sf);
99
     }
100
     for (; b < fMin(usb, stop_band); b++) {
101
-      pQmfOutReal[b] = scaleValue(real[b], hb_sf);
102
-      pQmfOutImag[b] = scaleValue(imag[b], hb_sf);
103
+      pQmfOutReal[b] = scaleValueSaturate(real[b], hb_sf);
104
+      pQmfOutImag[b] = scaleValueSaturate(imag[b], hb_sf);
105
     }
106
     for (; b < stop_band; b++) {
107
       pQmfOutReal[b] = (FIXP_DBL)0;
108
@@ -950,7 +945,7 @@
109
 
110
     if ((size > 4 * QMF_WB_SECTION_SIZE) && (pWorkBuffer[4] == NULL)) {
111
       /* get work buffer of size QMF_WB_SECTION_SIZE */
112
-      pWorkBuffer[4] = GetQmfWorkBufferCore5();
113
+      pWorkBuffer[4] = GetQmfWorkBufferCore7();
114
     }
115
 
116
     /* 8. distribute workbuffer over processing channels */
117
@@ -996,7 +991,7 @@
118
   if (pWorkBuffer[1]) FreeQmfWorkBufferCore1(&pWorkBuffer[1]);
119
   if (pWorkBuffer[2]) FreeQmfWorkBufferCore3(&pWorkBuffer[2]);
120
   if (pWorkBuffer[3]) FreeQmfWorkBufferCore4(&pWorkBuffer[3]);
121
-  if (pWorkBuffer[4]) FreeQmfWorkBufferCore5(&pWorkBuffer[4]);
122
+  if (pWorkBuffer[4]) FreeQmfWorkBufferCore7(&pWorkBuffer[4]);
123
 }
124
 
125
 void FDK_QmfDomain_FreeMem(HANDLE_FDK_QMF_DOMAIN hqd) {
126
fdk-aac-2.0.1.tar.gz/libFDK/src/dct.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/dct.cpp Changed
37
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -489,18 +489,18 @@
11
     for (i = 0; i < M - 1; i += 2, pDat_0 += 2, pDat_1 -= 2) {
12
       FIXP_DBL accu1, accu2, accu3, accu4;
13
 
14
-      accu1 = pDat_1[1];
15
-      accu2 = -pDat_0[0];
16
-      accu3 = pDat_0[1];
17
-      accu4 = -pDat_1[0];
18
+      accu1 = pDat_1[1] >> 1;
19
+      accu2 = -(pDat_0[0] >> 1);
20
+      accu3 = pDat_0[1] >> 1;
21
+      accu4 = -(pDat_1[0] >> 1);
22
 
23
       cplxMultDiv2(&accu1, &accu2, accu1, accu2, twiddle[i]);
24
       cplxMultDiv2(&accu3, &accu4, accu4, accu3, twiddle[i + 1]);
25
 
26
-      pDat_0[0] = accu2 >> 1;
27
-      pDat_0[1] = accu1 >> 1;
28
-      pDat_1[0] = accu4 >> 1;
29
-      pDat_1[1] = -(accu3 >> 1);
30
+      pDat_0[0] = accu2;
31
+      pDat_0[1] = accu1;
32
+      pDat_1[0] = accu4;
33
+      pDat_1[1] = -accu3;
34
     }
35
     if (M & 1) {
36
       FIXP_DBL accu1, accu2;
37
fdk-aac-2.0.1.tar.gz/libFDK/src/fft_rad2.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/fft_rad2.cpp Changed
10
 
1
@@ -109,7 +109,7 @@
2
 #if defined(__arm__)
3
 #include "arm/fft_rad2_arm.cpp"
4
 
5
-#elif defined(__GNUC__) && defined(__mips__) && defined(__mips_dsp)
6
+#elif defined(__GNUC__) && defined(__mips__) && defined(__mips_dsp) && !defined(__mips16)
7
 #include "mips/fft_rad2_mips.cpp"
8
 
9
 #endif
10
fdk-aac-2.0.1.tar.gz/libFDK/src/fixpoint_math.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/fixpoint_math.cpp Changed
23
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -650,6 +650,12 @@
11
   INT ans_lg2_e, baselg2_e;
12
   FIXP_DBL base_lg2, ans_lg2, result;
13
 
14
+  if (base_m <= (FIXP_DBL)0) {
15
+    result = (FIXP_DBL)0;
16
+    *result_e = 0;
17
+    return result;
18
+  }
19
+
20
   /* Calc log2 of base */
21
   base_lg2 = fLog2(base_m, base_e, &baselg2_e);
22
 
23
fdk-aac-2.0.1.tar.gz/libFDK/src/mdct.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/mdct.cpp Changed
28
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -569,7 +569,7 @@
11
        */
12
       for (i = 0; i < hMdct->prev_nr; i++) {
13
         FIXP_DBL x = -(*pOvl--);
14
-        *pOut0 = IMDCT_SCALE_DBL(x + hMdct->pFacZir[i]);
15
+        *pOut0 = fAddSaturate(x, IMDCT_SCALE_DBL(hMdct->pFacZir[i]));
16
         pOut0++;
17
       }
18
       hMdct->pFacZir = NULL;
19
@@ -678,7 +678,7 @@
20
       FIXP_DBL *pOut = pOut0 - fl / 2;
21
       FDK_ASSERT(fl / 2 <= 128);
22
       for (i = 0; i < fl / 2; i++) {
23
-        pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
24
+        pOut[i] = fAddSaturate(pOut[i], IMDCT_SCALE_DBL(hMdct->pFacZir[i]));
25
       }
26
       hMdct->pFacZir = NULL;
27
     }
28
fdk-aac-2.0.1.tar.gz/libFDK/src/mips/scale_mips.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/mips/scale_mips.cpp Changed
10
 
1
@@ -100,7 +100,7 @@
2
 
3
 *******************************************************************************/
4
 
5
-#if defined(__mips_dsp)
6
+#if defined(__mips_dsp) && !defined(__mips16)
7
 
8
 #ifndef FUNCTION_getScalefactor_DBL
9
 #define FUNCTION_getScalefactor_DBL
10
fdk-aac-2.0.1.tar.gz/libFDK/src/nlc_dec.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/nlc_dec.cpp Changed
37
 
1
@@ -568,7 +568,7 @@
2
 static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1,
3
                            SCHAR* out_data_2, DATA_TYPE data_type,
4
                            DIFF_TYPE diff_type_1, DIFF_TYPE diff_type_2,
5
-                           int num_val, CODING_SCHEME* cdg_scheme, int ldMode) {
6
+                           int num_val, int* cdg_scheme, int ldMode) {
7
   ERROR_t err = HUFFDEC_OK;
8
   DIFF_TYPE diff_type;
9
 
10
@@ -597,14 +597,14 @@
11
 
12
   /* Coding scheme */
13
   data = FDKreadBits(strm, 1);
14
-  *cdg_scheme = (CODING_SCHEME)(data << PAIR_SHIFT);
15
+  *cdg_scheme = (data << PAIR_SHIFT);
16
 
17
   if (*cdg_scheme >> PAIR_SHIFT == HUFF_2D) {
18
     if ((out_data_1 != NULL) && (out_data_2 != NULL) && (ldMode == 0)) {
19
       data = FDKreadBits(strm, 1);
20
-      *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | data);
21
+      *cdg_scheme = (*cdg_scheme | data);
22
     } else {
23
-      *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | FREQ_PAIR);
24
+      *cdg_scheme = (*cdg_scheme | FREQ_PAIR);
25
     }
26
   }
27
 
28
@@ -843,7 +843,7 @@
29
   SCHAR* pDataVec[2] = {NULL, NULL};
30
 
31
   DIFF_TYPE diff_type[2] = {DIFF_FREQ, DIFF_FREQ};
32
-  CODING_SCHEME cdg_scheme = HUFF_1D;
33
+  int cdg_scheme = HUFF_1D;
34
   DIRECTION direction = BACKWARDS;
35
 
36
   switch (data_type) {
37
fdk-aac-2.0.1.tar.gz/libFDK/src/qmf.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/qmf.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -147,88 +147,6 @@
11
 /* moved to qmf_pcm.h: -> qmfSynPrototypeFirSlot_NonSymmetric */
12
 /* moved to qmf_pcm.h: -> qmfSynthesisFilteringSlot */
13
 
14
-#ifndef FUNCTION_qmfAnaPrototypeFirSlot
15
-/*!
16
-  \brief Perform Analysis Prototype Filtering on a single slot of input data.
17
-*/
18
-static void qmfAnaPrototypeFirSlot(
19
-    FIXP_DBL *analysisBuffer,
20
-    INT no_channels, /*!< Number channels of analysis filter */
21
-    const FIXP_PFT *p_filter, INT p_stride, /*!< Stride of analysis filter    */
22
-    FIXP_QAS *RESTRICT pFilterStates) {
23
-  INT k;
24
-
25
-  FIXP_DBL accu;
26
-  const FIXP_PFT *RESTRICT p_flt = p_filter;
27
-  FIXP_DBL *RESTRICT pData_0 = analysisBuffer + 2 * no_channels - 1;
28
-  FIXP_DBL *RESTRICT pData_1 = analysisBuffer;
29
-
30
-  FIXP_QAS *RESTRICT sta_0 = (FIXP_QAS *)pFilterStates;
31
-  FIXP_QAS *RESTRICT sta_1 =
32
-      (FIXP_QAS *)pFilterStates + (2 * QMF_NO_POLY * no_channels) - 1;
33
-  INT pfltStep = QMF_NO_POLY * (p_stride);
34
-  INT staStep1 = no_channels << 1;
35
-  INT staStep2 = (no_channels << 3) - 1; /* Rewind one less */
36
-
37
-  /* FIR filters 127..64 0..63 */
38
-  for (k = 0; k < no_channels; k++) {
39
-    accu = fMultDiv2(p_flt[0], *sta_1);
40
-    sta_1 -= staStep1;
41
-    accu += fMultDiv2(p_flt[1], *sta_1);
42
-    sta_1 -= staStep1;
43
-    accu += fMultDiv2(p_flt[2], *sta_1);
44
-    sta_1 -= staStep1;
45
-    accu += fMultDiv2(p_flt[3], *sta_1);
46
-    sta_1 -= staStep1;
47
-    accu += fMultDiv2(p_flt[4], *sta_1);
48
-    *pData_1++ = (accu << 1);
49
-    sta_1 += staStep2;
50
-
51
-    p_flt += pfltStep;
52
-    accu = fMultDiv2(p_flt[0], *sta_0);
53
-    sta_0 += staStep1;
54
-    accu += fMultDiv2(p_flt[1], *sta_0);
55
-    sta_0 += staStep1;
56
-    accu += fMultDiv2(p_flt[2], *sta_0);
57
-    sta_0 += staStep1;
58
-    accu += fMultDiv2(p_flt[3], *sta_0);
59
-    sta_0 += staStep1;
60
-    accu += fMultDiv2(p_flt[4], *sta_0);
61
-    *pData_0-- = (accu << 1);
62
-    sta_0 -= staStep2;
63
-  }
64
-}
65
-#endif /* !defined(FUNCTION_qmfAnaPrototypeFirSlot) */
66
-
67
-#ifndef FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric
68
-/*!
69
-  \brief Perform Analysis Prototype Filtering on a single slot of input data.
70
-*/
71
-static void qmfAnaPrototypeFirSlot_NonSymmetric(
72
-    FIXP_DBL *analysisBuffer,
73
-    int no_channels, /*!< Number channels of analysis filter */
74
-    const FIXP_PFT *p_filter, int p_stride, /*!< Stride of analysis filter    */
75
-    FIXP_QAS *RESTRICT pFilterStates) {
76
-  const FIXP_PFT *RESTRICT p_flt = p_filter;
77
-  int p, k;
78
-
79
-  for (k = 0; k < 2 * no_channels; k++) {
80
-    FIXP_DBL accu = (FIXP_DBL)0;
81
-
82
-    p_flt += QMF_NO_POLY * (p_stride - 1);
83
-
84
-    /*
85
-      Perform FIR-Filter
86
-    */
87
-    for (p = 0; p < QMF_NO_POLY; p++) {
88
-      accu += fMultDiv2(*p_flt++, pFilterStates[2 * no_channels * p]);
89
-    }
90
-    analysisBuffer[2 * no_channels - 1 - k] = (accu << 1);
91
-    pFilterStates++;
92
-  }
93
-}
94
-#endif /* FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric */
95
-
96
 /*!
97
  *
98
  * \brief Perform real-valued forward modulation of the time domain
99
@@ -244,7 +162,7 @@
100
   int i;
101
   int L = anaQmf->no_channels;
102
   int M = L >> 1;
103
-  int scale;
104
+  int scale = 0;
105
   FIXP_DBL accu;
106
 
107
   const FIXP_DBL *timeInTmp1 = (FIXP_DBL *)&timeIn[3 * M];
108
@@ -381,211 +299,6 @@
109
 }
110
 #endif /* FUNCTION_qmfForwardModulationHQ */
111
 
112
-/*
113
- * \brief Perform one QMF slot analysis of the time domain data of timeIn
114
- *        with specified stride and stores the real part of the subband
115
- *        samples in rSubband, and the imaginary part in iSubband
116
- *
117
- *        Note: anaQmf->lsb can be greater than anaQmf->no_channels in case
118
- *        of implicit resampling (USAC with reduced 3/4 core frame length).
119
- */
120
-#if (SAMPLE_BITS != DFRACT_BITS) && (QAS_BITS == DFRACT_BITS)
121
-void qmfAnalysisFilteringSlot(
122
-    HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank  */
123
-    FIXP_DBL *qmfReal,             /*!< Low and High band, real */
124
-    FIXP_DBL *qmfImag,             /*!< Low and High band, imag */
125
-    const LONG *RESTRICT timeIn,   /*!< Pointer to input */
126
-    const int stride,              /*!< stride factor of input */
127
-    FIXP_DBL *pWorkBuffer          /*!< pointer to temporal working buffer */
128
-) {
129
-  int offset = anaQmf->no_channels * (QMF_NO_POLY * 2 - 1);
130
-  /*
131
-    Feed time signal into oldest anaQmf->no_channels states
132
-  */
133
-  {
134
-    FIXP_DBL *FilterStatesAnaTmp = ((FIXP_DBL *)anaQmf->FilterStates) + offset;
135
-
136
-    /* Feed and scale actual time in slot */
137
-    for (int i = anaQmf->no_channels >> 1; i != 0; i--) {
138
-      /* Place INT_PCM value left aligned in scaledTimeIn */
139
-
140
-      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
141
-      timeIn += stride;
142
-      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
143
-      timeIn += stride;
144
-    }
145
-  }
146
-
147
-  if (anaQmf->flags & QMF_FLAG_NONSYMMETRIC) {
148
-    qmfAnaPrototypeFirSlot_NonSymmetric(pWorkBuffer, anaQmf->no_channels,
149
-                                        anaQmf->p_filter, anaQmf->p_stride,
150
-                                        (FIXP_QAS *)anaQmf->FilterStates);
151
-  } else {
152
-    qmfAnaPrototypeFirSlot(pWorkBuffer, anaQmf->no_channels, anaQmf->p_filter,
153
-                           anaQmf->p_stride, (FIXP_QAS *)anaQmf->FilterStates);
154
-  }
155
-
156
-  if (anaQmf->flags & QMF_FLAG_LP) {
157
-    if (anaQmf->flags & QMF_FLAG_CLDFB)
158
-      qmfForwardModulationLP_odd(anaQmf, pWorkBuffer, qmfReal);
159
-    else
160
-      qmfForwardModulationLP_even(anaQmf, pWorkBuffer, qmfReal);
161
-
162
-  } else {
163
-    qmfForwardModulationHQ(anaQmf, pWorkBuffer, qmfReal, qmfImag);
164
-  }
165
-  /*
166
-    Shift filter states
167
-
168
-    Should be realized with modulo adressing on a DSP instead of a true buffer
169
-    shift
170
-  */
171
-  FDKmemmove(anaQmf->FilterStates,
172
-             (FIXP_QAS *)anaQmf->FilterStates + anaQmf->no_channels,
173
-             offset * sizeof(FIXP_QAS));
174
-}
175
-#endif
176
-
177
-void qmfAnalysisFilteringSlot(
178
-    HANDLE_QMF_FILTER_BANK anaQmf,  /*!< Handle of Qmf Synthesis Bank  */
179
-    FIXP_DBL *qmfReal,              /*!< Low and High band, real */
180
-    FIXP_DBL *qmfImag,              /*!< Low and High band, imag */
181
-    const INT_PCM *RESTRICT timeIn, /*!< Pointer to input */
182
-    const int stride,               /*!< stride factor of input */
183
-    FIXP_DBL *pWorkBuffer           /*!< pointer to temporal working buffer */
184
-) {
185
-  int offset = anaQmf->no_channels * (QMF_NO_POLY * 2 - 1);
186
-  /*
187
-    Feed time signal into oldest anaQmf->no_channels states
188
-  */
189
-  {
190
-    FIXP_QAS *FilterStatesAnaTmp = ((FIXP_QAS *)anaQmf->FilterStates) + offset;
191
-
192
-    /* Feed and scale actual time in slot */
193
-    for (int i = anaQmf->no_channels >> 1; i != 0; i--) {
194
-    /* Place INT_PCM value left aligned in scaledTimeIn */
195
-#if (QAS_BITS == SAMPLE_BITS)
196
-      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
197
-      timeIn += stride;
198
-      *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn;
199
-      timeIn += stride;
200
-#elif (QAS_BITS > SAMPLE_BITS)
201
fdk-aac-2.0.1.tar.gz/libFDK/src/scale.cpp -> fdk-aac-2.0.2.tar.gz/libFDK/src/scale.cpp Changed
55
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -250,10 +250,10 @@
11
  */
12
 #define FUNCTION_scaleValuesSaturate_DBL_DBL
13
 SCALE_INLINE
14
-void scaleValuesSaturate(FIXP_DBL *dst,  /*!< Output */
15
-                         FIXP_DBL *src,  /*!< Input   */
16
-                         INT len,        /*!< Length */
17
-                         INT scalefactor /*!< Scalefactor */
18
+void scaleValuesSaturate(FIXP_DBL *dst,       /*!< Output */
19
+                         const FIXP_DBL *src, /*!< Input   */
20
+                         INT len,             /*!< Length */
21
+                         INT scalefactor      /*!< Scalefactor */
22
 ) {
23
   INT i;
24
 
25
@@ -285,10 +285,10 @@
26
  */
27
 #define FUNCTION_scaleValuesSaturate_SGL_DBL
28
 SCALE_INLINE
29
-void scaleValuesSaturate(FIXP_SGL *dst,   /*!< Output */
30
-                         FIXP_DBL *src,   /*!< Input   */
31
-                         INT len,         /*!< Length */
32
-                         INT scalefactor) /*!< Scalefactor */
33
+void scaleValuesSaturate(FIXP_SGL *dst,       /*!< Output */
34
+                         const FIXP_DBL *src, /*!< Input   */
35
+                         INT len,             /*!< Length */
36
+                         INT scalefactor)     /*!< Scalefactor */
37
 {
38
   INT i;
39
   scalefactor = fixmax_I(fixmin_I(scalefactor, (INT)DFRACT_BITS - 1),
40
@@ -345,10 +345,10 @@
41
  */
42
 #define FUNCTION_scaleValuesSaturate_SGL_SGL
43
 SCALE_INLINE
44
-void scaleValuesSaturate(FIXP_SGL *dst,  /*!< Output */
45
-                         FIXP_SGL *src,  /*!< Input */
46
-                         INT len,        /*!< Length */
47
-                         INT scalefactor /*!< Scalefactor */
48
+void scaleValuesSaturate(FIXP_SGL *dst,       /*!< Output */
49
+                         const FIXP_SGL *src, /*!< Input */
50
+                         INT len,             /*!< Length */
51
+                         INT scalefactor      /*!< Scalefactor */
52
 ) {
53
   INT i;
54
 
55
fdk-aac-2.0.1.tar.gz/libMpegTPDec/src/tpdec_adts.cpp -> fdk-aac-2.0.2.tar.gz/libMpegTPDec/src/tpdec_adts.cpp Changed
78
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -213,8 +213,8 @@
11
     goto bail;
12
   }
13
 
14
+  FDKcrcReset(&pAdts->crcInfo);
15
   if (!bs.protection_absent) {
16
-    FDKcrcReset(&pAdts->crcInfo);
17
     FDKpushBack(hBs, 56); /* complete fixed and variable header! */
18
     crcReg = FDKcrcStartReg(&pAdts->crcInfo, hBs, 0);
19
     FDKpushFor(hBs, 56);
20
@@ -314,15 +314,55 @@
21
   if (bs.channel_config == 0) {
22
     int pceBits = 0;
23
     UINT alignAnchor = FDKgetValidBits(hBs);
24
+    CProgramConfig tmpPce;
25
 
26
     if (FDKreadBits(hBs, 3) == ID_PCE) {
27
       /* Got luck! Parse the PCE */
28
       crcReg = adtsRead_CrcStartReg(pAdts, hBs, 0);
29
 
30
-      CProgramConfig_Read(&pAsc->m_progrConfigElement, hBs, alignAnchor);
31
+      CProgramConfig_Init(&tmpPce);
32
+      CProgramConfig_Read(&tmpPce, hBs, alignAnchor);
33
+
34
+      if (CProgramConfig_IsValid(&tmpPce)) {
35
+        if (CProgramConfig_IsValid(&oldPce)) {
36
+          /* Compare the new and the old PCE (tags ignored) */
37
+          switch (CProgramConfig_Compare(&tmpPce, &oldPce)) {
38
+            case 0: /* Nothing to do because PCE matches the old one exactly. */
39
+            case 1: /* Channel configuration not changed. Just new metadata. */
40
+              FDKmemcpy(&pAsc->m_progrConfigElement, &tmpPce,
41
+                        sizeof(CProgramConfig));
42
+              break;
43
+            case 2:  /* The number of channels are identical but not the config
44
+                      */
45
+            case -1: /* The channel configuration is completely different */
46
+            default:
47
+              FDKmemcpy(&pAsc->m_progrConfigElement, &oldPce,
48
+                        sizeof(CProgramConfig));
49
+              FDKpushBack(hBs, adtsHeaderLength);
50
+              return TRANSPORTDEC_PARSE_ERROR;
51
+          }
52
+        } else {
53
+          FDKmemcpy(&pAsc->m_progrConfigElement, &tmpPce,
54
+                    sizeof(CProgramConfig));
55
+        }
56
+      } else {
57
+        if (CProgramConfig_IsValid(&oldPce)) {
58
+          FDKmemcpy(&pAsc->m_progrConfigElement, &oldPce,
59
+                    sizeof(CProgramConfig));
60
+        } else {
61
+          FDKpushBack(hBs, adtsHeaderLength);
62
+          return TRANSPORTDEC_PARSE_ERROR;
63
+        }
64
+      }
65
 
66
       adtsRead_CrcEndReg(pAdts, hBs, crcReg);
67
-      pceBits = alignAnchor - FDKgetValidBits(hBs);
68
+      pceBits = (INT)alignAnchor - (INT)FDKgetValidBits(hBs);
69
+      adtsHeaderLength += pceBits;
70
+
71
+      if (pceBits > (INT)alignAnchor) {
72
+        goto bail;
73
+      }
74
+
75
       /* store the number of PCE bits */
76
       bs.num_pce_bits = pceBits;
77
     } else {
78
fdk-aac-2.0.1.tar.gz/libMpegTPDec/src/tpdec_asc.cpp -> fdk-aac-2.0.2.tar.gz/libMpegTPDec/src/tpdec_asc.cpp Changed
146
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -1325,9 +1325,9 @@
11
                                                   CSTpCallBacks *cb) {
12
   TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK;
13
   CSEldSpecificConfig *esc = &asc->m_sc.m_eldSpecificConfig;
14
-  ASC_ELD_EXT_TYPE eldExtType;
15
+  UINT eldExtType;
16
   int eldExtLen, len, cnt, ldSbrLen = 0, eldExtLenSum, numSbrHeader = 0,
17
-                           sbrIndex;
18
+                           sbrIndex, eldExtCnt = 0;
19
 
20
   unsigned char downscale_fill_nibble;
21
 
22
@@ -1394,9 +1394,8 @@
23
   eldExtLenSum = FDKgetValidBits(hBs);
24
   esc->m_downscaledSamplingFrequency = asc->m_samplingFrequency;
25
   /* parse ExtTypeConfigData */
26
-  while (
27
-      ((eldExtType = (ASC_ELD_EXT_TYPE)FDKreadBits(hBs, 4)) != ELDEXT_TERM) &&
28
-      ((INT)FDKgetValidBits(hBs) >= 0)) {
29
+  while (((eldExtType = FDKreadBits(hBs, 4)) != ELDEXT_TERM) &&
30
+         ((INT)FDKgetValidBits(hBs) >= 0) && (eldExtCnt++ < 15)) {
31
     eldExtLen = len = FDKreadBits(hBs, 4);
32
     if (len == 0xf) {
33
       len = FDKreadBits(hBs, 8);
34
@@ -1440,7 +1439,8 @@
35
         UCHAR tmpDownscaleFreqIdx;
36
         esc->m_downscaledSamplingFrequency =
37
             getSampleRate(hBs, &tmpDownscaleFreqIdx, 4);
38
-        if (esc->m_downscaledSamplingFrequency == 0) {
39
+        if (esc->m_downscaledSamplingFrequency == 0 ||
40
+            esc->m_downscaledSamplingFrequency > 96000) {
41
           return TRANSPORTDEC_PARSE_ERROR;
42
         }
43
         downscale_fill_nibble = FDKreadBits(hBs, 4);
44
@@ -1454,6 +1454,9 @@
45
         break;
46
     }
47
   }
48
+  if (eldExtType != ELDEXT_TERM) {
49
+    return TRANSPORTDEC_PARSE_ERROR;
50
+  }
51
 
52
   if ((INT)FDKgetValidBits(hBs) < 0) {
53
     return TRANSPORTDEC_PARSE_ERROR;
54
@@ -1546,8 +1549,7 @@
55
                                            const AUDIO_OBJECT_TYPE aot) {
56
   TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK;
57
 
58
-  USAC_EXT_ELEMENT_TYPE usacExtElementType =
59
-      (USAC_EXT_ELEMENT_TYPE)escapedValue(hBs, 4, 8, 16);
60
+  int usacExtElementType = escapedValue(hBs, 4, 8, 16);
61
 
62
   /* recurve extension elements which are invalid for USAC */
63
   if (aot == AOT_USAC) {
64
@@ -1564,7 +1566,7 @@
65
     }
66
   }
67
 
68
-  extElement->usacExtElementType = usacExtElementType;
69
+  extElement->usacExtElementType = (USAC_EXT_ELEMENT_TYPE)usacExtElementType;
70
   int usacExtElementConfigLength = escapedValue(hBs, 4, 8, 16);
71
   extElement->usacExtElementConfigLength = (USHORT)usacExtElementConfigLength;
72
   INT bsAnchor;
73
@@ -1628,14 +1630,14 @@
74
   TRANSPORTDEC_ERROR ErrorStatus = TRANSPORTDEC_OK;
75
 
76
   int numConfigExtensions;
77
-  CONFIG_EXT_ID usacConfigExtType;
78
+  int usacConfigExtType;
79
   int usacConfigExtLength;
80
 
81
   numConfigExtensions = (int)escapedValue(hBs, 2, 4, 8) + 1;
82
   for (int confExtIdx = 0; confExtIdx < numConfigExtensions; confExtIdx++) {
83
     INT nbits;
84
     int loudnessInfoSetConfigExtensionPosition = FDKgetValidBits(hBs);
85
-    usacConfigExtType = (CONFIG_EXT_ID)escapedValue(hBs, 4, 8, 16);
86
+    usacConfigExtType = escapedValue(hBs, 4, 8, 16);
87
     usacConfigExtLength = (int)escapedValue(hBs, 4, 8, 16);
88
 
89
     /* Start bit position of config extension */
90
@@ -1948,6 +1950,9 @@
91
   INT nbits = (INT)FDKgetValidBits(hBs);
92
 
93
   usacSamplingFrequency = getSampleRate(hBs, &asc->m_samplingFrequencyIndex, 5);
94
+  if (usacSamplingFrequency == 0 || usacSamplingFrequency > 96000) {
95
+    return TRANSPORTDEC_PARSE_ERROR;
96
+  }
97
   asc->m_samplingFrequency = (UINT)usacSamplingFrequency;
98
 
99
   coreSbrFrameLengthIndex = FDKreadBits(hBs, 3);
100
@@ -2027,7 +2032,8 @@
101
               self->m_extensionSamplingFrequency = getSampleRate(
102
                   bs, &self->m_extensionSamplingFrequencyIndex, 4);
103
 
104
-              if ((INT)self->m_extensionSamplingFrequency <= 0) {
105
+              if (self->m_extensionSamplingFrequency == 0 ||
106
+                  self->m_extensionSamplingFrequency > 96000) {
107
                 return TRANSPORTDEC_PARSE_ERROR;
108
               }
109
             }
110
@@ -2139,6 +2145,24 @@
111
 
112
     self->m_channelConfiguration = FDKreadBits(bs, 4);
113
 
114
+    /* MPEG-04 standard ISO/IEC 14496-3: channelConfiguration == 0 is reserved
115
+       in er_raw_data_block (table 4.19) and er_raw_data_block_eld (table 4.75)
116
+       MPEG-04 conformance ISO/IEC 14496-4: channelConfiguration == 0 is not
117
+       permitted for AOT_ER_AAC_LC, AOT_ER_AAC_LTP, AOT_ER_AAC_LD,
118
+       AOT_ER_AAC_SCAL (chapter 6.6.4.1.2.1.1) */
119
+    if ((self->m_channelConfiguration == 0) &&
120
+        ((self->m_aot == AOT_ER_AAC_LC) || (self->m_aot == AOT_ER_AAC_LTP) ||
121
+         (self->m_aot == AOT_ER_AAC_LD) || (self->m_aot == AOT_ER_AAC_SCAL) ||
122
+         (self->m_aot == AOT_ER_AAC_ELD))) {
123
+      return TRANSPORTDEC_UNSUPPORTED_FORMAT;
124
+    }
125
+    /* MPEG-04 conformance ISO/IEC 14496-4: channelConfiguration > 2 is not
126
+     * permitted for AOT_AAC_SCAL and AOT_ER_AAC_SCAL (chapter 6.6.4.1.2.1.1) */
127
+    if ((self->m_channelConfiguration > 2) &&
128
+        ((self->m_aot == AOT_AAC_SCAL) || (self->m_aot == AOT_ER_AAC_SCAL))) {
129
+      return TRANSPORTDEC_UNSUPPORTED_FORMAT;
130
+    }
131
+
132
     /* SBR extension ( explicit non-backwards compatible mode ) */
133
     self->m_sbrPresentFlag = 0;
134
     self->m_psPresentFlag = 0;
135
@@ -2153,6 +2177,10 @@
136
 
137
       self->m_extensionSamplingFrequency =
138
           getSampleRate(bs, &self->m_extensionSamplingFrequencyIndex, 4);
139
+      if (self->m_extensionSamplingFrequency == 0 ||
140
+          self->m_extensionSamplingFrequency > 96000) {
141
+        return TRANSPORTDEC_PARSE_ERROR;
142
+      }
143
       self->m_aot = getAOT(bs);
144
 
145
       switch (self->m_aot) {
146
fdk-aac-2.0.1.tar.gz/libMpegTPDec/src/tpdec_latm.cpp -> fdk-aac-2.0.2.tar.gz/libMpegTPDec/src/tpdec_latm.cpp Changed
23
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -367,10 +367,10 @@
11
           }
12
           if (pLatmDemux->m_AudioMuxVersion == 1) {
13
             FDK_BITSTREAM tmpBs;
14
-            UINT ascLen = 0;
15
+            INT ascLen = 0;
16
             ascLen = CLatmDemux_GetValue(bs);
17
             /* The ascLen could be wrong, so check if validBits<=bufBits*/
18
-            if (ascLen > FDKgetValidBits(bs)) {
19
+            if (ascLen < 0 || ascLen > (INT)FDKgetValidBits(bs)) {
20
               ErrorStatus = TRANSPORTDEC_PARSE_ERROR;
21
               goto bail;
22
             }
23
fdk-aac-2.0.1.tar.gz/libMpegTPDec/src/tpdec_lib.cpp -> fdk-aac-2.0.2.tar.gz/libMpegTPDec/src/tpdec_lib.cpp Changed
130
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -274,7 +274,7 @@
11
   UCHAR configChanged = 0;
12
   UCHAR configMode = AC_CM_DET_CFG_CHANGE;
13
 
14
-  UCHAR tmpConf[1024];
15
+  UCHAR tmpConf[1024] = {0};
16
   if (length > 1024) {
17
     return TRANSPORTDEC_UNSUPPORTED_FORMAT;
18
   }
19
@@ -482,7 +482,8 @@
20
 
21
         for (int i = 0; i < 2; i++) {
22
           if (i > 0) {
23
-            FDKpushBack(hBs, newConfigLength * 8 - FDKgetValidBits(hBs));
24
+            FDKpushBack(hBs,
25
+                        (INT)newConfigLength * 8 - (INT)FDKgetValidBits(hBs));
26
             configMode = AC_CM_ALLOC_MEM;
27
           }
28
           /* config transport decoder */
29
@@ -663,10 +664,14 @@
30
     if (*pBytesValid == 0) {
31
       /* nothing to do */
32
       return TRANSPORTDEC_OK;
33
-    }
34
-
35
-    if (hTp->numberOfRawDataBlocks <= 0) {
36
+    } else {
37
+      const int bytesValid = *pBytesValid;
38
       FDKfeedBuffer(hBs, pBuffer, bufferSize, pBytesValid);
39
+
40
+      if (hTp->numberOfRawDataBlocks > 0) {
41
+        hTp->globalFramePos += (bytesValid - *pBytesValid) * 8;
42
+        hTp->accessUnitAnchor[layer] = FDKgetValidBits(hBs);
43
+      }
44
     }
45
   }
46
 
47
@@ -924,6 +929,11 @@
48
               }
49
             }
50
           }
51
+          /* if an error is detected terminate config parsing to avoid that an
52
+           * invalid config is accepted in the second pass */
53
+          if (err != TRANSPORTDEC_OK) {
54
+            break;
55
+          }
56
         }
57
       } else {
58
         /* Reset CRC because the next bits are the beginning of a
59
@@ -976,6 +986,9 @@
60
               CLatmDemux_GetNrOfSubFrames(&hTp->parser.latm);
61
           if (hTp->transportFmt == TT_MP4_LOAS) {
62
             syncLayerFrameBits -= startPos - (INT)FDKgetValidBits(hBs) - (13);
63
+            if (syncLayerFrameBits <= 0) {
64
+              err = TRANSPORTDEC_SYNC_ERROR;
65
+            }
66
           }
67
         }
68
       } else {
69
@@ -1151,6 +1164,11 @@
70
                                     &rawDataBlockLength, &fTraverseMoreFrames,
71
                                     &syncLayerFrameBits, &fConfigFound,
72
                                     &headerBits);
73
+      if (headerBits > bitsAvail) {
74
+        err = (headerBits < (INT)hBs->hBitBuf.bufBits)
75
+                  ? TRANSPORTDEC_NOT_ENOUGH_BITS
76
+                  : TRANSPORTDEC_SYNC_ERROR;
77
+      }
78
       if (TPDEC_IS_FATAL_ERROR(err)) {
79
         /* Rewind - TPDEC_SYNCSKIP, in order to look for a synch one bit ahead
80
          * next time. Ensure that the bit amount lands at a multiple of
81
@@ -1181,8 +1199,6 @@
82
     }
83
 
84
     if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) {
85
-      /* Enforce reading of new data */
86
-      hTp->numberOfRawDataBlocks = 0;
87
       break;
88
     }
89
 
90
@@ -1263,8 +1279,9 @@
91
   if (!(hTp->flags & (TPDEC_LOST_FRAMES_PENDING | TPDEC_IGNORE_BUFFERFULLNESS |
92
                       TPDEC_SYNCOK)) &&
93
       err == TRANSPORTDEC_OK) {
94
-    err = additionalHoldOffNeeded(hTp, transportDec_GetBufferFullness(hTp),
95
-                                  FDKgetValidBits(hBs) - syncLayerFrameBits);
96
+    err =
97
+        additionalHoldOffNeeded(hTp, transportDec_GetBufferFullness(hTp),
98
+                                (INT)FDKgetValidBits(hBs) - syncLayerFrameBits);
99
     if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) {
100
       hTp->holdOffFrames++;
101
     }
102
@@ -1273,7 +1290,9 @@
103
   /* Rewind for retry because of not enough bits */
104
   if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) {
105
     FDKpushBack(hBs, headerBits);
106
+    hTp->numberOfRawDataBlocks = numRawDataBlocksPrevious;
107
     headerBits = 0;
108
+    rawDataBlockLength = rawDataBlockLengthPrevious;
109
   } else {
110
     /* reset hold off frame counter */
111
     hTp->holdOffFrames = 0;
112
@@ -1460,7 +1479,7 @@
113
 
114
         for (i = 0; i < 2; i++) {
115
           if (i > 0) {
116
-            FDKpushBack(hBs, bsStart - FDKgetValidBits(hBs));
117
+            FDKpushBack(hBs, bsStart - (INT)FDKgetValidBits(hBs));
118
             configMode = AC_CM_ALLOC_MEM;
119
           }
120
 
121
@@ -1750,7 +1769,7 @@
122
   info += i;
123
 
124
   info->module_id = FDK_TPDEC;
125
-#ifdef __ANDROID__
126
+#ifdef SUPPRESS_BUILD_DATE_INFO
127
   info->build_date = "";
128
   info->build_time = "";
129
 #else
130
fdk-aac-2.0.1.tar.gz/libMpegTPEnc/src/tpenc_lib.cpp -> fdk-aac-2.0.2.tar.gz/libMpegTPEnc/src/tpenc_lib.cpp Changed
10
 
1
@@ -647,7 +647,7 @@
2
   info->module_id = FDK_TPENC;
3
   info->version = LIB_VERSION(TP_LIB_VL0, TP_LIB_VL1, TP_LIB_VL2);
4
   LIB_VERSION_STRING(info);
5
-#ifdef __ANDROID__
6
+#ifdef SUPPRESS_BUILD_DATE_INFO
7
   info->build_date = "";
8
   info->build_time = "";
9
 #else
10
fdk-aac-2.0.1.tar.gz/libPCMutils/include/limiter.h -> fdk-aac-2.0.2.tar.gz/libPCMutils/include/limiter.h Changed
67
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -109,8 +109,6 @@
11
 #define TDL_ATTACK_DEFAULT_MS (15)  /* default attack  time in ms */
12
 #define TDL_RELEASE_DEFAULT_MS (50) /* default release time in ms */
13
 
14
-#define TDL_GAIN_SCALING (15) /* scaling of gain value. */
15
-
16
 #ifdef __cplusplus
17
 extern "C" {
18
 #endif
19
@@ -128,10 +126,7 @@
20
   unsigned int maxBufIdx, delayBufIdx;
21
   FIXP_DBL smoothState0;
22
   FIXP_DBL minGain;
23
-
24
-  FIXP_DBL additionalGainPrev;
25
-  FIXP_DBL additionalGainFilterState;
26
-  FIXP_DBL additionalGainFilterState1;
27
+  INT scaling;
28
 };
29
 
30
 typedef enum {
31
@@ -255,27 +250,16 @@
32
 
33
 /******************************************************************************
34
  * pcmLimiter_Apply                                                            *
35
- * limiter:    limiter handle                                                  *
36
- * pGain :     pointer to gains to be applied to the signal before limiting,   *
37
- *             which are downscaled by TDL_GAIN_SCALING bit.                   *
38
- *             These gains are delayed by gain_delay, and smoothed.            *
39
- *             Smoothing is done by a butterworth lowpass filter with a cutoff *
40
- *             frequency which is fixed with respect to the sampling rate.     *
41
- *             It is a substitute for the smoothing due to windowing and       *
42
- *             overlap/add, if a gain is applied in frequency domain.          *
43
- * gain_scale: pointer to scaling exponents to be applied to the signal before *
44
- *             limiting, without delay and without smoothing                   *
45
- * gain_size:  number of elements in pGain, currently restricted to 1          *
46
- * gain_delay: delay [samples] with which the gains in pGain shall be applied  *
47
- *             gain_delay <= nSamples                                          *
48
- * samples:    input/output buffer containing interleaved samples              *
49
- *             precision of output will be DFRACT_BITS-TDL_GAIN_SCALING bits   *
50
- * nSamples:   number of samples per channel                                   *
51
+ * limiter:        limiter handle                                              *
52
+ * samplesIn:      pointer to input buffer containing interleaved samples      *
53
+ * samplesOut:     pointer to output buffer containing interleaved samples     *
54
+ * pGainPerSample: pointer to gains for each sample                            *
55
+ * scaling:        scaling of output samples                                   *
56
+ * nSamples:       number of samples per channel                               *
57
  * returns:    error code                                                      *
58
  ******************************************************************************/
59
 TDLIMITER_ERROR pcmLimiter_Apply(TDLimiterPtr limiter, PCM_LIM* samplesIn,
60
-                                 INT_PCM* samplesOut, FIXP_DBL* pGain,
61
-                                 const INT* gain_scale, const UINT gain_size,
62
-                                 const UINT gain_delay, const UINT nSamples);
63
+                                 INT_PCM* samplesOut, FIXP_DBL* pGainPerSample,
64
+                                 const INT scaling, const UINT nSamples);
65
 
66
 #endif /* #ifndef LIMITER_H */
67
fdk-aac-2.0.1.tar.gz/libPCMutils/src/limiter.cpp -> fdk-aac-2.0.2.tar.gz/libPCMutils/src/limiter.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -152,7 +152,7 @@
11
   limiter->attack = attack;
12
   limiter->attackConst = attackConst;
13
   limiter->releaseConst = releaseConst;
14
-  limiter->threshold = threshold >> TDL_GAIN_SCALING;
15
+  limiter->threshold = threshold;
16
   limiter->channels = maxChannels;
17
   limiter->maxChannels = maxChannels;
18
   limiter->sampleRate = maxSampleRate;
19
@@ -165,18 +165,13 @@
20
 
21
 /* apply limiter */
22
 TDLIMITER_ERROR pcmLimiter_Apply(TDLimiterPtr limiter, PCM_LIM* samplesIn,
23
-                                 INT_PCM* samplesOut, FIXP_DBL* RESTRICT pGain,
24
-                                 const INT* RESTRICT gain_scale,
25
-                                 const UINT gain_size, const UINT gain_delay,
26
-                                 const UINT nSamples) {
27
+                                 INT_PCM* samplesOut, FIXP_DBL* pGainPerSample,
28
+                                 const INT scaling, const UINT nSamples) {
29
   unsigned int i, j;
30
-  FIXP_DBL tmp1;
31
   FIXP_DBL tmp2;
32
-  FIXP_DBL tmp, old, gain, additionalGain = 0, additionalGainUnfiltered;
33
+  FIXP_DBL tmp, old, gain, additionalGain = 0;
34
   FIXP_DBL minGain = FL2FXCONST_DBL(1.0f / (1 << 1));
35
-
36
-  FDK_ASSERT(gain_size == 1);
37
-  FDK_ASSERT(gain_delay <= nSamples);
38
+  UINT additionalGainAvailable = 1;
39
 
40
   if (limiter == NULL) return TDLIMIT_INVALID_HANDLE;
41
 
42
@@ -185,7 +180,7 @@
43
     unsigned int attack = limiter->attack;
44
     FIXP_DBL attackConst = limiter->attackConst;
45
     FIXP_DBL releaseConst = limiter->releaseConst;
46
-    FIXP_DBL threshold = limiter->threshold;
47
+    FIXP_DBL threshold = limiter->threshold >> scaling;
48
 
49
     FIXP_DBL max = limiter->max;
50
     FIXP_DBL* maxBuf = limiter->maxBuf;
51
@@ -195,55 +190,34 @@
52
     unsigned int delayBufIdx = limiter->delayBufIdx;
53
 
54
     FIXP_DBL smoothState0 = limiter->smoothState0;
55
-    FIXP_DBL additionalGainSmoothState = limiter->additionalGainFilterState;
56
-    FIXP_DBL additionalGainSmoothState1 = limiter->additionalGainFilterState1;
57
 
58
-    if (!gain_delay) {
59
-      additionalGain = pGain[0];
60
-      if (gain_scale[0] > 0) {
61
-        additionalGain <<= gain_scale[0];
62
-      } else {
63
-        additionalGain >>= -gain_scale[0];
64
-      }
65
+    if (limiter->scaling != scaling) {
66
+      scaleValuesSaturate(delayBuf, attack * channels,
67
+                          limiter->scaling - scaling);
68
+      scaleValuesSaturate(maxBuf, attack + 1, limiter->scaling - scaling);
69
+      max = scaleValueSaturate(max, limiter->scaling - scaling);
70
+      limiter->scaling = scaling;
71
     }
72
 
73
-    for (i = 0; i < nSamples; i++) {
74
-      if (gain_delay) {
75
-        if (i < gain_delay) {
76
-          additionalGainUnfiltered = limiter->additionalGainPrev;
77
-        } else {
78
-          additionalGainUnfiltered = pGain[0];
79
-        }
80
+    if (pGainPerSample == NULL) {
81
+      additionalGainAvailable = 0;
82
+    }
83
 
84
-        /* Smooth additionalGain */
85
-        /* [b,a] = butter(1, 0.01) */
86
-        static const FIXP_SGL b[] = {FL2FXCONST_SGL(0.015466 * 2.0),
87
-                                     FL2FXCONST_SGL(0.015466 * 2.0)};
88
-        static const FIXP_SGL a[] = {(FIXP_SGL)MAXVAL_SGL,
89
-                                     FL2FXCONST_SGL(-0.96907)};
90
-        additionalGain = -fMult(additionalGainSmoothState, a[1]) +
91
-                         fMultDiv2(additionalGainUnfiltered, b[0]) +
92
-                         fMultDiv2(additionalGainSmoothState1, b[1]);
93
-        additionalGainSmoothState1 = additionalGainUnfiltered;
94
-        additionalGainSmoothState = additionalGain;
95
-
96
-        /* Apply the additional scaling that has no delay and no smoothing */
97
-        if (gain_scale[0] > 0) {
98
-          additionalGain <<= gain_scale[0];
99
-        } else {
100
-          additionalGain >>= -gain_scale[0];
101
-        }
102
-      }
103
+    for (i = 0; i < nSamples; i++) {
104
       /* get maximum absolute sample value of all channels, including the
105
        * additional gain. */
106
-      tmp1 = (FIXP_DBL)0;
107
+      tmp = (FIXP_DBL)0;
108
       for (j = 0; j < channels; j++) {
109
         tmp2 = PCM_LIM2FIXP_DBL(samplesIn[j]);
110
-        tmp2 = fAbs(tmp2);
111
-        tmp2 = FIXP_DBL(INT(tmp2) ^ INT((tmp2 >> (SAMPLE_BITS_LIM - 1))));
112
-        tmp1 = fMax(tmp1, tmp2);
113
+        tmp2 =
114
+            (tmp2 == (FIXP_DBL)MINVAL_DBL) ? (FIXP_DBL)MAXVAL_DBL : fAbs(tmp2);
115
+        tmp = fMax(tmp, tmp2);
116
+      }
117
+
118
+      if (additionalGainAvailable) {
119
+        additionalGain = pGainPerSample[i];
120
+        tmp = fMult(tmp, additionalGain);
121
       }
122
-      tmp = fMult(tmp1, additionalGain);
123
 
124
       /* set threshold as lower border to save calculations in running maximum
125
        * algorithm */
126
@@ -314,22 +288,42 @@
127
         /* lookahead delay, apply gain */
128
         for (j = 0; j < channels; j++) {
129
           tmp = p_delayBuf[j];
130
-          p_delayBuf[j] = fMult((FIXP_PCM_LIM)samplesIn[j], additionalGain);
131
+
132
+          if (additionalGainAvailable) {
133
+            p_delayBuf[j] = fMult((FIXP_PCM_LIM)samplesIn[j], additionalGain);
134
+          } else {
135
+            p_delayBuf[j] = PCM_LIM2FIXP_DBL(samplesIn[j]);
136
+          }
137
 
138
           /* Apply gain to delayed signal */
139
           tmp = fMultDiv2(tmp, gain);
140
-
141
+#if (SAMPLE_BITS == DFRACT_BITS)
142
+          samplesOut[j] = (INT_PCM)FX_DBL2FX_PCM(
143
+              (FIXP_DBL)SATURATE_LEFT_SHIFT(tmp, scaling + 1, DFRACT_BITS));
144
+#else
145
           samplesOut[j] = (INT_PCM)FX_DBL2FX_PCM((FIXP_DBL)SATURATE_LEFT_SHIFT(
146
-              tmp, TDL_GAIN_SCALING + 1, DFRACT_BITS));
147
+              tmp + ((FIXP_DBL)0x8000 >> (scaling + 1)), scaling + 1,
148
+              DFRACT_BITS));
149
+#endif
150
         }
151
         gain >>= 1;
152
       } else {
153
         /* lookahead delay, apply gain=1.0f */
154
         for (j = 0; j < channels; j++) {
155
           tmp = p_delayBuf[j];
156
-          p_delayBuf[j] = fMult((FIXP_PCM_LIM)samplesIn[j], additionalGain);
157
+          if (additionalGainAvailable) {
158
+            p_delayBuf[j] = fMult((FIXP_PCM_LIM)samplesIn[j], additionalGain);
159
+          } else {
160
+            p_delayBuf[j] = PCM_LIM2FIXP_DBL(samplesIn[j]);
161
+          }
162
+
163
+#if (SAMPLE_BITS == DFRACT_BITS)
164
+          samplesOut[j] = (INT_PCM)FX_DBL2FX_PCM(
165
+              (FIXP_DBL)SATURATE_LEFT_SHIFT(tmp, scaling, DFRACT_BITS));
166
+#else
167
           samplesOut[j] = (INT_PCM)FX_DBL2FX_PCM((FIXP_DBL)SATURATE_LEFT_SHIFT(
168
-              tmp, TDL_GAIN_SCALING, DFRACT_BITS));
169
+              tmp + ((FIXP_DBL)0x8000 >> scaling), scaling, DFRACT_BITS));
170
+#endif
171
         }
172
       }
173
 
174
@@ -354,13 +348,9 @@
175
     limiter->delayBufIdx = delayBufIdx;
176
 
177
     limiter->smoothState0 = smoothState0;
178
-    limiter->additionalGainFilterState = additionalGainSmoothState;
179
-    limiter->additionalGainFilterState1 = additionalGainSmoothState1;
180
 
181
     limiter->minGain = minGain;
182
 
183
-    limiter->additionalGainPrev = pGain[0];
184
-
185
     return TDLIMIT_OK;
186
   }
187
 }
188
@@ -370,7 +360,7 @@
189
                                         FIXP_DBL threshold) {
190
   if (limiter == NULL) return TDLIMIT_INVALID_HANDLE;
191
 
192
-  limiter->threshold = threshold >> TDL_GAIN_SCALING;
193
+  limiter->threshold = threshold;
194
 
195
   return TDLIMIT_OK;
196
 }
197
@@ -384,13 +374,7 @@
198
     limiter->cor = FL2FXCONST_DBL(1.0f / (1 << 1));
199
     limiter->smoothState0 = FL2FXCONST_DBL(1.0f / (1 << 1));
200
     limiter->minGain = FL2FXCONST_DBL(1.0f / (1 << 1));
201
fdk-aac-2.0.1.tar.gz/libPCMutils/src/pcmdmx_lib.cpp -> fdk-aac-2.0.2.tar.gz/libPCMutils/src/pcmdmx_lib.cpp Changed
9
 
1
@@ -585,7 +585,6 @@
2
 
3
     if (channelIndices[ch] >= numCh[channelType[ch] >> 4][chGrp])
4
       return PCMDMX_INVALID_CH_CONFIG;
5
-
6
     spkrPos[ch] = getSpeakerPos(channelType[ch], channelIndices[ch],
7
                                 numCh[channelType[ch] >> 4][chGrp]);
8
 
9
fdk-aac-2.0.1.tar.gz/libPCMutils/src/version.h -> fdk-aac-2.0.2.tar.gz/libPCMutils/src/version.h Changed
23
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -105,10 +105,10 @@
11
 
12
 /* library info */
13
 #define PCMUTIL_LIB_VL0 3
14
-#define PCMUTIL_LIB_VL1 0
15
+#define PCMUTIL_LIB_VL1 1
16
 #define PCMUTIL_LIB_VL2 0
17
 #define PCMUTIL_LIB_TITLE "PCM Utility Lib"
18
-#ifdef __ANDROID__
19
+#ifdef SUPPRESS_BUILD_DATE_INFO
20
 #define PCMUTIL_LIB_BUILD_DATE ""
21
 #define PCMUTIL_LIB_BUILD_TIME ""
22
 #else
23
fdk-aac-2.0.1.tar.gz/libSACdec/include/sac_dec_lib.h -> fdk-aac-2.0.2.tar.gz/libSACdec/include/sac_dec_lib.h Changed
44
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -252,7 +252,7 @@
11
                 scenario. Default parameter value is 3 frames. */
12
 } SACDEC_PARAM;
13
 
14
-#define PCM_MPS INT_PCM
15
+#define PCM_MPS LONG
16
 
17
 /**
18
  * \brief MPEG Surround decoder handle.
19
@@ -401,17 +401,22 @@
20
  * for each output audio channel is stored into.
21
  * \param mapDescr             Channep map descriptor for output channel mapping
22
  * to be used (From MPEG PCE ordering to whatever is required).
23
+ * \param inDataHeadroom       Headroom of SAC input time signal to prevent
24
+ * clipping.
25
+ * \param outDataHeadroom      Pointer to headroom of SAC output time signal to
26
+ * prevent clipping.
27
  *
28
  * \return  Error code.
29
  */
30
 int mpegSurroundDecoder_Apply(CMpegSurroundDecoder *pMpegSurroundDecoder,
31
-                              INT_PCM *input, PCM_MPS *pTimeData,
32
+                              PCM_MPS *input, PCM_MPS *pTimeData,
33
                               const int timeDataSize, int timeDataFrameSize,
34
                               int *nChannels, int *frameSize, int sampleRate,
35
                               AUDIO_OBJECT_TYPE coreCodec,
36
                               AUDIO_CHANNEL_TYPE channelType[],
37
                               UCHAR channelIndices[],
38
-                              const FDK_channelMapDescr *const mapDescr);
39
+                              const FDK_channelMapDescr *const mapDescr,
40
+                              const INT inDataHeadroom, INT *outDataHeadroom);
41
 
42
 /**
43
  * \brief                       Deallocate a MPEG Surround decoder instance.
44
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_bitdec.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_bitdec.cpp Changed
99
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -448,6 +448,7 @@
11
   int bsFreqRes, b3DaudioMode = 0;
12
   int numHeaderBits;
13
   int cfgStartPos, bitsAvailable;
14
+  int treeConfig;
15
 
16
   FDKmemclear(pSpatialSpecificConfig, sizeof(SPATIAL_SPECIFIC_CONFIG));
17
 
18
@@ -488,13 +489,13 @@
19
   pSpatialSpecificConfig->freqRes =
20
       (SPATIALDEC_FREQ_RES)freqResTable_LD[bsFreqRes];
21
 
22
-  pSpatialSpecificConfig->treeConfig =
23
-      (SPATIALDEC_TREE_CONFIG)FDKreadBits(bitstream, 4);
24
+  treeConfig = FDKreadBits(bitstream, 4);
25
 
26
-  if (pSpatialSpecificConfig->treeConfig != SPATIALDEC_MODE_RSVD7) {
27
+  if (treeConfig != SPATIALDEC_MODE_RSVD7) {
28
     err = MPS_UNSUPPORTED_CONFIG;
29
     goto bail;
30
   }
31
+  pSpatialSpecificConfig->treeConfig = (SPATIALDEC_TREE_CONFIG) treeConfig;
32
 
33
   {
34
     pSpatialSpecificConfig->nOttBoxes =
35
@@ -1457,7 +1458,7 @@
36
     FIXP_DBL (*pOttVsTotDb1)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS],
37
     FIXP_DBL (*pOttVsTotDb2)[MAX_PARAMETER_SETS][MAX_PARAMETER_BANDS]) {
38
   int aParamSlots[MAX_PARAMETER_SETS];
39
-  int aInterpolate[MAX_PARAMETER_SETS];
40
+  int aInterpolate[MAX_PARAMETER_SETS] = {0};
41
 
42
   int dataSets;
43
   int aMap[MAX_PARAMETER_BANDS + 1];
44
@@ -1554,21 +1555,20 @@
45
   /* Interpolate */
46
   i1 = 0;
47
   for (i = 0; i < numParameterSets; i++) {
48
-    int xi, i2, x1, x2;
49
-
50
     if (aInterpolate[i] != 1) {
51
       i1 = i;
52
-    }
53
-    i2 = i;
54
-    while (aInterpolate[i2] == 1) {
55
-      i2++;
56
-    }
57
-    x1 = paramSlot[i1];
58
-    xi = paramSlot[i];
59
-    x2 = paramSlot[i2];
60
+    } else {
61
+      int xi, i2, x1, x2;
62
 
63
-    if (aInterpolate[i] == 1) {
64
+      for (i2 = i; i2 < numParameterSets; i2++) {
65
+        if (aInterpolate[i2] != 1) break;
66
+      }
67
       if (i2 >= numParameterSets) return MPS_WRONG_PARAMETERSETS;
68
+
69
+      x1 = paramSlot[i1];
70
+      xi = paramSlot[i];
71
+      x2 = paramSlot[i2];
72
+
73
       for (band = startBand; band < stopBand; band++) {
74
         int yi, y1, y2;
75
         y1 = outputIdxData[xttIdx][i1][band];
76
@@ -1587,9 +1587,9 @@
77
   for (ps = 0; ps < numParameterSets; ps++) {
78
     if (quantMode && (paramType == t_CLD)) {
79
       if (pOttVsTotDbIn == 0) return MPS_WRONG_OTT;
80
-      if ((pOttVsTotDb1 == 0) && (ottVsTotDbMode == ottVsTotDb1Activ))
81
+      if ((pOttVsTotDb1 == 0) && (ottVsTotDbMode & ottVsTotDb1Activ))
82
         return MPS_WRONG_OTT;
83
-      if ((pOttVsTotDb2 == 0) && (ottVsTotDbMode == ottVsTotDb2Activ))
84
+      if ((pOttVsTotDb2 == 0) && (ottVsTotDbMode & ottVsTotDb2Activ))
85
         return MPS_WRONG_OTT;
86
 
87
       for (pb = startBand; pb < stopBand; pb++) {
88
@@ -1611,6 +1611,10 @@
89
   } /* for( i = 0 ; i < numParameterSets; i++ ) */
90
 
91
   if (extendFrame) {
92
+    if (paramType == t_IPD) {
93
+      llData->bsQuantCoarseXXX[numParameterSets] =
94
+          llData->bsQuantCoarseXXX[numParameterSets - 1];
95
+    }
96
     for (band = startBand; band < stopBand; band++) {
97
       outputDataIdx[xttIdx][numParameterSets][band] =
98
           outputDataIdx[xttIdx][numParameterSets - 1][band];
99
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_calcM1andM2.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_calcM1andM2.cpp Changed
108
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -474,80 +474,6 @@
11
     FL2FXCONST_DBL(0.888178419700125),
12
 };
13
 
14
-static FIXP_DBL dequantIPD_CLD_ICC_splitAngle__FDK_Function(INT ipdIdx,
15
-                                                            INT cldIdx,
16
-                                                            INT iccIdx) {
17
-  FIXP_DBL cld;
18
-  SpatialDequantGetCLD2Values(cldIdx, &cld);
19
-
20
-  /*const FIXP_DBL one_m = (FIXP_DBL)MAXVAL_DBL;
21
-  const int one_e = 0;*/
22
-  const FIXP_DBL one_m = FL2FXCONST_DBL(0.5f);
23
-  const int one_e = 1;
24
-  /* iidLin = sqrt(cld); */
25
-  FIXP_DBL iidLin_m = sqrt_CLD_m[cldIdx];
26
-  int iidLin_e = sqrt_CLD_e[cldIdx];
27
-  /* iidLin2 = cld; */
28
-  FIXP_DBL iidLin2_m = CLD_m[cldIdx];
29
-  int iidLin2_e = sqrt_CLD_e[cldIdx] << 1;
30
-  /* iidLin21 = iidLin2 + 1.0f; */
31
-  int iidLin21_e;
32
-  FIXP_DBL iidLin21_m =
33
-      fAddNorm(iidLin2_m, iidLin2_e, one_m, one_e, &iidLin21_e);
34
-  /* iidIcc2 = iidLin * icc * 2.0f; */
35
-  FIXP_CFG icc = dequantICC__FDK[iccIdx];
36
-  FIXP_DBL temp1_m, temp1c_m;
37
-  int temp1_e, temp1c_e;
38
-  temp1_m = fMult(iidLin_m, icc);
39
-  temp1_e = iidLin_e + 1;
40
-
41
-  FIXP_DBL cosIpd, sinIpd;
42
-  cosIpd = COS_IPD(ipdIdx);
43
-  sinIpd = SIN_IPD(ipdIdx);
44
-
45
-  temp1c_m = fMult(temp1_m, cosIpd);
46
-  temp1c_e = temp1_e;  //+cosIpd_e;
47
-
48
-  int temp2_e, temp3_e, inv_temp3_e, ratio_e;
49
-  FIXP_DBL temp2_m =
50
-      fAddNorm(iidLin21_m, iidLin21_e, temp1c_m, temp1c_e, &temp2_e);
51
-  FIXP_DBL temp3_m =
52
-      fAddNorm(iidLin21_m, iidLin21_e, temp1_m, temp1_e, &temp3_e);
53
-  /* calculate 1/temp3 needed later */
54
-  inv_temp3_e = temp3_e;
55
-  FIXP_DBL inv_temp3_m = invFixp(temp3_m, &inv_temp3_e);
56
-  FIXP_DBL ratio_m =
57
-      fAddNorm(fMult(inv_temp3_m, temp2_m), (inv_temp3_e + temp2_e),
58
-               FL2FXCONST_DBL(1e-9f), 0, &ratio_e);
59
-
60
-  int weight2_e, tempb_atan2_e;
61
-  FIXP_DBL weight2_m =
62
-      fPow(ratio_m, ratio_e, FL2FXCONST_DBL(0.5f), -1, &weight2_e);
63
-  /* atan2(w2*sinIpd, w1*iidLin + w2*cosIpd) = atan2(w2*sinIpd, (2 - w2)*iidLin
64
-   * + w2*cosIpd) = atan2(w2*sinIpd, 2*iidLin + w2*(cosIpd - iidLin)); */
65
-  /* tmpa_atan2 = w2*sinIpd; tmpb_atan2 = 2*iidLin + w2*(cosIpd - iidLin); */
66
-  FIXP_DBL tempb_atan2_m = iidLin_m;
67
-  tempb_atan2_e = iidLin_e + 1;
68
-  int add_tmp1_e = 0;
69
-  FIXP_DBL add_tmp1_m = fAddNorm(cosIpd, 0, -iidLin_m, iidLin_e, &add_tmp1_e);
70
-  FIXP_DBL add_tmp2_m = fMult(add_tmp1_m, weight2_m);
71
-  int add_tmp2_e = add_tmp1_e + weight2_e;
72
-  tempb_atan2_m = fAddNorm(tempb_atan2_m, tempb_atan2_e, add_tmp2_m, add_tmp2_e,
73
-                           &tempb_atan2_e);
74
-
75
-  FIXP_DBL tempa_atan2_m = fMult(weight2_m, sinIpd);
76
-  int tempa_atan2_e = weight2_e;  // + sinIpd_e;
77
-
78
-  if (tempa_atan2_e > tempb_atan2_e) {
79
-    tempb_atan2_m = (tempb_atan2_m >> (tempa_atan2_e - tempb_atan2_e));
80
-    tempb_atan2_e = tempa_atan2_e;
81
-  } else if (tempb_atan2_e > tempa_atan2_e) {
82
-    tempa_atan2_m = (tempa_atan2_m >> (tempb_atan2_e - tempa_atan2_e));
83
-  }
84
-
85
-  return fixp_atan2(tempa_atan2_m, tempb_atan2_m);
86
-}
87
-
88
 static void calculateOpd(spatialDec* self, INT ottBoxIndx, INT parameterSetIndx,
89
                          FIXP_DBL opd[MAX_PARAMETER_BANDS]) {
90
   INT band;
91
@@ -563,12 +489,12 @@
92
     SpatialDequantGetCLD2Values(idxCld, &cld);
93
 
94
     /* ipd(idxIpd==8) == PI */
95
-    if ((cld == FL2FXCONST_DBL(0.0f)) && (idxIpd == 8)) {
96
+    if (((cld == FL2FXCONST_DBL(0.0f)) && (idxIpd == 8)) || (idxIpd == 0)) {
97
       opd[2 * band] = FL2FXCONST_DBL(0.0f);
98
     } else {
99
-      opd[2 * band] = (dequantIPD_CLD_ICC_splitAngle__FDK_Function(
100
-                           idxIpd, idxCld, idxIcc) >>
101
-                       (IPD_SCALE - AT2O_SF));
102
+      FDK_ASSERT(idxIpd > 0);
103
+      opd[2 * band] =
104
+          dequantIPD_CLD_ICC_splitAngle__FDK[idxIpd - 1][idxCld][idxIcc];
105
     }
106
     opd[2 * band + 1] = opd[2 * band] - ipd;
107
   }
108
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_calcM1andM2.h -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_calcM1andM2.h Changed
20
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -117,6 +117,9 @@
11
 /* Scaling of spectral data after applying M2 matrix, but only for binaural
12
    upmix type Scaling is compensated later in synthesis qmf filterbank */
13
 #define SCALE_DATA_APPLY_M2 (1)
14
+/* Applying M2 parameter in combination with phase coding needs 2 bits headroom
15
+ * because up to a maximum of 4 spectral values can be added for USAC */
16
+#define SCALE_DATA_APPLY_M2_PC (2)
17
 
18
 SACDEC_ERROR initM1andM2(spatialDec* self, int initStatesFlag,
19
                          int configChanged);
20
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_dec.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_dec.cpp Changed
107
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -200,6 +200,7 @@
11
 
12
   /* parameter smoothing tool set to off */
13
   bsFrame->bsSmoothMode[0] = 0;
14
+  initParameterSmoothing(self);
15
 
16
   /* reset residual data */
17
   {
18
@@ -765,7 +766,7 @@
19
 
20
     /* output scaling */
21
     for (nCh = 0; nCh < self->numOutputChannelsAT; nCh++) {
22
-      int outputScale = 0, outputGain_e = 0, scale = 0;
23
+      int outputScale = 0, outputGain_e = 0, scale = -(8) + (1);
24
       FIXP_DBL outputGain_m = getChGain(self, nCh, &outputGain_e);
25
 
26
       if (!isTwoChMode(self->upmixType) && !bypassMode) {
27
@@ -774,7 +775,7 @@
28
                                              synthesis qmf */
29
       }
30
 
31
-      scale = outputScale;
32
+      scale += outputScale;
33
 
34
       qmfChangeOutScalefactor(&self->pQmfDomain->QmfDomainOut[nCh].fb, scale);
35
       qmfChangeOutGain(&self->pQmfDomain->QmfDomainOut[nCh].fb, outputGain_m,
36
@@ -1222,18 +1223,24 @@
37
               !(self->stereoConfigIndex == 3)) {
38
             for (i = 0; i < self->qmfBands; i++) {
39
               self_qmfResidualReal__FDK_0_0[i] =
40
-                  fMult(self_qmfResidualReal__FDK_0_0[i] << 1,
41
+                  fMult(scaleValueSaturate(self_qmfResidualReal__FDK_0_0[i],
42
+                                           1 + self->sacInDataHeadroom - (1)),
43
                         self->clipProtectGain__FDK);
44
               self_qmfResidualImag__FDK_0_0[i] =
45
-                  fMult(self_qmfResidualImag__FDK_0_0[i] << 1,
46
+                  fMult(scaleValueSaturate(self_qmfResidualImag__FDK_0_0[i],
47
+                                           1 + self->sacInDataHeadroom - (1)),
48
                         self->clipProtectGain__FDK);
49
             }
50
           } else {
51
             for (i = 0; i < self->qmfBands; i++) {
52
-              self_qmfResidualReal__FDK_0_0[i] = fMult(
53
-                  self_qmfResidualReal__FDK_0_0[i], self->clipProtectGain__FDK);
54
-              self_qmfResidualImag__FDK_0_0[i] = fMult(
55
-                  self_qmfResidualImag__FDK_0_0[i], self->clipProtectGain__FDK);
56
+              self_qmfResidualReal__FDK_0_0[i] =
57
+                  fMult(scaleValueSaturate(self_qmfResidualReal__FDK_0_0[i],
58
+                                           self->sacInDataHeadroom - (1)),
59
+                        self->clipProtectGain__FDK);
60
+              self_qmfResidualImag__FDK_0_0[i] =
61
+                  fMult(scaleValueSaturate(self_qmfResidualImag__FDK_0_0[i],
62
+                                           self->sacInDataHeadroom - (1)),
63
+                        self->clipProtectGain__FDK);
64
             }
65
           }
66
         }
67
@@ -1316,10 +1323,12 @@
68
       if ((self->tempShapeConfig == 1) && (!isTwoChMode(self->upmixType))) {
69
         for (ch = 0; ch < self->numOutputChannels; ch++) {
70
           for (hyb = 0; hyb < self->tp_hybBandBorder; hyb++) {
71
-            self->hybOutputRealDry__FDK[ch][hyb] +=
72
-                self->hybOutputRealWet__FDK[ch][hyb];
73
-            self->hybOutputImagDry__FDK[ch][hyb] +=
74
-                self->hybOutputImagWet__FDK[ch][hyb];
75
+            self->hybOutputRealDry__FDK[ch][hyb] =
76
+                fAddSaturate(self->hybOutputRealDry__FDK[ch][hyb],
77
+                             self->hybOutputRealWet__FDK[ch][hyb]);
78
+            self->hybOutputImagDry__FDK[ch][hyb] =
79
+                fAddSaturate(self->hybOutputImagDry__FDK[ch][hyb],
80
+                             self->hybOutputImagWet__FDK[ch][hyb]);
81
           } /* loop hyb */
82
         }   /* loop ch */
83
         err = subbandTPApply(
84
@@ -1340,11 +1349,11 @@
85
             FIXP_DBL *RESTRICT pRealWet = self->hybOutputRealWet__FDK[ch];
86
             FIXP_DBL *RESTRICT pImagWet = self->hybOutputImagWet__FDK[ch];
87
             for (hyb = 0; hyb < nHybBands; hyb++) {
88
-              pRealDry[hyb] += pRealWet[hyb];
89
-              pImagDry[hyb] += pImagWet[hyb];
90
+              pRealDry[hyb] = fAddSaturate(pRealDry[hyb], pRealWet[hyb]);
91
+              pImagDry[hyb] = fAddSaturate(pImagDry[hyb], pImagWet[hyb]);
92
             } /* loop hyb */
93
             for (; hyb < self->hybridBands; hyb++) {
94
-              pRealDry[hyb] += pRealWet[hyb];
95
+              pRealDry[hyb] = fAddSaturate(pRealDry[hyb], pRealWet[hyb]);
96
             } /* loop hyb */
97
           }   /* loop ch */
98
         } /* ( self->tempShapeConfig == 1 ) || ( self->tempShapeConfig == 2 ) */
99
@@ -1413,6 +1422,7 @@
100
   FDK_ASSERT(self != NULL);
101
   FDK_ASSERT(pControlFlags != NULL);
102
   FDK_ASSERT(pcmOutBuf != NULL);
103
+  FDK_ASSERT(self->sacInDataHeadroom >= (1));
104
 
105
   self->errInt = err; /* Init internal error */
106
 
107
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_dec.h -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_dec.h Changed
20
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -523,6 +523,9 @@
11
                              new frame after SSC change (aka
12
                              decodeAfterConfigHasChangedFlag). */
13
   SpatialDecConcealmentInfo concealInfo;
14
+
15
+  INT sacInDataHeadroom; /* Headroom of the SAC input time signal to prevent
16
+                            clipping */
17
 };
18
 
19
 #define SACDEC_SYNTAX_MPS 1
20
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_dec_interface.h -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_dec_interface.h Changed
24
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -249,10 +249,10 @@
11
 
12
 } MEM_REQUIREMENTS;
13
 
14
-#define PCM_MPS INT_PCM
15
-#define PCM_MPSF FIXP_PCM
16
+#define PCM_MPS LONG
17
+#define PCM_MPSF FIXP_DBL
18
 
19
-#define FIXP_DBL2PCM_MPS(x) ((INT_PCM)FX_DBL2FX_PCM(x))
20
+#define FIXP_DBL2PCM_MPS(x) ((LONG)(x))
21
 
22
 /* exposed functions (library interface) */
23
 
24
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_dec_lib.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_dec_lib.cpp Changed
90
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -1507,15 +1507,17 @@
11
 }
12
 
13
 int mpegSurroundDecoder_Apply(CMpegSurroundDecoder *pMpegSurroundDecoder,
14
-                              INT_PCM *input, PCM_MPS *pTimeData,
15
+                              PCM_MPS *input, PCM_MPS *pTimeData,
16
                               const int timeDataSize, int timeDataFrameSize,
17
                               int *nChannels, int *frameSize, int sampleRate,
18
                               AUDIO_OBJECT_TYPE coreCodec,
19
                               AUDIO_CHANNEL_TYPE channelType[],
20
                               UCHAR channelIndices[],
21
-                              const FDK_channelMapDescr *const mapDescr) {
22
+                              const FDK_channelMapDescr *const mapDescr,
23
+                              const INT inDataHeadroom, INT *outDataHeadroom) {
24
   SACDEC_ERROR err = MPS_OK;
25
   PCM_MPS *pTimeOut = pTimeData;
26
+  PCM_MPS *TDinput = NULL;
27
   UINT initControlFlags = 0, controlFlags = 0;
28
   int timeDataRequiredSize = 0;
29
   int newData;
30
@@ -1534,6 +1536,9 @@
31
     return MPS_NOTOK;
32
   }
33
 
34
+  pMpegSurroundDecoder->pSpatialDec->sacInDataHeadroom = inDataHeadroom;
35
+  *outDataHeadroom = (INT)(8);
36
+
37
   pMpegSurroundDecoder->pSpatialDec->pConfigCurrent =
38
       &pMpegSurroundDecoder
39
            ->spatialSpecificConfig[pMpegSurroundDecoder->bsFrameDecode];
40
@@ -1682,8 +1687,7 @@
41
         (timeDataFrameSize *
42
          pMpegSurroundDecoder->pQmfDomain->globalConf.nBandsSynthesis) /
43
         pMpegSurroundDecoder->pQmfDomain->globalConf.nBandsAnalysis;
44
-    pMpegSurroundDecoder->pQmfDomain->globalConf.TDinput =
45
-        pTimeData + timeDataFrameSizeOut - timeDataFrameSize;
46
+    TDinput = pTimeData + timeDataFrameSizeOut - timeDataFrameSize;
47
     for (int i = *nChannels - 1; i >= 0; i--) {
48
       FDKmemmove(pTimeData + (i + 1) * timeDataFrameSizeOut - timeDataFrameSize,
49
                  pTimeData + timeDataFrameSize * i,
50
@@ -1694,8 +1698,8 @@
51
   } else {
52
     if (pMpegSurroundDecoder->mpegSurroundUseTimeInterface) {
53
       FDKmemcpy(input, pTimeData,
54
-                sizeof(INT_PCM) * (*nChannels) * (*frameSize));
55
-      pMpegSurroundDecoder->pQmfDomain->globalConf.TDinput = input;
56
+                sizeof(PCM_MPS) * (*nChannels) * (*frameSize));
57
+      TDinput = input;
58
     }
59
   }
60
 
61
@@ -1707,8 +1711,8 @@
62
       &pMpegSurroundDecoder->bsFrames[pMpegSurroundDecoder->bsFrameDecode],
63
       pMpegSurroundDecoder->mpegSurroundUseTimeInterface ? INPUTMODE_TIME
64
                                                          : INPUTMODE_QMF_SBR,
65
-      pMpegSurroundDecoder->pQmfDomain->globalConf.TDinput, NULL, NULL,
66
-      pTimeOut, *frameSize, &controlFlags, *nChannels, mapDescr);
67
+      TDinput, NULL, NULL, pTimeOut, *frameSize, &controlFlags, *nChannels,
68
+      mapDescr);
69
   *nChannels = pMpegSurroundDecoder->pSpatialDec->numOutputChannelsAT;
70
 
71
   if (err !=
72
@@ -1781,7 +1785,7 @@
73
 }
74
 
75
 #define SACDEC_VL0 2
76
-#define SACDEC_VL1 0
77
+#define SACDEC_VL1 1
78
 #define SACDEC_VL2 0
79
 
80
 int mpegSurroundDecoder_GetLibInfo(LIB_INFO *info) {
81
@@ -1800,7 +1804,7 @@
82
   info += i;
83
 
84
   info->module_id = FDK_MPSDEC;
85
-#ifdef __ANDROID__
86
+#ifdef SUPPRESS_BUILD_DATE_INFO
87
   info->build_date = "";
88
   info->build_time = "";
89
 #else
90
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_process.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_process.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -113,6 +113,8 @@
11
 #include "FDK_trigFcts.h"
12
 #include "FDK_decorrelate.h"
13
 
14
+#define SAC_DEC_APPLY_M2_SCALE(spec, s) ((spec) >> (-(s)))
15
+
16
 /**
17
  * \brief  Linear interpolation between two parameter values.
18
  *         a*alpha + b*(1-alpha)
19
@@ -185,8 +187,12 @@
20
       if (!isTwoChMode(self->upmixType) && !bypassMode) {
21
         int i;
22
         for (i = 0; i < self->qmfBands; i++) {
23
-          qmfReal[ch][i] = fMult(qmfReal[ch][i], self->clipProtectGain__FDK);
24
-          qmfImag[ch][i] = fMult(qmfImag[ch][i], self->clipProtectGain__FDK);
25
+          qmfReal[ch][i] = fMult(
26
+              scaleValueSaturate(qmfReal[ch][i], self->sacInDataHeadroom - (1)),
27
+              self->clipProtectGain__FDK);
28
+          qmfImag[ch][i] = fMult(
29
+              scaleValueSaturate(qmfImag[ch][i], self->sacInDataHeadroom - (1)),
30
+              self->clipProtectGain__FDK);
31
         }
32
       }
33
     }
34
@@ -214,16 +220,17 @@
35
 
36
       /* Write Input data to pQmfRealAnalysis. */
37
       if (self->bShareDelayWithSBR) {
38
-        FDK_QmfDomain_GetSlot(
39
-            &self->pQmfDomain->QmfDomainIn[ch], ts + HYBRID_FILTER_DELAY, 0,
40
-            MAX_QMF_BANDS_TO_HYBRID, pQmfRealAnalysis, pQmfImagAnalysis, 15);
41
+        FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch],
42
+                              ts + HYBRID_FILTER_DELAY, 0,
43
+                              MAX_QMF_BANDS_TO_HYBRID, pQmfRealAnalysis,
44
+                              pQmfImagAnalysis, 15 + (1));
45
         FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch], ts,
46
                               MAX_QMF_BANDS_TO_HYBRID, self->qmfBands,
47
-                              pQmfRealAnalysis, pQmfImagAnalysis, 15);
48
+                              pQmfRealAnalysis, pQmfImagAnalysis, 15 + (1));
49
       } else {
50
         FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch], ts, 0,
51
                               self->qmfBands, pQmfRealAnalysis,
52
-                              pQmfImagAnalysis, 15);
53
+                              pQmfImagAnalysis, 15 + (1));
54
       }
55
       if (ts == self->pQmfDomain->globalConf.nQmfTimeSlots - 1) {
56
         /* Is currently also needed in case we dont have any overlap. We need to
57
@@ -499,8 +506,8 @@
58
     for (pb = 0, qs = 3; pb < 2; pb++) {
59
       INT s;
60
       FIXP_DBL maxVal;
61
-      FIXP_SGL mReal1;
62
-      FIXP_SGL mReal0, mImag0;
63
+      FIXP_DBL mReal1;
64
+      FIXP_DBL mReal0, mImag0;
65
       FIXP_DBL iReal0, iImag0, iReal1;
66
 
67
       iReal0 = interpolateParameter(alpha, MReal0[pb], MRealPrev0[pb]);
68
@@ -513,9 +520,9 @@
69
       s = fMax(CntLeadingZeros(maxVal) - 1, 0);
70
       s = fMin(s, scale_param_m2);
71
 
72
-      mReal0 = FX_DBL2FX_SGL(iReal0 << s);
73
-      mImag0 = FX_DBL2FX_SGL(iImag0 << s);
74
-      mReal1 = FX_DBL2FX_SGL(iReal1 << s);
75
+      mReal0 = iReal0 << s;
76
+      mImag0 = iImag0 << s;
77
+      mReal1 = iReal1 << s;
78
 
79
       s = scale_param_m2 - s;
80
 
81
@@ -634,8 +641,7 @@
82
     }
83
 
84
     if (self->phaseCoding == 3) {
85
-      /* + SCALE_DATA_APPLY_M2 to compensate for Div2 below ?! */
86
-      scale_param_m2 = SCALE_PARAM_M2_212_PRED + SCALE_DATA_APPLY_M2;
87
+      scale_param_m2 = -(SCALE_DATA_APPLY_M2_PC - 1);
88
     }
89
 
90
     for (row = 0; row < self->numM2rows; row++) {
91
@@ -686,10 +692,10 @@
92
           } else { /*  isBinauralMode(self->upmixType)  */
93
 
94
             for (qs = 0; qs < complexHybBands; qs++) {
95
-              pHybOutRealDry[qs] += fMultDiv2(pWReal[qs], pKernel[qs])
96
-                                    << (scale_param_m2);
97
-              pHybOutImagDry[qs] += fMultDiv2(pWImag[qs], pKernel[qs])
98
-                                    << (scale_param_m2);
99
+              pHybOutRealDry[qs] += SAC_DEC_APPLY_M2_SCALE(
100
+                  fMultDiv2(pWReal[qs], pKernel[qs]), scale_param_m2);
101
+              pHybOutImagDry[qs] += SAC_DEC_APPLY_M2_SCALE(
102
+                  fMultDiv2(pWImag[qs], pKernel[qs]), scale_param_m2);
103
             }
104
 
105
             M2ParamToKernelMult(pKernel, self->M2Imag__FDK[row][col],
106
@@ -697,27 +703,27 @@
107
                                 self->kernels_width, alpha, complexParBands);
108
 
109
             /* direct signals sign is -1 for qs = 0,2 */
110
-            pHybOutRealDry[0] += fMultDiv2(pWImag[0], pKernel[0])
111
-                                 << (scale_param_m2);
112
-            pHybOutImagDry[0] -= fMultDiv2(pWReal[0], pKernel[0])
113
-                                 << (scale_param_m2);
114
+            pHybOutRealDry[0] += SAC_DEC_APPLY_M2_SCALE(
115
+                fMultDiv2(pWImag[0], pKernel[0]), scale_param_m2);
116
+            pHybOutImagDry[0] -= SAC_DEC_APPLY_M2_SCALE(
117
+                fMultDiv2(pWReal[0], pKernel[0]), scale_param_m2);
118
 
119
-            pHybOutRealDry[2] += fMultDiv2(pWImag[2], pKernel[2])
120
-                                 << (scale_param_m2);
121
-            pHybOutImagDry[2] -= fMultDiv2(pWReal[2], pKernel[2])
122
-                                 << (scale_param_m2);
123
+            pHybOutRealDry[2] += SAC_DEC_APPLY_M2_SCALE(
124
+                fMultDiv2(pWImag[2], pKernel[2]), scale_param_m2);
125
+            pHybOutImagDry[2] -= SAC_DEC_APPLY_M2_SCALE(
126
+                fMultDiv2(pWReal[2], pKernel[2]), scale_param_m2);
127
 
128
             /* direct signals sign is +1 for qs = 1,3,4,5,...,complexHybBands */
129
-            pHybOutRealDry[1] -= fMultDiv2(pWImag[1], pKernel[1])
130
-                                 << (scale_param_m2);
131
-            pHybOutImagDry[1] += fMultDiv2(pWReal[1], pKernel[1])
132
-                                 << (scale_param_m2);
133
+            pHybOutRealDry[1] -= SAC_DEC_APPLY_M2_SCALE(
134
+                fMultDiv2(pWImag[1], pKernel[1]), scale_param_m2);
135
+            pHybOutImagDry[1] += SAC_DEC_APPLY_M2_SCALE(
136
+                fMultDiv2(pWReal[1], pKernel[1]), scale_param_m2);
137
 
138
             for (qs = 3; qs < complexHybBands; qs++) {
139
-              pHybOutRealDry[qs] -= fMultDiv2(pWImag[qs], pKernel[qs])
140
-                                    << (scale_param_m2);
141
-              pHybOutImagDry[qs] += fMultDiv2(pWReal[qs], pKernel[qs])
142
-                                    << (scale_param_m2);
143
+              pHybOutRealDry[qs] -= SAC_DEC_APPLY_M2_SCALE(
144
+                  fMultDiv2(pWImag[qs], pKernel[qs]), scale_param_m2);
145
+              pHybOutImagDry[qs] += SAC_DEC_APPLY_M2_SCALE(
146
+                  fMultDiv2(pWReal[qs], pKernel[qs]), scale_param_m2);
147
             }
148
           } /* self->upmixType */
149
         }   /* if (activParamBands) */
150
@@ -770,17 +776,17 @@
151
             FIXP_DBL *RESTRICT pHybOutImag;
152
 
153
             for (qs = 0; qs < resHybIndex; qs++) {
154
-              pHybOutRealDry[qs] += fMultDiv2(pWReal[qs], pKernel[qs])
155
-                                    << (scale_param_m2);
156
-              pHybOutImagDry[qs] += fMultDiv2(pWImag[qs], pKernel[qs])
157
-                                    << (scale_param_m2);
158
+              pHybOutRealDry[qs] += SAC_DEC_APPLY_M2_SCALE(
159
+                  fMultDiv2(pWReal[qs], pKernel[qs]), scale_param_m2);
160
+              pHybOutImagDry[qs] += SAC_DEC_APPLY_M2_SCALE(
161
+                  fMultDiv2(pWImag[qs], pKernel[qs]), scale_param_m2);
162
             }
163
             /* decor signals */
164
             for (; qs < complexHybBands; qs++) {
165
-              pHybOutRealWet[qs] += fMultDiv2(pWReal[qs], pKernel[qs])
166
-                                    << (scale_param_m2);
167
-              pHybOutImagWet[qs] += fMultDiv2(pWImag[qs], pKernel[qs])
168
-                                    << (scale_param_m2);
169
+              pHybOutRealWet[qs] += SAC_DEC_APPLY_M2_SCALE(
170
+                  fMultDiv2(pWReal[qs], pKernel[qs]), scale_param_m2);
171
+              pHybOutImagWet[qs] += SAC_DEC_APPLY_M2_SCALE(
172
+                  fMultDiv2(pWImag[qs], pKernel[qs]), scale_param_m2);
173
             }
174
 
175
             M2ParamToKernelMult(pKernel, self->M2Imag__FDK[row][col],
176
@@ -790,20 +796,20 @@
177
             /* direct signals sign is -1 for qs = 0,2 */
178
             /* direct signals sign is +1 for qs = 1,3.. */
179
             if (toolsDisabled) {
180
-              pHybOutRealDry[0] += fMultDiv2(pWImag[0], pKernel[0])
181
-                                   << (scale_param_m2);
182
-              pHybOutImagDry[0] -= fMultDiv2(pWReal[0], pKernel[0])
183
-                                   << (scale_param_m2);
184
-
185
-              pHybOutRealDry[1] -= fMultDiv2(pWImag[1], pKernel[1])
186
-                                   << (scale_param_m2);
187
-              pHybOutImagDry[1] += fMultDiv2(pWReal[1], pKernel[1])
188
-                                   << (scale_param_m2);
189
-
190
-              pHybOutRealDry[2] += fMultDiv2(pWImag[2], pKernel[2])
191
-                                   << (scale_param_m2);
192
-              pHybOutImagDry[2] -= fMultDiv2(pWReal[2], pKernel[2])
193
-                                   << (scale_param_m2);
194
+              pHybOutRealDry[0] += SAC_DEC_APPLY_M2_SCALE(
195
+                  fMultDiv2(pWImag[0], pKernel[0]), scale_param_m2);
196
+              pHybOutImagDry[0] -= SAC_DEC_APPLY_M2_SCALE(
197
+                  fMultDiv2(pWReal[0], pKernel[0]), scale_param_m2);
198
+
199
+              pHybOutRealDry[1] -= SAC_DEC_APPLY_M2_SCALE(
200
+                  fMultDiv2(pWImag[1], pKernel[1]), scale_param_m2);
201
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_qmf.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_qmf.cpp Changed
19
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -110,7 +110,7 @@
11
 
12
 SACDEC_ERROR CalculateSpaceSynthesisQmf(
13
     const HANDLE_FDK_QMF_DOMAIN_OUT hQmfDomainOutCh, const FIXP_DBL *Sr,
14
-    const FIXP_DBL *Si, const INT stride, INT_PCM *timeSig) {
15
+    const FIXP_DBL *Si, const INT stride, PCM_MPS *timeSig) {
16
   SACDEC_ERROR err = MPS_OK;
17
 
18
   if (hQmfDomainOutCh == NULL) {
19
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_qmf.h -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_qmf.h Changed
19
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -124,7 +124,7 @@
11
  */
12
 SACDEC_ERROR CalculateSpaceSynthesisQmf(
13
     const HANDLE_FDK_QMF_DOMAIN_OUT hQmfDomainOutCh, const FIXP_DBL *Sr,
14
-    const FIXP_DBL *Si, const INT stride, INT_PCM *timeSig);
15
+    const FIXP_DBL *Si, const INT stride, PCM_MPS *timeSig);
16
 
17
 /**
18
  * \brief  Convert audio input data to qmf representation.
19
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_reshapeBBEnv.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_reshapeBBEnv.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -162,75 +162,59 @@
11
   FIXP_DBL nrg;
12
 
13
   /* qs = 12, 13, 14 */
14
-  slotNrg[0] = ((fPow2Div2((*pReal++) << maxValSF) +
15
-                 fPow2Div2((*pImag++) << maxValSF)) >>
16
-                (SF_FACTOR_SLOT - 1));
17
-  slotNrg[1] = ((fPow2Div2((*pReal++) << maxValSF) +
18
-                 fPow2Div2((*pImag++) << maxValSF)) >>
19
-                (SF_FACTOR_SLOT - 1));
20
-  slotNrg[2] = ((fPow2Div2((*pReal++) << maxValSF) +
21
-                 fPow2Div2((*pImag++) << maxValSF)) >>
22
-                (SF_FACTOR_SLOT - 1));
23
+  slotNrg[0] = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
24
+                (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
25
+  slotNrg[1] = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
26
+                (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
27
+  slotNrg[2] = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
28
+                (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
29
   /* qs = 15 */
30
-  slotNrg[3] = ((fPow2Div2((*pReal++) << maxValSF) +
31
-                 fPow2Div2((*pImag++) << maxValSF)) >>
32
-                (SF_FACTOR_SLOT - 1));
33
+  slotNrg[3] = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
34
+                (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
35
   /* qs = 16, 17 */
36
-  nrg = ((fPow2Div2((*pReal++) << maxValSF) +
37
-          fPow2Div2((*pImag++) << maxValSF)) >>
38
-         (SF_FACTOR_SLOT - 1));
39
-  slotNrg[4] = nrg + ((fPow2Div2((*pReal++) << maxValSF) +
40
-                       fPow2Div2((*pImag++) << maxValSF)) >>
41
-                      (SF_FACTOR_SLOT - 1));
42
+  nrg = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
43
+         (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
44
+  slotNrg[4] =
45
+      nrg + ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
46
+             (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
47
   /* qs = 18, 19, 20 */
48
-  nrg = ((fPow2Div2((*pReal++) << maxValSF) +
49
-          fPow2Div2((*pImag++) << maxValSF)) >>
50
-         (SF_FACTOR_SLOT - 1));
51
-  nrg += ((fPow2Div2((*pReal++) << maxValSF) +
52
-           fPow2Div2((*pImag++) << maxValSF)) >>
53
-          (SF_FACTOR_SLOT - 1));
54
-  slotNrg[5] = nrg + ((fPow2Div2((*pReal++) << maxValSF) +
55
-                       fPow2Div2((*pImag++) << maxValSF)) >>
56
-                      (SF_FACTOR_SLOT - 1));
57
+  nrg = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
58
+         (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
59
+  nrg += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
60
+          (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
61
+  slotNrg[5] =
62
+      nrg + ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
63
+             (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
64
   /* qs = 21, 22 */
65
-  nrg = ((fPow2Div2((*pReal++) << maxValSF) +
66
-          fPow2Div2((*pImag++) << maxValSF)) >>
67
-         (SF_FACTOR_SLOT - 1));
68
-  slotNrg[6] = nrg + ((fPow2Div2((*pReal++) << maxValSF) +
69
-                       fPow2Div2((*pImag++) << maxValSF)) >>
70
-                      (SF_FACTOR_SLOT - 1));
71
+  nrg = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
72
+         (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
73
+  slotNrg[6] =
74
+      nrg + ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
75
+             (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
76
   /* qs = 23, 24 */
77
   if (hybBands > 23) {
78
-    slotNrg[6] += ((fPow2Div2((*pReal++) << maxValSF) +
79
-                    fPow2Div2((*pImag++) << maxValSF)) >>
80
-                   (SF_FACTOR_SLOT - 1));
81
-    slotNrg[6] += ((fPow2Div2((*pReal++) << maxValSF) +
82
-                    fPow2Div2((*pImag++) << maxValSF)) >>
83
-                   (SF_FACTOR_SLOT - 1));
84
+    slotNrg[6] += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
85
+                   (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
86
+    slotNrg[6] += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
87
+                   (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
88
     /* qs = 25, 26, 29, 28, 29 */
89
-    nrg = ((fPow2Div2((*pReal++) << maxValSF) +
90
-            fPow2Div2((*pImag++) << maxValSF)) >>
91
-           (SF_FACTOR_SLOT - 1));
92
-    nrg += ((fPow2Div2((*pReal++) << maxValSF) +
93
-             fPow2Div2((*pImag++) << maxValSF)) >>
94
-            (SF_FACTOR_SLOT - 1));
95
-    nrg += ((fPow2Div2((*pReal++) << maxValSF) +
96
-             fPow2Div2((*pImag++) << maxValSF)) >>
97
-            (SF_FACTOR_SLOT - 1));
98
-    nrg += ((fPow2Div2((*pReal++) << maxValSF) +
99
-             fPow2Div2((*pImag++) << maxValSF)) >>
100
-            (SF_FACTOR_SLOT - 1));
101
-    slotNrg[7] = nrg + ((fPow2Div2((*pReal++) << maxValSF) +
102
-                         fPow2Div2((*pImag++) << maxValSF)) >>
103
-                        (SF_FACTOR_SLOT - 1));
104
+    nrg = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
105
+           (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
106
+    nrg += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
107
+            (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
108
+    nrg += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
109
+            (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
110
+    nrg += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
111
+            (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
112
+    slotNrg[7] =
113
+        nrg + ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
114
+               (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
115
     /* qs = 30 ... min(41,hybBands-1) */
116
-    nrg = ((fPow2Div2((*pReal++) << maxValSF) +
117
-            fPow2Div2((*pImag++) << maxValSF)) >>
118
-           (SF_FACTOR_SLOT - 1));
119
+    nrg = ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
120
+           (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
121
     for (qs = 31; qs < hybBands; qs++) {
122
-      nrg += ((fPow2Div2((*pReal++) << maxValSF) +
123
-               fPow2Div2((*pImag++) << maxValSF)) >>
124
-              (SF_FACTOR_SLOT - 1));
125
+      nrg += ((fPow2Div2((*pReal++) << maxValSF) >> (SF_FACTOR_SLOT - 1)) +
126
+              (fPow2Div2((*pImag++) << maxValSF) >> (SF_FACTOR_SLOT - 1)));
127
     }
128
     slotNrg[8] = nrg;
129
   } else {
130
@@ -239,49 +223,22 @@
131
   }
132
 }
133
 
134
-static inline INT getMaxValDmx(FIXP_DBL *RESTRICT pReal,
135
-                               FIXP_DBL *RESTRICT pImag, INT cplxBands,
136
-                               INT hybBands) {
137
-  INT qs, clz;
138
-  FIXP_DBL maxVal = FL2FXCONST_DBL(0.0f);
139
-
140
-  for (qs = 12; qs < cplxBands; qs++) {
141
-    maxVal |= fAbs(pReal[qs]);
142
-    maxVal |= fAbs(pImag[qs]);
143
-  }
144
-  for (; qs < hybBands; qs++) {
145
-    maxVal |= fAbs(pReal[qs]);
146
-  }
147
-
148
-  clz = fixMax(0, CntLeadingZeros(maxVal) - 1);
149
-
150
-  return (clz);
151
-}
152
-
153
-static inline INT getMaxValDryWet(FIXP_DBL *RESTRICT pReal,
154
-                                  FIXP_DBL *RESTRICT pImag,
155
-                                  FIXP_DBL *RESTRICT pHybOutputRealDry,
156
-                                  FIXP_DBL *RESTRICT pHybOutputImagDry,
157
-                                  FIXP_DBL *RESTRICT pHybOutputRealWet,
158
-                                  FIXP_DBL *RESTRICT pHybOutputImagWet,
159
-                                  INT cplxBands, INT hybBands) {
160
-  INT qs, clz;
161
-  FIXP_DBL maxVal = FL2FXCONST_DBL(0.0f);
162
+static inline void combineDryWet(FIXP_DBL *RESTRICT pReal,
163
+                                 FIXP_DBL *RESTRICT pImag,
164
+                                 FIXP_DBL *RESTRICT pHybOutputRealDry,
165
+                                 FIXP_DBL *RESTRICT pHybOutputImagDry,
166
+                                 FIXP_DBL *RESTRICT pHybOutputRealWet,
167
+                                 FIXP_DBL *RESTRICT pHybOutputImagWet,
168
+                                 INT cplxBands, INT hybBands) {
169
+  INT qs;
170
 
171
   for (qs = 12; qs < cplxBands; qs++) {
172
-    pReal[qs] = pHybOutputRealDry[qs] + pHybOutputRealWet[qs];
173
-    maxVal |= fAbs(pReal[qs]);
174
-    pImag[qs] = pHybOutputImagDry[qs] + pHybOutputImagWet[qs];
175
-    maxVal |= fAbs(pImag[qs]);
176
+    pReal[qs] = (pHybOutputRealDry[qs] >> 1) + (pHybOutputRealWet[qs] >> 1);
177
+    pImag[qs] = (pHybOutputImagDry[qs] >> 1) + (pHybOutputImagWet[qs] >> 1);
178
   }
179
   for (; qs < hybBands; qs++) {
180
-    pReal[qs] = pHybOutputRealDry[qs] + pHybOutputRealWet[qs];
181
-    maxVal |= fAbs(pReal[qs]);
182
+    pReal[qs] = (pHybOutputRealDry[qs] >> 1) + (pHybOutputRealWet[qs] >> 1);
183
   }
184
-
185
-  clz = fixMax(0, CntLeadingZeros(maxVal) - 1);
186
-
187
-  return (clz);
188
 }
189
 
190
 static inline void slotAmp(FIXP_DBL *RESTRICT slotAmp_dry,
191
@@ -296,17 +253,17 @@
192
 
193
   dry = wet = FL2FXCONST_DBL(0.0f);
194
   for (qs = 0; qs < cplxBands; qs++) {
195
-    dry = fAddSaturate(dry, fPow2Div2(pHybOutputRealDry[qs]) +
196
-                                fPow2Div2(pHybOutputImagDry[qs]));
197
-    wet = fAddSaturate(wet, fPow2Div2(pHybOutputRealWet[qs]) +
198
-                                fPow2Div2(pHybOutputImagWet[qs]));
199
+    dry = fAddSaturate(dry, fPow2Div2(pHybOutputRealDry[qs] << (1)) +
200
+                                fPow2Div2(pHybOutputImagDry[qs] << (1)));
201
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_rom.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_rom.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -163,7 +163,7 @@
11
     SCALE_IPD(4.71238898038469f), SCALE_IPD(5.105088062f),
12
     SCALE_IPD(5.49778714378214f), SCALE_IPD(5.890486225f)};
13
 
14
-#define SCALE_SPLIT_ANGLE(a) (FL2FXCONST_CFG(a / (float)(1 << IPD_SCALE)))
15
+#define SCALE_SPLIT_ANGLE(a) (FL2FXCONST_DBL(a / (float)(1 << IPD_SCALE)))
16
 /*
17
   Generate table dequantIPD_CLD_ICC_splitAngle__FDK[16][31][8]:
18
 
19
@@ -200,6 +200,3758 @@
20
   atan2(w2 * sinIpd, w1 * iidLin + w2 * cosIpd);
21
       }
22
 */
23
+const FIXP_DBL dequantIPD_CLD_ICC_splitAngle__FDK[15][31][8] = {
24
+    {
25
+        {SCALE_SPLIT_ANGLE(0.39269909262657),
26
+         SCALE_SPLIT_ANGLE(0.39269909262657),
27
+         SCALE_SPLIT_ANGLE(0.39269909262657),
28
+         SCALE_SPLIT_ANGLE(0.39269909262657),
29
+         SCALE_SPLIT_ANGLE(0.39269909262657),
30
+         SCALE_SPLIT_ANGLE(0.39269909262657),
31
+         SCALE_SPLIT_ANGLE(0.39269909262657),
32
+         SCALE_SPLIT_ANGLE(0.39269909262657)},
33
+        {SCALE_SPLIT_ANGLE(0.39055734872818),
34
+         SCALE_SPLIT_ANGLE(0.39055740833282),
35
+         SCALE_SPLIT_ANGLE(0.39055749773979),
36
+         SCALE_SPLIT_ANGLE(0.39055770635605),
37
+         SCALE_SPLIT_ANGLE(0.39055791497231),
38
+         SCALE_SPLIT_ANGLE(0.39055824279785),
39
+         SCALE_SPLIT_ANGLE(0.39055877923965),
40
+         SCALE_SPLIT_ANGLE(0.39055916666985)},
41
+        {SCALE_SPLIT_ANGLE(0.38890451192856),
42
+         SCALE_SPLIT_ANGLE(0.38890469074249),
43
+         SCALE_SPLIT_ANGLE(0.38890495896339),
44
+         SCALE_SPLIT_ANGLE(0.38890564441681),
45
+         SCALE_SPLIT_ANGLE(0.38890630006790),
46
+         SCALE_SPLIT_ANGLE(0.38890734314919),
47
+         SCALE_SPLIT_ANGLE(0.38890904188156),
48
+         SCALE_SPLIT_ANGLE(0.38891020417213)},
49
+        {SCALE_SPLIT_ANGLE(0.38599541783333),
50
+         SCALE_SPLIT_ANGLE(0.38599592447281),
51
+         SCALE_SPLIT_ANGLE(0.38599672913551),
52
+         SCALE_SPLIT_ANGLE(0.38599878549576),
53
+         SCALE_SPLIT_ANGLE(0.38600078225136),
54
+         SCALE_SPLIT_ANGLE(0.38600403070450),
55
+         SCALE_SPLIT_ANGLE(0.38600939512253),
56
+         SCALE_SPLIT_ANGLE(0.38601315021515)},
57
+        {SCALE_SPLIT_ANGLE(0.38091576099396),
58
+         SCALE_SPLIT_ANGLE(0.38091731071472),
59
+         SCALE_SPLIT_ANGLE(0.38091966509819),
60
+         SCALE_SPLIT_ANGLE(0.38092571496964),
61
+         SCALE_SPLIT_ANGLE(0.38093179464340),
62
+         SCALE_SPLIT_ANGLE(0.38094165921211),
63
+         SCALE_SPLIT_ANGLE(0.38095843791962),
64
+         SCALE_SPLIT_ANGLE(0.38097056746483)},
65
+        {SCALE_SPLIT_ANGLE(0.37216997146606),
66
+         SCALE_SPLIT_ANGLE(0.37217426300049),
67
+         SCALE_SPLIT_ANGLE(0.37218090891838),
68
+         SCALE_SPLIT_ANGLE(0.37219807505608),
69
+         SCALE_SPLIT_ANGLE(0.37221556901932),
70
+         SCALE_SPLIT_ANGLE(0.37224492430687),
71
+         SCALE_SPLIT_ANGLE(0.37229704856873),
72
+         SCALE_SPLIT_ANGLE(0.37233674526215)},
73
+        {SCALE_SPLIT_ANGLE(0.36424967646599),
74
+         SCALE_SPLIT_ANGLE(0.36425727605820),
75
+         SCALE_SPLIT_ANGLE(0.36426907777786),
76
+         SCALE_SPLIT_ANGLE(0.36430004239082),
77
+         SCALE_SPLIT_ANGLE(0.36433213949203),
78
+         SCALE_SPLIT_ANGLE(0.36438730359077),
79
+         SCALE_SPLIT_ANGLE(0.36448970437050),
80
+         SCALE_SPLIT_ANGLE(0.36457163095474)},
81
+        {SCALE_SPLIT_ANGLE(0.35356888175011),
82
+         SCALE_SPLIT_ANGLE(0.35358175635338),
83
+         SCALE_SPLIT_ANGLE(0.35360190272331),
84
+         SCALE_SPLIT_ANGLE(0.35365560650826),
85
+         SCALE_SPLIT_ANGLE(0.35371258854866),
86
+         SCALE_SPLIT_ANGLE(0.35381385684013),
87
+         SCALE_SPLIT_ANGLE(0.35401365160942),
88
+         SCALE_SPLIT_ANGLE(0.35418578982353)},
89
+        {SCALE_SPLIT_ANGLE(0.33942583203316),
90
+         SCALE_SPLIT_ANGLE(0.33944645524025),
91
+         SCALE_SPLIT_ANGLE(0.33947896957397),
92
+         SCALE_SPLIT_ANGLE(0.33956742286682),
93
+         SCALE_SPLIT_ANGLE(0.33966416120529),
94
+         SCALE_SPLIT_ANGLE(0.33984372019768),
95
+         SCALE_SPLIT_ANGLE(0.34023007750511),
96
+         SCALE_SPLIT_ANGLE(0.34060221910477)},
97
+        {SCALE_SPLIT_ANGLE(0.32115450501442),
98
+         SCALE_SPLIT_ANGLE(0.32118520140648),
99
+         SCALE_SPLIT_ANGLE(0.32123416662216),
100
+         SCALE_SPLIT_ANGLE(0.32137048244476),
101
+         SCALE_SPLIT_ANGLE(0.32152509689331),
102
+         SCALE_SPLIT_ANGLE(0.32182863354683),
103
+         SCALE_SPLIT_ANGLE(0.32256561517715),
104
+         SCALE_SPLIT_ANGLE(0.32340893149376)},
105
+        {SCALE_SPLIT_ANGLE(0.29830521345139),
106
+         SCALE_SPLIT_ANGLE(0.29834723472595),
107
+         SCALE_SPLIT_ANGLE(0.29841500520706),
108
+         SCALE_SPLIT_ANGLE(0.29860860109329),
109
+         SCALE_SPLIT_ANGLE(0.29883742332458),
110
+         SCALE_SPLIT_ANGLE(0.29931786656380),
111
+         SCALE_SPLIT_ANGLE(0.30069106817245),
112
+         SCALE_SPLIT_ANGLE(0.30275771021843)},
113
+        {SCALE_SPLIT_ANGLE(0.28050789237022),
114
+         SCALE_SPLIT_ANGLE(0.28055712580681),
115
+         SCALE_SPLIT_ANGLE(0.28063708543777),
116
+         SCALE_SPLIT_ANGLE(0.28086942434311),
117
+         SCALE_SPLIT_ANGLE(0.28115189075470),
118
+         SCALE_SPLIT_ANGLE(0.28177404403687),
119
+         SCALE_SPLIT_ANGLE(0.28380545973778),
120
+         SCALE_SPLIT_ANGLE(0.28782638907433)},
121
+        {SCALE_SPLIT_ANGLE(0.26083287596703),
122
+         SCALE_SPLIT_ANGLE(0.26088824868202),
123
+         SCALE_SPLIT_ANGLE(0.26097872853279),
124
+         SCALE_SPLIT_ANGLE(0.26124578714371),
125
+         SCALE_SPLIT_ANGLE(0.26157897710800),
126
+         SCALE_SPLIT_ANGLE(0.26234793663025),
127
+         SCALE_SPLIT_ANGLE(0.26525345444679),
128
+         SCALE_SPLIT_ANGLE(0.27373576164246)},
129
+        {SCALE_SPLIT_ANGLE(0.23960022628307),
130
+         SCALE_SPLIT_ANGLE(0.23966011404991),
131
+         SCALE_SPLIT_ANGLE(0.23975846171379),
132
+         SCALE_SPLIT_ANGLE(0.24005253612995),
133
+         SCALE_SPLIT_ANGLE(0.24042735993862),
134
+         SCALE_SPLIT_ANGLE(0.24132782220840),
135
+         SCALE_SPLIT_ANGLE(0.24525125324726),
136
+         SCALE_SPLIT_ANGLE(0.26534587144852)},
137
+        {SCALE_SPLIT_ANGLE(0.21727463603020),
138
+         SCALE_SPLIT_ANGLE(0.21733720600605),
139
+         SCALE_SPLIT_ANGLE(0.21744030714035),
140
+         SCALE_SPLIT_ANGLE(0.21775111556053),
141
+         SCALE_SPLIT_ANGLE(0.21815299987793),
142
+         SCALE_SPLIT_ANGLE(0.21914559602737),
143
+         SCALE_SPLIT_ANGLE(0.22397418320179),
144
+         SCALE_SPLIT_ANGLE(0.27997341752052)},
145
+        {SCALE_SPLIT_ANGLE(0.19442924857140),
146
+         SCALE_SPLIT_ANGLE(0.19449260830879),
147
+         SCALE_SPLIT_ANGLE(0.19459712505341),
148
+         SCALE_SPLIT_ANGLE(0.19491320848465),
149
+         SCALE_SPLIT_ANGLE(0.19532410800457),
150
+         SCALE_SPLIT_ANGLE(0.19634956121445),
151
+         SCALE_SPLIT_ANGLE(0.20156545937061),
152
+         SCALE_SPLIT_ANGLE(0.33650875091553)},
153
+        {SCALE_SPLIT_ANGLE(0.17168679833412),
154
+         SCALE_SPLIT_ANGLE(0.17174908518791),
155
+         SCALE_SPLIT_ANGLE(0.17185173928738),
156
+         SCALE_SPLIT_ANGLE(0.17216140031815),
157
+         SCALE_SPLIT_ANGLE(0.17256212234497),
158
+         SCALE_SPLIT_ANGLE(0.17355351150036),
159
+         SCALE_SPLIT_ANGLE(0.17841057479382),
160
+         SCALE_SPLIT_ANGLE(0.23922468721867)},
161
+        {SCALE_SPLIT_ANGLE(0.14965108036995),
162
+         SCALE_SPLIT_ANGLE(0.14971046149731),
163
+         SCALE_SPLIT_ANGLE(0.14980803430080),
164
+         SCALE_SPLIT_ANGLE(0.15010002255440),
165
+         SCALE_SPLIT_ANGLE(0.15047283470631),
166
+         SCALE_SPLIT_ANGLE(0.15137128531933),
167
+         SCALE_SPLIT_ANGLE(0.15533345937729),
168
+         SCALE_SPLIT_ANGLE(0.17691856622696)},
169
+        {SCALE_SPLIT_ANGLE(0.12884500622749),
170
+         SCALE_SPLIT_ANGLE(0.12889973819256),
171
+         SCALE_SPLIT_ANGLE(0.12898921966553),
172
+         SCALE_SPLIT_ANGLE(0.12925371527672),
173
+         SCALE_SPLIT_ANGLE(0.12958450615406),
174
+         SCALE_SPLIT_ANGLE(0.13035117089748),
175
+         SCALE_SPLIT_ANGLE(0.13329000771046),
176
+         SCALE_SPLIT_ANGLE(0.14226883649826)},
177
+        {SCALE_SPLIT_ANGLE(0.10966771841049),
178
+         SCALE_SPLIT_ANGLE(0.10971628874540),
179
+         SCALE_SPLIT_ANGLE(0.10979522019625),
180
+         SCALE_SPLIT_ANGLE(0.11002497375011),
181
+         SCALE_SPLIT_ANGLE(0.11030506342649),
182
+         SCALE_SPLIT_ANGLE(0.11092507839203),
183
+         SCALE_SPLIT_ANGLE(0.11297956109047),
184
+         SCALE_SPLIT_ANGLE(0.11718676239252)},
185
+        {SCALE_SPLIT_ANGLE(0.09237616509199),
186
+         SCALE_SPLIT_ANGLE(0.09241759032011),
187
+         SCALE_SPLIT_ANGLE(0.09248441457748),
188
+         SCALE_SPLIT_ANGLE(0.09267570823431),
189
+         SCALE_SPLIT_ANGLE(0.09290253371000),
190
+         SCALE_SPLIT_ANGLE(0.09338124841452),
191
+         SCALE_SPLIT_ANGLE(0.09476862102747),
192
+         SCALE_SPLIT_ANGLE(0.09691140055656)},
193
+        {SCALE_SPLIT_ANGLE(0.07020132243633),
194
+         SCALE_SPLIT_ANGLE(0.07023159414530),
195
+         SCALE_SPLIT_ANGLE(0.07027988880873),
196
+         SCALE_SPLIT_ANGLE(0.07041462510824),
197
+         SCALE_SPLIT_ANGLE(0.07056795060635),
198
+         SCALE_SPLIT_ANGLE(0.07087047398090),
199
+         SCALE_SPLIT_ANGLE(0.07161350548267),
200
+         SCALE_SPLIT_ANGLE(0.07247893512249)},
201
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_rom.h -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_rom.h Changed
63
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -111,21 +111,12 @@
11
 #include "machine_type.h"
12
 
13
 /* Global ROM table data type: */
14
-#ifndef ARCH_PREFER_MULT_32x32
15
-#define FIXP_CFG FIXP_SGL
16
-#define FX_CFG2FX_DBL FX_SGL2FX_DBL
17
-#define FX_CFG2FX_SGL
18
-#define CFG(a) (FX_DBL2FXCONST_SGL(a))
19
-#define FL2FXCONST_CFG FL2FXCONST_SGL
20
-#define FX_DBL2FX_CFG(x) FX_DBL2FX_SGL((FIXP_DBL)(x))
21
-#else
22
 #define FIXP_CFG FIXP_DBL
23
 #define FX_CFG2FX_DBL
24
 #define FX_CFG2FX_SGL FX_DBL2FX_SGL
25
 #define CFG(a) FIXP_DBL(a)
26
 #define FL2FXCONST_CFG FL2FXCONST_DBL
27
 #define FX_DBL2FX_CFG(x) ((FIXP_DBL)(x))
28
-#endif
29
 
30
 /* others  */
31
 #define SCALE_INV_ICC (2)
32
@@ -133,21 +124,15 @@
33
 
34
 #define QCC_SCALE 1
35
 #define M1M2_DATA FIXP_DBL
36
-#ifndef ARCH_PREFER_MULT_32x32
37
-#define M1M2_CDATA FIXP_SGL
38
-#define M1M2_CDATA2FX_DBL(a) FX_SGL2FX_DBL(a)
39
-#define FX_DBL2M1M2_CDATA(a) FX_DBL2FX_SGL(a)
40
-#else
41
 #define M1M2_CDATA FIXP_DBL
42
 #define M1M2_CDATA2FX_DBL(a) (a)
43
 #define FX_DBL2M1M2_CDATA(a) (a)
44
-#endif
45
 
46
 #define CLIP_PROTECT_GAIN_0(x) FL2FXCONST_CFG(((x) / (float)(1 << 0)))
47
 #define CLIP_PROTECT_GAIN_1(x) FL2FXCONST_CFG(((x) / (float)(1 << 1)))
48
 #define CLIP_PROTECT_GAIN_2(x) FL2FXCONST_CFG(((x) / (float)(1 << 2)))
49
 
50
-#define SF_CLD_C1C2 (8)
51
+#define SF_CLD_C1C2 (9)
52
 
53
 extern const FIXP_CFG dequantCPC__FDK[];
54
 extern const FIXP_CFG dequantICC__FDK[8];
55
@@ -160,6 +145,7 @@
56
   (FL2FXCONST_DBL(3.1415926535897932f / (float)(1 << (IPD_SCALE - 1))))
57
 
58
 extern const FIXP_CFG dequantIPD__FDK[16];
59
+extern const FIXP_DBL dequantIPD_CLD_ICC_splitAngle__FDK[15][31][8];
60
 
61
 extern const FIXP_CFG H11_nc[31][8];
62
 extern const FIXP_CFG H12_nc[31][8];
63
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_stp.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_stp.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -106,6 +106,8 @@
11
 #include "FDK_matrixCalloc.h"
12
 #include "sac_rom.h"
13
 
14
+#define SF_FREQ_DOMAIN_HEADROOM (2 * (1))
15
+
16
 #define BP_GF_START 6
17
 #define BP_GF_SIZE 25
18
 #define HP_SIZE 9
19
@@ -114,6 +116,16 @@
20
 #define SF_WET 5
21
 #define SF_DRY \
22
   3 /* SF_DRY == 2 would produce good conformance test results as well */
23
+#define SF_DRY_NRG                                                           \
24
+  (4 - 1) /* 8.495f = sum(BP_GF__FDK[i])                                     \
25
+             i=0,..,(sizeof(BP_GF__FDK)/sizeof(FIXP_CFG)-1) => energy        \
26
+             calculation needs 4 bits headroom, headroom can be reduced by 1 \
27
+             bit due to fPow2Div2() usage */
28
+#define SF_WET_NRG                                                           \
29
+  (4 - 1) /* 8.495f = sum(BP_GF__FDK[i])                                     \
30
+             i=0,..,(sizeof(BP_GF__FDK)/sizeof(FIXP_CFG)-1) => energy        \
31
+             calculation needs 4 bits headroom, headroom can be reduced by 1 \
32
+             bit due to fPow2Div2() usage */
33
 #define SF_PRODUCT_BP_GF 13
34
 #define SF_PRODUCT_BP_GF_GF 26
35
 #define SF_SCALE 2
36
@@ -172,18 +184,6 @@
37
        STP_SCALE_LIMIT_LO_LD64 = LD64(STP_SCALE_LIMIT_LO*STP_SCALE_LIMIT_LO)
38
 */
39
 
40
-#define DRY_ENER_WEIGHT(DryEner) DryEner = DryEner >> dry_scale_dmx
41
-
42
-#define WET_ENER_WEIGHT(WetEner) WetEner = WetEner << wet_scale_dmx
43
-
44
-#define DRY_ENER_SUM_REAL(DryEner, dmxReal, n) \
45
-  DryEner +=                                   \
46
-      fMultDiv2(fPow2Div2(dmxReal << SF_DRY), pBP[n]) >> ((2 * SF_DRY) - 2)
47
-
48
-#define DRY_ENER_SUM_CPLX(DryEner, dmxReal, dmxImag, n) \
49
-  DryEner += fMultDiv2(                                 \
50
-      fPow2Div2(dmxReal << SF_DRY) + fPow2Div2(dmxImag << SF_DRY), pBP[n])
51
-
52
 #define CALC_WET_SCALE(dryIdx, wetIdx)                                         \
53
   if ((DryEnerLD64[dryIdx] - STP_SCALE_LIMIT_HI_LD64) > WetEnerLD64[wetIdx]) { \
54
     scale[wetIdx] = STP_SCALE_LIMIT_HI;                                        \
55
@@ -206,29 +206,6 @@
56
   int update_old_ener;
57
 };
58
 
59
-inline void combineSignalReal(FIXP_DBL *hybOutputRealDry,
60
-                              FIXP_DBL *hybOutputRealWet, int bands) {
61
-  int n;
62
-
63
-  for (n = bands - 1; n >= 0; n--) {
64
-    *hybOutputRealDry = *hybOutputRealDry + *hybOutputRealWet;
65
-    hybOutputRealDry++, hybOutputRealWet++;
66
-  }
67
-}
68
-
69
-inline void combineSignalRealScale1(FIXP_DBL *hybOutputRealDry,
70
-                                    FIXP_DBL *hybOutputRealWet, FIXP_DBL scaleX,
71
-                                    int bands) {
72
-  int n;
73
-
74
-  for (n = bands - 1; n >= 0; n--) {
75
-    *hybOutputRealDry =
76
-        *hybOutputRealDry +
77
-        (fMultDiv2(*hybOutputRealWet, scaleX) << (SF_SCALE + 1));
78
-    hybOutputRealDry++, hybOutputRealWet++;
79
-  }
80
-}
81
-
82
 inline void combineSignalCplx(FIXP_DBL *hybOutputRealDry,
83
                               FIXP_DBL *hybOutputImagDry,
84
                               FIXP_DBL *hybOutputRealWet,
85
@@ -236,8 +213,8 @@
86
   int n;
87
 
88
   for (n = bands - 1; n >= 0; n--) {
89
-    *hybOutputRealDry = *hybOutputRealDry + *hybOutputRealWet;
90
-    *hybOutputImagDry = *hybOutputImagDry + *hybOutputImagWet;
91
+    *hybOutputRealDry = fAddSaturate(*hybOutputRealDry, *hybOutputRealWet);
92
+    *hybOutputImagDry = fAddSaturate(*hybOutputImagDry, *hybOutputImagWet);
93
     hybOutputRealDry++, hybOutputRealWet++;
94
     hybOutputImagDry++, hybOutputImagWet++;
95
   }
96
@@ -253,12 +230,14 @@
97
   FIXP_DBL scaleY;
98
   for (n = bands - 1; n >= 0; n--) {
99
     scaleY = fMultDiv2(scaleX, *pBP);
100
-    *hybOutputRealDry =
101
-        *hybOutputRealDry +
102
-        (fMultDiv2(*hybOutputRealWet, scaleY) << (SF_SCALE + 2));
103
-    *hybOutputImagDry =
104
-        *hybOutputImagDry +
105
-        (fMultDiv2(*hybOutputImagWet, scaleY) << (SF_SCALE + 2));
106
+    *hybOutputRealDry = SATURATE_LEFT_SHIFT(
107
+        (*hybOutputRealDry >> 1) +
108
+            (fMultDiv2(*hybOutputRealWet, scaleY) << (SF_SCALE + 1)),
109
+        1, DFRACT_BITS);
110
+    *hybOutputImagDry = SATURATE_LEFT_SHIFT(
111
+        (*hybOutputImagDry >> 1) +
112
+            (fMultDiv2(*hybOutputImagWet, scaleY) << (SF_SCALE + 1)),
113
+        1, DFRACT_BITS);
114
     hybOutputRealDry++, hybOutputRealWet++;
115
     hybOutputImagDry++, hybOutputImagWet++;
116
     pBP++;
117
@@ -305,12 +284,10 @@
118
 
119
   for (ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
120
     self->prev_tp_scale[ch] = FL2FXCONST_DBL(1.0f / (1 << SF_SCALE));
121
-    self->oldWetEnerLD64[ch] =
122
-        FL2FXCONST_DBL(0.34375f); /* 32768.0*32768.0/2^(44-26-10) */
123
+    self->oldWetEnerLD64[ch] = FL2FXCONST_DBL(0.0);
124
   }
125
   for (ch = 0; ch < MAX_INPUT_CHANNELS; ch++) {
126
-    self->oldDryEnerLD64[ch] =
127
-        FL2FXCONST_DBL(0.1875f); /* 32768.0*32768.0/2^(44-26) */
128
+    self->oldDryEnerLD64[ch] = FL2FXCONST_DBL(0.0);
129
   }
130
 
131
   self->BP = BP__FDK;
132
@@ -364,7 +341,12 @@
133
   {
134
     cplxBands = BP_GF_SIZE;
135
     cplxHybBands = self->hybridBands;
136
-    dry_scale_dmx = (2 * SF_DRY) - 2;
137
+    if (self->treeConfig == TREE_212) {
138
+      dry_scale_dmx = 2; /* 2 bits to compensate fMultDiv2() and fPow2Div2()
139
+                            used in energy calculation */
140
+    } else {
141
+      dry_scale_dmx = (2 * SF_DRY) - 2;
142
+    }
143
     wet_scale_dmx = 2;
144
   }
145
 
146
@@ -390,8 +372,12 @@
147
           CalcLdData(hStpDec->runDryEner[ch] + ABS_THR__FDK);
148
     }
149
     for (ch = 0; ch < self->numOutputChannels; ch++) {
150
-      hStpDec->oldWetEnerLD64[ch] =
151
-          CalcLdData(hStpDec->runWetEner[ch] + ABS_THR2__FDK);
152
+      if (self->treeConfig == TREE_212)
153
+        hStpDec->oldWetEnerLD64[ch] =
154
+            CalcLdData(hStpDec->runWetEner[ch] + ABS_THR__FDK);
155
+      else
156
+        hStpDec->oldWetEnerLD64[ch] =
157
+            CalcLdData(hStpDec->runWetEner[ch] + ABS_THR2__FDK);
158
     }
159
   } else {
160
     hStpDec->update_old_ener++;
161
@@ -411,12 +397,33 @@
162
   pBP = hStpDec->BP_GF - BP_GF_START;
163
   switch (self->treeConfig) {
164
     case TREE_212:
165
+      INT sMin, sNorm, sReal, sImag;
166
+
167
+      sReal = fMin(getScalefactor(&qmfOutputRealDry[i_LF][BP_GF_START],
168
+                                  cplxBands - BP_GF_START),
169
+                   getScalefactor(&qmfOutputRealDry[i_RF][BP_GF_START],
170
+                                  cplxBands - BP_GF_START));
171
+      sImag = fMin(getScalefactor(&qmfOutputImagDry[i_LF][BP_GF_START],
172
+                                  cplxBands - BP_GF_START),
173
+                   getScalefactor(&qmfOutputImagDry[i_RF][BP_GF_START],
174
+                                  cplxBands - BP_GF_START));
175
+      sMin = fMin(sReal, sImag) - 1;
176
+
177
       for (n = BP_GF_START; n < cplxBands; n++) {
178
-        dmxReal0 = qmfOutputRealDry[i_LF][n] + qmfOutputRealDry[i_RF][n];
179
-        dmxImag0 = qmfOutputImagDry[i_LF][n] + qmfOutputImagDry[i_RF][n];
180
-        DRY_ENER_SUM_CPLX(DryEner0, dmxReal0, dmxImag0, n);
181
+        dmxReal0 = scaleValue(qmfOutputRealDry[i_LF][n], sMin) +
182
+                   scaleValue(qmfOutputRealDry[i_RF][n], sMin);
183
+        dmxImag0 = scaleValue(qmfOutputImagDry[i_LF][n], sMin) +
184
+                   scaleValue(qmfOutputImagDry[i_RF][n], sMin);
185
+
186
+        DryEner0 += (fMultDiv2(fPow2Div2(dmxReal0), pBP[n]) +
187
+                     fMultDiv2(fPow2Div2(dmxImag0), pBP[n])) >>
188
+                    SF_DRY_NRG;
189
       }
190
-      DRY_ENER_WEIGHT(DryEner0);
191
+
192
+      sNorm = SF_FREQ_DOMAIN_HEADROOM + SF_DRY_NRG + dry_scale_dmx -
193
+              (2 * sMin) + nrgScale;
194
+      DryEner0 = scaleValueSaturate(
195
+          DryEner0, fMax(fMin(sNorm, DFRACT_BITS - 1), -(DFRACT_BITS - 1)));
196
       break;
197
     default:;
198
   }
199
@@ -424,7 +431,7 @@
200
 
201
fdk-aac-2.0.1.tar.gz/libSACdec/src/sac_tsd.cpp -> fdk-aac-2.0.2.tar.gz/libSACdec/src/sac_tsd.cpp Changed
56
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -123,12 +123,15 @@
11
 
12
 RAM_ALIGN
13
 LNK_SECTION_CONSTDATA
14
-static const FIXP_STP phiTsd[8] = {
15
-    STCP(0x7fffffff, 0x00000000), STCP(0x5a82799a, 0x5a82799a),
16
-    STCP(0x00000000, 0x7fffffff), STCP(0xa57d8666, 0x5a82799a),
17
-    STCP(0x80000000, 0x00000000), STCP(0xa57d8666, 0xa57d8666),
18
-    STCP(0x00000000, 0x80000000), STCP(0x5a82799a, 0xa57d8666),
19
-};
20
+static const FIXP_DPK phiTsd[8] = {
21
+    {{(FIXP_DBL)0x7fffffff, (FIXP_DBL)0x00000000}},
22
+    {{(FIXP_DBL)0x5a82799a, (FIXP_DBL)0x5a82799a}},
23
+    {{(FIXP_DBL)0x00000000, (FIXP_DBL)0x7fffffff}},
24
+    {{(FIXP_DBL)0xa57d8666, (FIXP_DBL)0x5a82799a}},
25
+    {{(FIXP_DBL)0x80000000, (FIXP_DBL)0x00000000}},
26
+    {{(FIXP_DBL)0xa57d8666, (FIXP_DBL)0xa57d8666}},
27
+    {{(FIXP_DBL)0x00000000, (FIXP_DBL)0x80000000}},
28
+    {{(FIXP_DBL)0x5a82799a, (FIXP_DBL)0xa57d8666}}};
29
 
30
 /*** Static Functions ***/
31
 static void longmult1(USHORT a[], USHORT b, USHORT d[], int len) {
32
@@ -333,16 +336,19 @@
33
 
34
   if (isTrSlot(pTsdData, ts)) {
35
     int k;
36
-    const FIXP_STP *phi = &phiTsd[pTsdData->bsTsdTrPhaseData[ts]];
37
+    const FIXP_DPK *phi = &phiTsd[pTsdData->bsTsdTrPhaseData[ts]];
38
     FDK_ASSERT((pTsdData->bsTsdTrPhaseData[ts] >= 0) &&
39
                (pTsdData->bsTsdTrPhaseData[ts] < 8));
40
 
41
     /* d = d_nonTr + v_direct * exp(j * bsTsdTrPhaseData[ts]/4 * pi ) */
42
     for (k = TSD_START_BAND; k < numHybridBands; k++) {
43
       FIXP_DBL tempReal, tempImag;
44
-      cplxMult(&tempReal, &tempImag, pVdirectReal[k], pVdirectImag[k], *phi);
45
-      pDnonTrReal[k] += tempReal;
46
-      pDnonTrImag[k] += tempImag;
47
+      cplxMultDiv2(&tempReal, &tempImag, pVdirectReal[k], pVdirectImag[k],
48
+                   *phi);
49
+      pDnonTrReal[k] = SATURATE_LEFT_SHIFT(
50
+          (pDnonTrReal[k] >> 2) + (tempReal >> 1), 2, DFRACT_BITS);
51
+      pDnonTrImag[k] = SATURATE_LEFT_SHIFT(
52
+          (pDnonTrImag[k] >> 2) + (tempImag >> 1), 2, DFRACT_BITS);
53
     }
54
   }
55
 
56
fdk-aac-2.0.1.tar.gz/libSACenc/src/sacenc_lib.cpp -> fdk-aac-2.0.2.tar.gz/libSACenc/src/sacenc_lib.cpp Changed
10
 
1
@@ -130,7 +130,7 @@
2
 #define SACENC_LIB_VL1 0
3
 #define SACENC_LIB_VL2 0
4
 #define SACENC_LIB_TITLE "MPEG Surround Encoder"
5
-#ifdef __ANDROID__
6
+#ifdef SUPPRESS_BUILD_DATE_INFO
7
 #define SACENC_LIB_BUILD_DATE ""
8
 #define SACENC_LIB_BUILD_TIME ""
9
 #else
10
fdk-aac-2.0.1.tar.gz/libSBRdec/include/sbrdecoder.h -> fdk-aac-2.0.2.tar.gz/libSBRdec/include/sbrdecoder.h Changed
35
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -361,15 +361,20 @@
11
  * error (0: core decoder found errors, 1: no errors).
12
  * \param psDecoded       Pointer to a buffer holding a flag. Input: PS is
13
  * possible, Output: PS has been rendered.
14
+ * \param inDataHeadroom  Headroom of the SBR input time signal to prevent
15
+ * clipping.
16
+ * \param outDataHeadroom Pointer to headroom of the SBR output time signal to
17
+ * prevent clipping.
18
  *
19
  * \return  Error code.
20
  */
21
-SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, INT_PCM *input,
22
-                           INT_PCM *timeData, const int timeDataSize,
23
-                           int *numChannels, int *sampleRate,
24
+SBR_ERROR sbrDecoder_Apply(HANDLE_SBRDECODER self, LONG *input, LONG *timeData,
25
+                           const int timeDataSize, int *numChannels,
26
+                           int *sampleRate,
27
                            const FDK_channelMapDescr *const mapDescr,
28
                            const int mapIdx, const int coreDecodedOk,
29
-                           UCHAR *psDecoded);
30
+                           UCHAR *psDecoded, const INT inDataHeadroom,
31
+                           INT *outDataHeadroom);
32
 
33
 /**
34
  * \brief       Close SBR decoder instance and free memory.
35
fdk-aac-2.0.1.tar.gz/libSBRdec/src/HFgen_preFlat.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/HFgen_preFlat.cpp Changed
50
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -897,30 +897,31 @@
11
     for (i = startSample; i < stopSample; i++) {
12
       maxVal |=
13
           (FIXP_DBL)((LONG)(sourceBufferReal[i][loBand]) ^
14
-                     ((LONG)sourceBufferReal[i][loBand] >> (SAMPLE_BITS - 1)));
15
+                     ((LONG)sourceBufferReal[i][loBand] >> (DFRACT_BITS - 1)));
16
       maxVal |=
17
           (FIXP_DBL)((LONG)(sourceBufferImag[i][loBand]) ^
18
-                     ((LONG)sourceBufferImag[i][loBand] >> (SAMPLE_BITS - 1)));
19
+                     ((LONG)sourceBufferImag[i][loBand] >> (DFRACT_BITS - 1)));
20
     }
21
 
22
     if (maxVal != FL2FX_DBL(0.0f)) {
23
-      reserve = fixMax(0, CntLeadingZeros(maxVal) - 2);
24
+      reserve = CntLeadingZeros(maxVal) - 2;
25
     }
26
 
27
     nrg_ov = nrg = (FIXP_DBL)0;
28
     if (scale_nrg_ov > -31) {
29
       for (i = startSample; i < overlap; i++) {
30
-        nrg_ov += (fPow2Div2(sourceBufferReal[i][loBand] << reserve) +
31
-                   fPow2Div2(sourceBufferImag[i][loBand] << reserve)) >>
32
-                  sum_scale_ov;
33
+        nrg_ov +=
34
+            (fPow2Div2(scaleValue(sourceBufferReal[i][loBand], reserve)) +
35
+             fPow2Div2(scaleValue(sourceBufferImag[i][loBand], reserve))) >>
36
+            sum_scale_ov;
37
       }
38
     } else {
39
       scale_nrg_ov = 0;
40
     }
41
     if (scale_nrg > -31) {
42
       for (i = overlap; i < stopSample; i++) {
43
-        nrg += (fPow2Div2(sourceBufferReal[i][loBand] << reserve) +
44
-                fPow2Div2(sourceBufferImag[i][loBand] << reserve)) >>
45
+        nrg += (fPow2Div2(scaleValue(sourceBufferReal[i][loBand], reserve)) +
46
+                fPow2Div2(scaleValue(sourceBufferImag[i][loBand], reserve))) >>
47
                sum_scale;
48
       }
49
     } else {
50
fdk-aac-2.0.1.tar.gz/libSBRdec/src/env_calc.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/env_calc.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -151,6 +151,9 @@
11
 
12
 #include "genericStds.h" /* need FDKpow() for debug outputs */
13
 
14
+#define MAX_SFB_NRG_HEADROOM (1)
15
+#define MAX_VAL_NRG_HEADROOM ((((FIXP_DBL)MAXVAL_DBL) >> MAX_SFB_NRG_HEADROOM))
16
+
17
 typedef struct {
18
   FIXP_DBL nrgRef[MAX_FREQ_COEFFS];
19
   FIXP_DBL nrgEst[MAX_FREQ_COEFFS];
20
@@ -493,7 +496,7 @@
21
   }
22
 }
23
 
24
-#define INTER_TES_SF_CHANGE 3
25
+#define INTER_TES_SF_CHANGE 4
26
 
27
 typedef struct {
28
   FIXP_DBL subsample_power_low[(((1024) / (32) * (4) / 2) + (3 * (4)))];
29
@@ -699,20 +702,11 @@
30
       gain_sf[i] += gamma_sf + 1; /* +1 because of fMultDiv2() */
31
 
32
       /* set gain to at least 0.2f */
33
-      FIXP_DBL point_two = FL2FXCONST_DBL(0.8f); /* scaled up by 2 */
34
-      int point_two_sf = -2;
35
-
36
-      FIXP_DBL tmp = gain[i];
37
-      if (point_two_sf < gain_sf[i]) {
38
-        point_two >>= gain_sf[i] - point_two_sf;
39
-      } else {
40
-        tmp >>= point_two_sf - gain_sf[i];
41
-      }
42
-
43
       /* limit and calculate gain[i]^2 too */
44
       FIXP_DBL gain_pow2;
45
       int gain_pow2_sf;
46
-      if (tmp < point_two) {
47
+
48
+      if (fIsLessThan(gain[i], gain_sf[i], FL2FXCONST_DBL(0.2f), 0)) {
49
         gain[i] = FL2FXCONST_DBL(0.8f);
50
         gain_sf[i] = -2;
51
         gain_pow2 = FL2FXCONST_DBL(0.64f);
52
@@ -739,7 +733,8 @@
53
             fMin(DFRACT_BITS - 1, new_summand_sf - total_power_high_after_sf);
54
         total_power_high_after_sf = new_summand_sf;
55
       } else if (new_summand_sf < total_power_high_after_sf) {
56
-        subsample_power_high[i] >>= total_power_high_after_sf - new_summand_sf;
57
+        subsample_power_high[i] >>=
58
+            fMin(DFRACT_BITS - 1, total_power_high_after_sf - new_summand_sf);
59
       }
60
       total_power_high_after += subsample_power_high[i] >> preShift2;
61
     }
62
@@ -985,7 +980,8 @@
63
   */
64
   if (!useLP)
65
     adj_e = h_sbr_cal_env->filtBufferNoise_e -
66
-            getScalefactor(h_sbr_cal_env->filtBufferNoise, noSubbands);
67
+            getScalefactor(h_sbr_cal_env->filtBufferNoise, noSubbands) +
68
+            (INT)MAX_SFB_NRG_HEADROOM;
69
 
70
   /*
71
     Scan for maximum reference energy to be able
72
@@ -1005,7 +1001,7 @@
73
        - Smoothing can smear high gains of the previous envelope into the
74
        current
75
     */
76
-    maxSfbNrg_e += 6;
77
+    maxSfbNrg_e += (6 + MAX_SFB_NRG_HEADROOM);
78
 
79
     adj_e = maxSfbNrg_e;
80
     // final_e should not exist for PVC fixfix framing
81
@@ -1031,7 +1027,7 @@
82
          - Smoothing can smear high gains of the previous envelope into the
83
          current
84
       */
85
-      maxSfbNrg_e += 6;
86
+      maxSfbNrg_e += (6 + MAX_SFB_NRG_HEADROOM);
87
 
88
       if (borders[i] < hHeaderData->numberTimeSlots)
89
         /* This envelope affects timeslots that belong to the output frame */
90
@@ -1477,7 +1473,7 @@
91
 
92
       for (k = 0; k < noSubbands; k++) {
93
         int sc = scale_change - pNrgs->nrgGain_e[k] + (sc_change - 1);
94
-        pNrgs->nrgGain[k] >>= sc;
95
+        pNrgs->nrgGain[k] >>= fixMin(sc, DFRACT_BITS - 1);
96
         pNrgs->nrgGain_e[k] += sc;
97
       }
98
 
99
@@ -1485,7 +1481,7 @@
100
         for (k = 0; k < noSubbands; k++) {
101
           int sc =
102
               scale_change - h_sbr_cal_env->filtBuffer_e[k] + (sc_change - 1);
103
-          h_sbr_cal_env->filtBuffer[k] >>= sc;
104
+          h_sbr_cal_env->filtBuffer[k] >>= fixMin(sc, DFRACT_BITS - 1);
105
         }
106
       }
107
 
108
@@ -1576,12 +1572,13 @@
109
           FDK_ASSERT(!iTES_enable); /* not supported */
110
           if (flags & SBRDEC_ELD_GRID) {
111
             /* FDKmemset(analysBufferReal[j], 0, 64 * sizeof(FIXP_DBL)); */
112
-            adjustTimeSlot_EldGrid(&analysBufferReal[j][lowSubband], pNrgs,
113
-                                   &h_sbr_cal_env->harmIndex, lowSubband,
114
-                                   noSubbands,
115
-                                   fMin(scale_change, DFRACT_BITS - 1),
116
-                                   noNoiseFlag, &h_sbr_cal_env->phaseIndex,
117
-                                   EXP2SCALE(adj_e) - sbrScaleFactor->lb_scale);
118
+            adjustTimeSlot_EldGrid(
119
+                &analysBufferReal[j][lowSubband], pNrgs,
120
+                &h_sbr_cal_env->harmIndex, lowSubband, noSubbands,
121
+                fMin(scale_change, DFRACT_BITS - 1), noNoiseFlag,
122
+                &h_sbr_cal_env->phaseIndex,
123
+                fMax(EXP2SCALE(adj_e) - sbrScaleFactor->lb_scale,
124
+                     -(DFRACT_BITS - 1)));
125
           } else {
126
             adjustTimeSlotLC(&analysBufferReal[j][lowSubband], pNrgs,
127
                              &h_sbr_cal_env->harmIndex, lowSubband, noSubbands,
128
@@ -1830,7 +1827,8 @@
129
     diff = (int)(nrgGain_e[band] - filtBuffer_e[band]);
130
     if (diff > 0) {
131
       filtBuffer[band] >>=
132
-          diff; /* Compensate for the scale change by shifting the mantissa. */
133
+          fMin(diff, DFRACT_BITS - 1); /* Compensate for the scale change by
134
+                                          shifting the mantissa. */
135
       filtBuffer_e[band] += diff; /* New gain is bigger, use its exponent */
136
     } else if (diff < 0) {
137
       /* The buffered gains seem to be larger, but maybe there
138
@@ -1850,8 +1848,8 @@
139
         filtBuffer_e[band] -= reserve; /* Compensate in the exponent: */
140
 
141
         /* For the remaining difference, change the new gain value */
142
-        diff = fixMin(-(reserve + diff), DFRACT_BITS - 1);
143
-        nrgGain[band] >>= diff;
144
+        diff = -(reserve + diff);
145
+        nrgGain[band] >>= fMin(diff, DFRACT_BITS - 1);
146
         nrgGain_e[band] += diff;
147
       }
148
     }
149
@@ -2325,7 +2323,15 @@
150
     }
151
 
152
     /*  gain = nrgRef / B */
153
-    FDK_divide_MantExp(nrgRef, nrgRef_e, b, b_e, ptrNrgGain, ptrNrgGain_e);
154
+    INT result_exp = 0;
155
+    *ptrNrgGain = fDivNorm(nrgRef, b, &result_exp);
156
+    *ptrNrgGain_e = (SCHAR)result_exp + (nrgRef_e - b_e);
157
+
158
+    /* There could be a one bit diffs. This is important to compensate,
159
+       because later in the code values are compared by exponent only. */
160
+    int headroom = CountLeadingBits(*ptrNrgGain);
161
+    *ptrNrgGain <<= headroom;
162
+    *ptrNrgGain_e -= headroom;
163
   }
164
 }
165
 
166
@@ -2415,6 +2421,9 @@
167
   const FIXP_DBL *p_harmonicPhaseX = &harmonicPhaseX[harmIndex][0];
168
   const INT *p_harmonicPhase = &harmonicPhase[harmIndex][0];
169
 
170
+  const FIXP_DBL max_val = MAX_VAL_NRG_HEADROOM >> scale_change;
171
+  const FIXP_DBL min_val = -max_val;
172
+
173
   *(ptrReal - 1) = fAddSaturate(
174
       *(ptrReal - 1),
175
       SATURATE_SHIFT(fMultDiv2(p_harmonicPhaseX[lowSubband & 1], pSineLevel[0]),
176
@@ -2427,12 +2436,12 @@
177
     FIXP_DBL sineLevel_curr = *pSineLevel++;
178
     phaseIndex = (phaseIndex + 1) & (SBR_NF_NO_RANDOM_VAL - 1);
179
 
180
-    signalReal = fMultDiv2(*ptrReal, *pGain++) << ((int)scale_change);
181
+    signalReal = fMax(fMin(fMultDiv2(*ptrReal, *pGain++), max_val), min_val)
182
+                 << scale_change;
183
     sbNoise = *pNoiseLevel++;
184
     if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
185
       signalReal +=
186
-          (fMultDiv2(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise)
187
-           << 4);
188
+          fMult(FDK_sbrDecoder_sbr_randomPhase[phaseIndex][0], sbNoise);
189
     }
190
     signalReal += sineLevel_curr * p_harmonicPhase[0];
191
     signalReal =
192
@@ -2462,12 +2471,12 @@
193
     FIXP_DBL sineLevel_curr = *pSineLevel++;
194
     phaseIndex = (phaseIndex + 1) & (SBR_NF_NO_RANDOM_VAL - 1);
195
 
196
-    signalReal = fMultDiv2(*ptrReal, *pGain++) << ((int)scale_change);
197
+    signalReal = fMax(fMin(fMultDiv2(*ptrReal, *pGain++), max_val), min_val)
198
+                 << scale_change;
199
     sbNoise = *pNoiseLevel++;
200
     if (((INT)sineLevel_curr | noNoiseFlag) == 0) {
201
fdk-aac-2.0.1.tar.gz/libSBRdec/src/env_extr.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/env_extr.cpp Changed
12
 
1
@@ -1152,6 +1152,10 @@
2
   int nEnv, i, tranIdx;
3
   const int *pTable;
4
 
5
+  if (tranPosInternal >= numberTimeSlots) {
6
+    return 0;
7
+  }
8
+
9
   switch (numberTimeSlots) {
10
     case 8:
11
       pTable = FDK_sbrDecoder_envelopeTable_8[tranPosInternal];
12
fdk-aac-2.0.1.tar.gz/libSBRdec/src/hbe.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/hbe.cpp Changed
28
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -957,7 +957,7 @@
11
     hQmfTran->qmfOutBufSize = 2 * (hQmfTran->noCols / 2 + QMF_WIN_LEN - 1);
12
 
13
     hQmfTran->inBuf_F =
14
-        (INT_PCM*)FDKcalloc(QMF_SYNTH_CHANNELS + 20 + 1, sizeof(INT_PCM));
15
+        (LONG*)FDKcalloc(QMF_SYNTH_CHANNELS + 20 + 1, sizeof(LONG));
16
     /* buffered time signal needs to be delayed by synthesis_size; max
17
      * synthesis_size = 20; */
18
     if (hQmfTran->inBuf_F == NULL) {
19
@@ -1339,7 +1339,7 @@
20
     g_r_m = fMultDiv2(tmp_r, factor_m) << shift;
21
     g_i_m = fMultDiv2(tmp_i, factor_m) << shift;
22
     g_e = scale_factor_hbe - (g_e + factor_e + gammaCenter_e + add);
23
-    fMax((INT)0, g_e);
24
+    g_e = fMax((INT)0, g_e);
25
     *qmfHBEBufReal_F += g_r_m >> g_e;
26
     *qmfHBEBufImag_F += g_i_m >> g_e;
27
   }
28
fdk-aac-2.0.1.tar.gz/libSBRdec/src/hbe.h -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/hbe.h Changed
39
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -132,6 +132,9 @@
11
 } KEEP_STATES_SYNCED_MODE;
12
 
13
 struct hbeTransposer {
14
+  FIXP_DBL anaQmfStates[HBE_QMF_FILTER_STATE_ANA_SIZE];
15
+  FIXP_QSS synQmfStates[HBE_QMF_FILTER_STATE_SYN_SIZE];
16
+
17
   int xOverQmf[MAX_NUM_PATCHES_HBE];
18
 
19
   int maxStretch;
20
@@ -144,7 +147,7 @@
21
   int stopBand;
22
   int bSbr41;
23
 
24
-  INT_PCM *inBuf_F;
25
+  LONG *inBuf_F;
26
   FIXP_DBL **qmfInBufReal_F;
27
   FIXP_DBL **qmfInBufImag_F;
28
 
29
@@ -156,9 +159,6 @@
30
   FIXP_DBL const *synthesisQmfPreModCos_F;
31
   FIXP_DBL const *synthesisQmfPreModSin_F;
32
 
33
-  FIXP_QAS anaQmfStates[HBE_QMF_FILTER_STATE_ANA_SIZE];
34
-  FIXP_QSS synQmfStates[HBE_QMF_FILTER_STATE_SYN_SIZE];
35
-
36
   FIXP_DBL **qmfHBEBufReal_F;
37
   FIXP_DBL **qmfHBEBufImag_F;
38
 
39
fdk-aac-2.0.1.tar.gz/libSBRdec/src/lpp_tran.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/lpp_tran.cpp Changed
72
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -446,8 +446,26 @@
11
                                 pSettings->nCols) +
12
                      lowBandShift);
13
     }
14
-    dynamicScale = fixMax(
15
-        0, dynamicScale - 1); /* one additional bit headroom to prevent -1.0 */
16
+
17
+    if (dynamicScale == 0) {
18
+      /* In this special case the available headroom bits as well as
19
+         ovLowBandShift and lowBandShift are zero. The spectrum is limited to
20
+         prevent -1.0, so negative values for dynamicScale can be avoided. */
21
+      for (i = 0; i < (LPC_ORDER + pSettings->overlap + pSettings->nCols);
22
+           i++) {
23
+        lowBandReal[i] = fixMax(lowBandReal[i], (FIXP_DBL)0x80000001);
24
+      }
25
+      if (!useLP) {
26
+        for (i = 0; i < (LPC_ORDER + pSettings->overlap + pSettings->nCols);
27
+             i++) {
28
+          lowBandImag[i] = fixMax(lowBandImag[i], (FIXP_DBL)0x80000001);
29
+        }
30
+      }
31
+    } else {
32
+      dynamicScale =
33
+          fixMax(0, dynamicScale -
34
+                        1); /* one additional bit headroom to prevent -1.0 */
35
+    }
36
 
37
     /*
38
       Scale temporal QMF buffer.
39
@@ -996,8 +1014,8 @@
40
                               pSettings->nCols) +
41
                    lowBandShift);
42
 
43
-    dynamicScale = fixMax(
44
-        0, dynamicScale - 1); /* one additional bit headroom to prevent -1.0 */
45
+    dynamicScale =
46
+        dynamicScale - 1; /* one additional bit headroom to prevent -1.0 */
47
 
48
     /*
49
     Scale temporal QMF buffer.
50
@@ -1176,6 +1194,9 @@
51
     } else { /* bw <= 0 */
52
 
53
       int descale = fixMin(DFRACT_BITS - 1, (LPC_SCALE_FACTOR + dynamicScale));
54
+      dynamicScale +=
55
+          1; /* prevent negativ scale factor due to 'one additional bit
56
+                headroom' */
57
 
58
       for (i = startSample; i < stopSample; i++) {
59
         FIXP_DBL accu1, accu2;
60
@@ -1192,9 +1213,9 @@
61
                 dynamicScale;
62
 
63
         qmfBufferReal[i][loBand] =
64
-            (lowBandReal[LPC_ORDER + i] >> descale) + (accu1 << 1);
65
+            (lowBandReal[LPC_ORDER + i] >> descale) + (accu1 << (1 + 1));
66
         qmfBufferImag[i][loBand] =
67
-            (lowBandImag[LPC_ORDER + i] >> descale) + (accu2 << 1);
68
+            (lowBandImag[LPC_ORDER + i] >> descale) + (accu2 << (1 + 1));
69
       }
70
     } /* bw <= 0 */
71
 
72
fdk-aac-2.0.1.tar.gz/libSBRdec/src/psdec.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/psdec.cpp Changed
58
 
1
@@ -325,11 +325,11 @@
2
     int env, int usb) {
3
   INT group = 0;
4
   INT bin = 0;
5
-  INT noIidSteps, noFactors;
6
+  INT noIidSteps;
7
 
8
   FIXP_SGL invL;
9
   FIXP_DBL ScaleL, ScaleR;
10
-  FIXP_DBL Alpha, Beta, AlphasValue;
11
+  FIXP_DBL Alpha, Beta;
12
   FIXP_DBL h11r, h12r, h21r, h22r;
13
 
14
   const FIXP_DBL *PScaleFactors;
15
@@ -337,11 +337,9 @@
16
   if (h_ps_d->bsData[h_ps_d->processSlot].mpeg.bFineIidQ) {
17
     PScaleFactors = ScaleFactorsFine; /* values are shiftet right by one */
18
     noIidSteps = NO_IID_STEPS_FINE;
19
-    noFactors = NO_IID_LEVELS_FINE;
20
   } else {
21
     PScaleFactors = ScaleFactors; /* values are shiftet right by one */
22
     noIidSteps = NO_IID_STEPS;
23
-    noFactors = NO_IID_LEVELS;
24
   }
25
 
26
   /* dequantize and decode */
27
@@ -360,23 +358,17 @@
28
 
29
     /* ScaleR and ScaleL are scaled by 1 shift right */
30
 
31
-    ScaleL = ScaleR = 0;
32
-    if (noIidSteps + h_ps_d->specificTo.mpeg.pCoef->aaIidIndexMapped[env][bin] >= 0 && noIidSteps + h_ps_d->specificTo.mpeg.pCoef->aaIidIndexMapped[env][bin] < noFactors)
33
-      ScaleR = PScaleFactors[noIidSteps + h_ps_d->specificTo.mpeg.pCoef
34
-                                              ->aaIidIndexMapped[env][bin]];
35
-    if (noIidSteps - h_ps_d->specificTo.mpeg.pCoef->aaIidIndexMapped[env][bin] >= 0 && noIidSteps - h_ps_d->specificTo.mpeg.pCoef->aaIidIndexMapped[env][bin] < noFactors)
36
-      ScaleL = PScaleFactors[noIidSteps - h_ps_d->specificTo.mpeg.pCoef
37
-                                              ->aaIidIndexMapped[env][bin]];
38
-
39
-    AlphasValue = 0;
40
-    if (h_ps_d->specificTo.mpeg.pCoef->aaIccIndexMapped[env][bin] >= 0)
41
-      AlphasValue = Alphas[h_ps_d->specificTo.mpeg.pCoef->aaIccIndexMapped[env][bin]];
42
+    ScaleR = PScaleFactors[noIidSteps + h_ps_d->specificTo.mpeg.pCoef
43
+                                            ->aaIidIndexMapped[env][bin]];
44
+    ScaleL = PScaleFactors[noIidSteps - h_ps_d->specificTo.mpeg.pCoef
45
+                                            ->aaIidIndexMapped[env][bin]];
46
+
47
     Beta = fMult(
48
-        fMult(AlphasValue,
49
+        fMult(Alphas[h_ps_d->specificTo.mpeg.pCoef->aaIccIndexMapped[env][bin]],
50
               (ScaleR - ScaleL)),
51
         FIXP_SQRT05);
52
     Alpha =
53
-        AlphasValue >> 1;
54
+        Alphas[h_ps_d->specificTo.mpeg.pCoef->aaIccIndexMapped[env][bin]] >> 1;
55
 
56
     /* Alpha and Beta are now both scaled by 2 shifts right */
57
 
58
fdk-aac-2.0.1.tar.gz/libSBRdec/src/pvc_dec.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/pvc_dec.cpp Changed
70
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -534,7 +534,8 @@
11
     for (ksg = ksg_start; ksg < PVC_NBLOW; ksg++) {
12
       for (band = sg_borders[ksg]; band < sg_borders[ksg + 1]; band++) {
13
         /* The division by 8 == (RATE*lbw) is required algorithmically */
14
-        E[ksg] += (fPow2Div2(qmfR[band]) + fPow2Div2(qmfI[band])) >> 2;
15
+        E[ksg] +=
16
+            ((fPow2Div2(qmfR[band]) >> 1) + (fPow2Div2(qmfI[band]) >> 1)) >> 3;
17
       }
18
     }
19
   }
20
@@ -542,7 +543,7 @@
21
     if (E[ksg] > (FIXP_DBL)0) {
22
       /* 10/log2(10) = 0.752574989159953 * 2^2 */
23
       int exp_log;
24
-      FIXP_DBL nrg = CalcLog2(E[ksg], 2 * qmfExponent, &exp_log);
25
+      FIXP_DBL nrg = CalcLog2(E[ksg], 2 * qmfExponent + 2, &exp_log);
26
       nrg = fMult(nrg, FL2FXCONST_SGL(LOG10FAC));
27
       nrg = scaleValue(nrg, exp_log - PVC_ESG_EXP + 2);
28
       pEsg[ksg] = fMax(nrg, FL2FXCONST_DBL(-10.0 / (1 << PVC_ESG_EXP)));
29
@@ -603,22 +604,22 @@
30
       E_high_exp[ksg] = 0;
31
 
32
       /* residual part */
33
-      accu = ((LONG)(SCHAR)*pTab2++) << (DFRACT_BITS - 8 - PVC_ESG_EXP +
34
+      accu = ((LONG)(SCHAR)*pTab2++) << (DFRACT_BITS - 8 - PVC_ESG_EXP - 2 +
35
                                          pPvcDynamicData->pScalingCoef[3]);
36
 
37
       /* linear combination of lower grouped energies part */
38
       for (kb = 0; kb < PVC_NBLOW; kb++) {
39
         predCoeff = (FIXP_SGL)(
40
             (SHORT)(SCHAR)pTab1[kb * pPvcDynamicData->nbHigh + ksg] << 8);
41
-        predCoeff_exp = pPvcDynamicData->pScalingCoef[kb] +
42
-                        1; /* +1 to compensate for Div2 */
43
-        accu += fMultDiv2(E[kb], predCoeff) << predCoeff_exp;
44
+        predCoeff_exp = -(pPvcDynamicData->pScalingCoef[kb] + 1 -
45
+                          2); /* +1 to compensate for Div2; -2 for accu */
46
+        accu += fMultDiv2(E[kb], predCoeff) >> predCoeff_exp;
47
       }
48
       /* convert back to linear domain */
49
       accu = fMult(accu, FL2FXCONST_SGL(LOG10FAC_INV));
50
-      accu = f2Pow(
51
-          accu, PVC_ESG_EXP - 1,
52
-          &predCoeff_exp); /* -1 compensates for exponent of LOG10FAC_INV */
53
+      accu = f2Pow(accu, PVC_ESG_EXP - 1 + 2,
54
+                   &predCoeff_exp); /* -1 compensates for exponent of
55
+                                       LOG10FAC_INV; +2 for accu */
56
       predictedEsgSlot[ksg] = accu;
57
       E_high_exp[ksg] = predCoeff_exp;
58
       if (predCoeff_exp > E_high_exp_max) {
59
@@ -628,8 +629,8 @@
60
 
61
     /* rescale output vector according to largest exponent */
62
     for (ksg = 0; ksg < pPvcDynamicData->nbHigh; ksg++) {
63
-      int scale = E_high_exp[ksg] - E_high_exp_max;
64
-      predictedEsgSlot[ksg] = scaleValue(predictedEsgSlot[ksg], scale);
65
+      int scale = fMin(E_high_exp_max - E_high_exp[ksg], DFRACT_BITS - 1);
66
+      predictedEsgSlot[ksg] = predictedEsgSlot[ksg] >> scale;
67
     }
68
     *predictedEsg_exp = E_high_exp_max;
69
   }
70
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_dec.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbr_dec.cpp Changed
90
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -259,17 +259,18 @@
11
 
12
 void sbr_dec(
13
     HANDLE_SBR_DEC hSbrDec,             /*!< handle to Decoder channel */
14
-    INT_PCM *timeIn,                    /*!< pointer to input time signal */
15
-    INT_PCM *timeOut,                   /*!< pointer to output time signal */
16
+    LONG *timeIn,                       /*!< pointer to input time signal */
17
+    LONG *timeOut,                      /*!< pointer to output time signal */
18
     HANDLE_SBR_DEC hSbrDecRight,        /*!< handle to Decoder channel right */
19
-    INT_PCM *timeOutRight,              /*!< pointer to output time signal */
20
+    LONG *timeOutRight,                 /*!< pointer to output time signal */
21
     const int strideOut,                /*!< Time data traversal strideOut */
22
     HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static control data */
23
     HANDLE_SBR_FRAME_DATA hFrameData,   /*!< Control data of current frame */
24
     HANDLE_SBR_PREV_FRAME_DATA
25
         hPrevFrameData,        /*!< Some control data of last frame */
26
     const int applyProcessing, /*!< Flag for SBR operation */
27
-    HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize) {
28
+    HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize,
29
+    const INT sbrInDataHeadroom) {
30
   int i, slot, reserve;
31
   int saveLbScale;
32
   int lastSlotOffs;
33
@@ -278,7 +279,7 @@
34
   /* temporary pointer / variable for QMF;
35
      required as we want to use temporary buffer
36
      creating one frame delay for HBE in LP mode */
37
-  INT_PCM *pTimeInQmf = timeIn;
38
+  LONG *pTimeInQmf = timeIn;
39
 
40
   /* Number of QMF timeslots in the overlap buffer: */
41
   int ov_len = hSbrDec->LppTrans.pSettings->overlap;
42
@@ -341,8 +342,8 @@
43
   } else {
44
     C_AALLOC_SCRATCH_START(qmfTemp, FIXP_DBL, 2 * (64));
45
     qmfAnalysisFiltering(&hSbrDec->qmfDomainInCh->fb, pReal, pImag,
46
-                         &hSbrDec->qmfDomainInCh->scaling, pTimeInQmf, 0, 1,
47
-                         qmfTemp);
48
+                         &hSbrDec->qmfDomainInCh->scaling, pTimeInQmf,
49
+                         0 + sbrInDataHeadroom, 1, qmfTemp);
50
 
51
     C_AALLOC_SCRATCH_END(qmfTemp, FIXP_DBL, 2 * (64));
52
   }
53
@@ -658,7 +659,7 @@
54
 
55
   if (!(flags & SBRDEC_PS_DECODED)) {
56
     if (!(flags & SBRDEC_SKIP_QMF_SYN)) {
57
-      int outScalefactor = 0;
58
+      int outScalefactor = -(8);
59
 
60
       if (h_ps_d != NULL) {
61
         h_ps_d->procFrameBased = 1; /* we here do frame based processing */
62
@@ -743,6 +744,7 @@
63
       */
64
       FDK_ASSERT(hSbrDec->qmfDomainInCh->pGlobalConf->nBandsSynthesis <=
65
                  QMF_MAX_SYNTHESIS_BANDS);
66
+      qmfChangeOutScalefactor(synQmfRight, -(8));
67
       FDKmemcpy(synQmfRight->FilterStates, synQmf->FilterStates,
68
                 9 * hSbrDec->qmfDomainInCh->pGlobalConf->nBandsSynthesis *
69
                     sizeof(FIXP_QSS));
70
@@ -814,7 +816,8 @@
71
                   : scaleFactorLowBand_no_ov,
72
               scaleFactorHighBand, synQmf->lsb, synQmf->usb);
73
 
74
-          outScalefactorL = outScalefactorR = 1; /* psDiffScale! (MPEG-PS) */
75
+          outScalefactorL = outScalefactorR =
76
+              1 + sbrInDataHeadroom; /* psDiffScale! (MPEG-PS) */
77
         }
78
 
79
         sbrDecoder_drcApplySlot(/* right channel */
80
@@ -831,6 +834,9 @@
81
         outScalefactorL += maxShift;
82
 
83
         if (!(flags & SBRDEC_SKIP_QMF_SYN)) {
84
+          qmfChangeOutScalefactor(synQmf, -(8));
85
+          qmfChangeOutScalefactor(synQmfRight, -(8));
86
+
87
           qmfSynthesisFilteringSlot(
88
               synQmfRight, rQmfReal, /* QMF real buffer */
89
               rQmfImag,              /* QMF imag buffer */
90
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_dec.h -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbr_dec.h Changed
33
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -176,17 +176,18 @@
11
 
12
 void sbr_dec(
13
     HANDLE_SBR_DEC hSbrDec,             /*!< handle to Decoder channel */
14
-    INT_PCM *timeIn,                    /*!< pointer to input time signal */
15
-    INT_PCM *timeOut,                   /*!< pointer to output time signal */
16
+    LONG *timeIn,                       /*!< pointer to input time signal */
17
+    LONG *timeOut,                      /*!< pointer to output time signal */
18
     HANDLE_SBR_DEC hSbrDecRight,        /*!< handle to Decoder channel right */
19
-    INT_PCM *timeOutRight,              /*!< pointer to output time signal */
20
+    LONG *timeOutRight,                 /*!< pointer to output time signal */
21
     INT strideOut,                      /*!< Time data traversal strideOut */
22
     HANDLE_SBR_HEADER_DATA hHeaderData, /*!< Static control data */
23
     HANDLE_SBR_FRAME_DATA hFrameData,   /*!< Control data of current frame */
24
     HANDLE_SBR_PREV_FRAME_DATA
25
         hPrevFrameData,        /*!< Some control data of last frame */
26
     const int applyProcessing, /*!< Flag for SBR operation */
27
-    HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize);
28
+    HANDLE_PS_DEC h_ps_d, const UINT flags, const int codecFrameSize,
29
+    const INT sbrInDataHeadroom);
30
 
31
 SBR_ERROR
32
 createSbrDec(SBR_CHANNEL *hSbrChannel, HANDLE_SBR_HEADER_DATA hHeaderData,
33
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_ram.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbr_ram.cpp Changed
20
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -109,9 +109,6 @@
11
 
12
 #include "sbr_ram.h"
13
 
14
-#define WORKBUFFER1_TAG 2
15
-#define WORKBUFFER2_TAG 3
16
-
17
 /*!
18
   \name StaticSbrData
19
 
20
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_ram.h -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbr_ram.h Changed
20
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -170,6 +170,9 @@
11
                        flushed consecutively. */
12
 
13
   UINT flags;
14
+
15
+  INT sbrInDataHeadroom; /* Headroom of the SBR input time signal to prevent
16
+                            clipping */
17
 };
18
 
19
 H_ALLOC_MEM(Ram_SbrDecElement, SBR_DECODER_ELEMENT)
20
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbr_rom.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbr_rom.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -241,1030 +241,518 @@
11
   random numbers.
12
 */
13
 const FIXP_SGL FDK_sbrDecoder_sbr_randomPhase[SBR_NF_NO_RANDOM_VAL][2] = {
14
-    {FL2FXCONST_SGL(-0.99948153278296f / 8.0),
15
-     FL2FXCONST_SGL(-0.59483417516607f / 8.0)},
16
-    {FL2FXCONST_SGL(0.97113454393991f / 8.0),
17
-     FL2FXCONST_SGL(-0.67528515225647f / 8.0)},
18
-    {FL2FXCONST_SGL(0.14130051758487f / 8.0),
19
-     FL2FXCONST_SGL(-0.95090983575689f / 8.0)},
20
-    {FL2FXCONST_SGL(-0.47005496701697f / 8.0),
21
-     FL2FXCONST_SGL(-0.37340549728647f / 8.0)},
22
-    {FL2FXCONST_SGL(0.80705063769351f / 8.0),
23
-     FL2FXCONST_SGL(0.29653668284408f / 8.0)},
24
-    {FL2FXCONST_SGL(-0.38981478896926f / 8.0),
25
-     FL2FXCONST_SGL(0.89572605717087f / 8.0)},
26
-    {FL2FXCONST_SGL(-0.01053049862020f / 8.0),
27
-     FL2FXCONST_SGL(-0.66959058036166f / 8.0)},
28
-    {FL2FXCONST_SGL(-0.91266367957293f / 8.0),
29
-     FL2FXCONST_SGL(-0.11522938140034f / 8.0)},
30
-    {FL2FXCONST_SGL(0.54840422910309f / 8.0),
31
-     FL2FXCONST_SGL(0.75221367176302f / 8.0)},
32
-    {FL2FXCONST_SGL(0.40009252867955f / 8.0),
33
-     FL2FXCONST_SGL(-0.98929400334421f / 8.0)},
34
-    {FL2FXCONST_SGL(-0.99867974711855f / 8.0),
35
-     FL2FXCONST_SGL(-0.88147068645358f / 8.0)},
36
-    {FL2FXCONST_SGL(-0.95531076805040f / 8.0),
37
-     FL2FXCONST_SGL(0.90908757154593f / 8.0)},
38
-    {FL2FXCONST_SGL(-0.45725933317144f / 8.0),
39
-     FL2FXCONST_SGL(-0.56716323646760f / 8.0)},
40
-    {FL2FXCONST_SGL(-0.72929675029275f / 8.0),
41
-     FL2FXCONST_SGL(-0.98008272727324f / 8.0)},
42
-    {FL2FXCONST_SGL(0.75622801399036f / 8.0),
43
-     FL2FXCONST_SGL(0.20950329995549f / 8.0)},
44
-    {FL2FXCONST_SGL(0.07069442601050f / 8.0),
45
-     FL2FXCONST_SGL(-0.78247898470706f / 8.0)},
46
-    {FL2FXCONST_SGL(0.74496252926055f / 8.0),
47
-     FL2FXCONST_SGL(-0.91169004445807f / 8.0)},
48
-    {FL2FXCONST_SGL(-0.96440182703856f / 8.0),
49
-     FL2FXCONST_SGL(-0.94739918296622f / 8.0)},
50
-    {FL2FXCONST_SGL(0.30424629369539f / 8.0),
51
-     FL2FXCONST_SGL(-0.49438267012479f / 8.0)},
52
-    {FL2FXCONST_SGL(0.66565033746925f / 8.0),
53
-     FL2FXCONST_SGL(0.64652935542491f / 8.0)},
54
-    {FL2FXCONST_SGL(0.91697008020594f / 8.0),
55
-     FL2FXCONST_SGL(0.17514097332009f / 8.0)},
56
-    {FL2FXCONST_SGL(-0.70774918760427f / 8.0),
57
-     FL2FXCONST_SGL(0.52548653416543f / 8.0)},
58
-    {FL2FXCONST_SGL(-0.70051415345560f / 8.0),
59
-     FL2FXCONST_SGL(-0.45340028808763f / 8.0)},
60
-    {FL2FXCONST_SGL(-0.99496513054797f / 8.0),
61
-     FL2FXCONST_SGL(-0.90071908066973f / 8.0)},
62
-    {FL2FXCONST_SGL(0.98164490790123f / 8.0),
63
-     FL2FXCONST_SGL(-0.77463155528697f / 8.0)},
64
-    {FL2FXCONST_SGL(-0.54671580548181f / 8.0),
65
-     FL2FXCONST_SGL(-0.02570928536004f / 8.0)},
66
-    {FL2FXCONST_SGL(-0.01689629065389f / 8.0),
67
-     FL2FXCONST_SGL(0.00287506445732f / 8.0)},
68
-    {FL2FXCONST_SGL(-0.86110349531986f / 8.0),
69
-     FL2FXCONST_SGL(0.42548583726477f / 8.0)},
70
-    {FL2FXCONST_SGL(-0.98892980586032f / 8.0),
71
-     FL2FXCONST_SGL(-0.87881132267556f / 8.0)},
72
-    {FL2FXCONST_SGL(0.51756627678691f / 8.0),
73
-     FL2FXCONST_SGL(0.66926784710139f / 8.0)},
74
-    {FL2FXCONST_SGL(-0.99635026409640f / 8.0),
75
-     FL2FXCONST_SGL(-0.58107730574765f / 8.0)},
76
-    {FL2FXCONST_SGL(-0.99969370862163f / 8.0),
77
-     FL2FXCONST_SGL(0.98369989360250f / 8.0)},
78
-    {FL2FXCONST_SGL(0.55266258627194f / 8.0),
79
-     FL2FXCONST_SGL(0.59449057465591f / 8.0)},
80
-    {FL2FXCONST_SGL(0.34581177741673f / 8.0),
81
-     FL2FXCONST_SGL(0.94879421061866f / 8.0)},
82
-    {FL2FXCONST_SGL(0.62664209577999f / 8.0),
83
-     FL2FXCONST_SGL(-0.74402970906471f / 8.0)},
84
-    {FL2FXCONST_SGL(-0.77149701404973f / 8.0),
85
-     FL2FXCONST_SGL(-0.33883658042801f / 8.0)},
86
-    {FL2FXCONST_SGL(-0.91592244254432f / 8.0),
87
-     FL2FXCONST_SGL(0.03687901376713f / 8.0)},
88
-    {FL2FXCONST_SGL(-0.76285492357887f / 8.0),
89
-     FL2FXCONST_SGL(-0.91371867919124f / 8.0)},
90
-    {FL2FXCONST_SGL(0.79788337195331f / 8.0),
91
-     FL2FXCONST_SGL(-0.93180971199849f / 8.0)},
92
-    {FL2FXCONST_SGL(0.54473080610200f / 8.0),
93
-     FL2FXCONST_SGL(-0.11919206037186f / 8.0)},
94
-    {FL2FXCONST_SGL(-0.85639281671058f / 8.0),
95
-     FL2FXCONST_SGL(0.42429854760451f / 8.0)},
96
-    {FL2FXCONST_SGL(-0.92882402971423f / 8.0),
97
-     FL2FXCONST_SGL(0.27871809078609f / 8.0)},
98
-    {FL2FXCONST_SGL(-0.11708371046774f / 8.0),
99
-     FL2FXCONST_SGL(-0.99800843444966f / 8.0)},
100
-    {FL2FXCONST_SGL(0.21356749817493f / 8.0),
101
-     FL2FXCONST_SGL(-0.90716295627033f / 8.0)},
102
-    {FL2FXCONST_SGL(-0.76191692573909f / 8.0),
103
-     FL2FXCONST_SGL(0.99768118356265f / 8.0)},
104
-    {FL2FXCONST_SGL(0.98111043100884f / 8.0),
105
-     FL2FXCONST_SGL(-0.95854459734407f / 8.0)},
106
-    {FL2FXCONST_SGL(-0.85913269895572f / 8.0),
107
-     FL2FXCONST_SGL(0.95766566168880f / 8.0)},
108
-    {FL2FXCONST_SGL(-0.93307242253692f / 8.0),
109
-     FL2FXCONST_SGL(0.49431757696466f / 8.0)},
110
-    {FL2FXCONST_SGL(0.30485754879632f / 8.0),
111
-     FL2FXCONST_SGL(-0.70540034357529f / 8.0)},
112
-    {FL2FXCONST_SGL(0.85289650925190f / 8.0),
113
-     FL2FXCONST_SGL(0.46766131791044f / 8.0)},
114
-    {FL2FXCONST_SGL(0.91328082618125f / 8.0),
115
-     FL2FXCONST_SGL(-0.99839597361769f / 8.0)},
116
-    {FL2FXCONST_SGL(-0.05890199924154f / 8.0),
117
-     FL2FXCONST_SGL(0.70741827819497f / 8.0)},
118
-    {FL2FXCONST_SGL(0.28398686150148f / 8.0),
119
-     FL2FXCONST_SGL(0.34633555702188f / 8.0)},
120
-    {FL2FXCONST_SGL(0.95258164539612f / 8.0),
121
-     FL2FXCONST_SGL(-0.54893416026939f / 8.0)},
122
-    {FL2FXCONST_SGL(-0.78566324168507f / 8.0),
123
-     FL2FXCONST_SGL(-0.75568541079691f / 8.0)},
124
-    {FL2FXCONST_SGL(-0.95789495447877f / 8.0),
125
-     FL2FXCONST_SGL(-0.20423194696966f / 8.0)},
126
-    {FL2FXCONST_SGL(0.82411158711197f / 8.0),
127
-     FL2FXCONST_SGL(0.96654618432562f / 8.0)},
128
-    {FL2FXCONST_SGL(-0.65185446735885f / 8.0),
129
-     FL2FXCONST_SGL(-0.88734990773289f / 8.0)},
130
-    {FL2FXCONST_SGL(-0.93643603134666f / 8.0),
131
-     FL2FXCONST_SGL(0.99870790442385f / 8.0)},
132
-    {FL2FXCONST_SGL(0.91427159529618f / 8.0),
133
-     FL2FXCONST_SGL(-0.98290505544444f / 8.0)},
134
-    {FL2FXCONST_SGL(-0.70395684036886f / 8.0),
135
-     FL2FXCONST_SGL(0.58796798221039f / 8.0)},
136
-    {FL2FXCONST_SGL(0.00563771969365f / 8.0),
137
-     FL2FXCONST_SGL(0.61768196727244f / 8.0)},
138
-    {FL2FXCONST_SGL(0.89065051931895f / 8.0),
139
-     FL2FXCONST_SGL(0.52783352697585f / 8.0)},
140
-    {FL2FXCONST_SGL(-0.68683707712762f / 8.0),
141
-     FL2FXCONST_SGL(0.80806944710339f / 8.0)},
142
-    {FL2FXCONST_SGL(0.72165342518718f / 8.0),
143
-     FL2FXCONST_SGL(-0.69259857349564f / 8.0)},
144
-    {FL2FXCONST_SGL(-0.62928247730667f / 8.0),
145
-     FL2FXCONST_SGL(0.13627037407335f / 8.0)},
146
-    {FL2FXCONST_SGL(0.29938434065514f / 8.0),
147
-     FL2FXCONST_SGL(-0.46051329682246f / 8.0)},
148
-    {FL2FXCONST_SGL(-0.91781958879280f / 8.0),
149
-     FL2FXCONST_SGL(-0.74012716684186f / 8.0)},
150
-    {FL2FXCONST_SGL(0.99298717043688f / 8.0),
151
-     FL2FXCONST_SGL(0.40816610075661f / 8.0)},
152
-    {FL2FXCONST_SGL(0.82368298622748f / 8.0),
153
-     FL2FXCONST_SGL(-0.74036047190173f / 8.0)},
154
-    {FL2FXCONST_SGL(-0.98512833386833f / 8.0),
155
-     FL2FXCONST_SGL(-0.99972330709594f / 8.0)},
156
-    {FL2FXCONST_SGL(-0.95915368242257f / 8.0),
157
-     FL2FXCONST_SGL(-0.99237800466040f / 8.0)},
158
-    {FL2FXCONST_SGL(-0.21411126572790f / 8.0),
159
-     FL2FXCONST_SGL(-0.93424819052545f / 8.0)},
160
-    {FL2FXCONST_SGL(-0.68821476106884f / 8.0),
161
-     FL2FXCONST_SGL(-0.26892306315457f / 8.0)},
162
-    {FL2FXCONST_SGL(0.91851997982317f / 8.0),
163
-     FL2FXCONST_SGL(0.09358228901785f / 8.0)},
164
-    {FL2FXCONST_SGL(-0.96062769559127f / 8.0),
165
-     FL2FXCONST_SGL(0.36099095133739f / 8.0)},
166
-    {FL2FXCONST_SGL(0.51646184922287f / 8.0),
167
-     FL2FXCONST_SGL(-0.71373332873917f / 8.0)},
168
-    {FL2FXCONST_SGL(0.61130721139669f / 8.0),
169
-     FL2FXCONST_SGL(0.46950141175917f / 8.0)},
170
-    {FL2FXCONST_SGL(0.47336129371299f / 8.0),
171
-     FL2FXCONST_SGL(-0.27333178296162f / 8.0)},
172
-    {FL2FXCONST_SGL(0.90998308703519f / 8.0),
173
-     FL2FXCONST_SGL(0.96715662938132f / 8.0)},
174
-    {FL2FXCONST_SGL(0.44844799194357f / 8.0),
175
-     FL2FXCONST_SGL(0.99211574628306f / 8.0)},
176
-    {FL2FXCONST_SGL(0.66614891079092f / 8.0),
177
-     FL2FXCONST_SGL(0.96590176169121f / 8.0)},
178
-    {FL2FXCONST_SGL(0.74922239129237f / 8.0),
179
-     FL2FXCONST_SGL(-0.89879858826087f / 8.0)},
180
-    {FL2FXCONST_SGL(-0.99571588506485f / 8.0),
181
-     FL2FXCONST_SGL(0.52785521494349f / 8.0)},
182
-    {FL2FXCONST_SGL(0.97401082477563f / 8.0),
183
-     FL2FXCONST_SGL(-0.16855870075190f / 8.0)},
184
-    {FL2FXCONST_SGL(0.72683747733879f / 8.0),
185
-     FL2FXCONST_SGL(-0.48060774432251f / 8.0)},
186
-    {FL2FXCONST_SGL(0.95432193457128f / 8.0),
187
-     FL2FXCONST_SGL(0.68849603408441f / 8.0)},
188
-    {FL2FXCONST_SGL(-0.72962208425191f / 8.0),
189
-     FL2FXCONST_SGL(-0.76608443420917f / 8.0)},
190
-    {FL2FXCONST_SGL(-0.85359479233537f / 8.0),
191
-     FL2FXCONST_SGL(0.88738125901579f / 8.0)},
192
-    {FL2FXCONST_SGL(-0.81412430338535f / 8.0),
193
-     FL2FXCONST_SGL(-0.97480768049637f / 8.0)},
194
-    {FL2FXCONST_SGL(-0.87930772356786f / 8.0),
195
-     FL2FXCONST_SGL(0.74748307690436f / 8.0)},
196
-    {FL2FXCONST_SGL(-0.71573331064977f / 8.0),
197
-     FL2FXCONST_SGL(-0.98570608178923f / 8.0)},
198
-    {FL2FXCONST_SGL(0.83524300028228f / 8.0),
199
-     FL2FXCONST_SGL(0.83702537075163f / 8.0)},
200
-    {FL2FXCONST_SGL(-0.48086065601423f / 8.0),
201
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbrdec_freq_sca.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbrdec_freq_sca.cpp Changed
29
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -230,6 +230,8 @@
11
       }
12
     }
13
 
14
+    stopMin = fMin(stopMin, 64);
15
+
16
     /*
17
       Choose a stop band between k1 and 64 depending on stopFreq (0..13),
18
       based on a logarithmic scale.
19
@@ -523,7 +525,8 @@
20
       step = FL2FXCONST_DBL(0.0f);
21
     }
22
   }
23
-  return FX_DBL2FX_SGL(bandfactor << 1);
24
+  return (bandfactor >= FL2FXCONST_DBL(0.5)) ? (FIXP_SGL)MAXVAL_SGL
25
+                                             : FX_DBL2FX_SGL(bandfactor << 1);
26
 }
27
 
28
 /*!
29
fdk-aac-2.0.1.tar.gz/libSBRdec/src/sbrdecoder.cpp -> fdk-aac-2.0.2.tar.gz/libSBRdec/src/sbrdecoder.cpp Changed
201
 
1
@@ -1,7 +1,7 @@
2
 /* -----------------------------------------------------------------------------
3
 Software License for The Fraunhofer FDK AAC Codec Library for Android
4
 
5
-© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
6
+© Copyright  1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
7
 Forschung e.V. All rights reserved.
8
 
9
  1.    INTRODUCTION
10
@@ -143,24 +143,22 @@
11
 #include "env_extr.h"
12
 #include "sbr_dec.h"
13
 #include "env_dec.h"
14
-#include "sbr_crc.h"
15
+#include "FDK_crc.h"
16
 #include "sbr_ram.h"
17
 #include "sbr_rom.h"
18
 #include "lpp_tran.h"
19
 #include "transcendent.h"
20
 
21
-#include "FDK_crc.h"
22
-
23
 #include "sbrdec_drc.h"
24
 
25
 #include "psbitdec.h"
26
 
27
 /* Decoder library info */
28
 #define SBRDECODER_LIB_VL0 3
29
-#define SBRDECODER_LIB_VL1 0
30
+#define SBRDECODER_LIB_VL1 1
31
 #define SBRDECODER_LIB_VL2 0
32
 #define SBRDECODER_LIB_TITLE "SBR Decoder"
33
-#ifdef __ANDROID__
34
+#ifdef SUPPRESS_BUILD_DATE_INFO
35
 #define SBRDECODER_LIB_BUILD_DATE ""
36
 #define SBRDECODER_LIB_BUILD_TIME ""
37
 #else
38
@@ -619,10 +617,6 @@
39
       self->numSbrChannels -= self->pSbrElement[elementIndex]->nChannels;
40
     }
41
 
42
-    /* Save element ID for sanity checks and to have a fallback for concealment.
43
-     */
44
-    self->pSbrElement[elementIndex]->elementID = elementID;
45
-
46
     /* Determine amount of channels for this element */
47
     switch (elementID) {
48
       case ID_NONE:
49
@@ -655,12 +649,16 @@
50
     }
51
 
52
     /* Sanity check to avoid memory leaks */
53
-    if (elChannels < self->pSbrElement[elementIndex]->nChannels) {
54
+    if (elChannels < self->pSbrElement[elementIndex]->nChannels ||
55
+        (self->numSbrChannels + elChannels) > (8) + (1)) {
56
       self->numSbrChannels += self->pSbrElement[elementIndex]->nChannels;
57
       sbrError = SBRDEC_PARSE_ERROR;
58
       goto bail;
59
     }
60
 
61
+    /* Save element ID for sanity checks and to have a fallback for concealment.
62
+     */
63
+    self->pSbrElement[elementIndex]->elementID = elementID;
64
     self->pSbrElement[elementIndex]->nChannels = elChannels;
65
 
66
     for (ch = 0; ch < elChannels; ch++) {
67
@@ -871,11 +869,10 @@
68
         if (sbrError == SBRDEC_OK) {
69
           hSbrHeader->syncState = SBR_HEADER;
70
           hSbrHeader->status |= SBRDEC_HDR_STAT_UPDATE;
71
+        } else {
72
+          hSbrHeader->syncState = SBR_NOT_INITIALIZED;
73
+          hSbrHeader->status = HEADER_ERROR;
74
         }
75
-        /* else {
76
-          Since we already have overwritten the old SBR header the only way out
77
-        is UPSAMPLING! This will be prepared in the next step.
78
-        } */
79
       }
80
     }
81
   }
82
@@ -1135,18 +1132,22 @@
83
   SBR_HEADER_STATUS headerStatus = HEADER_NOT_PRESENT;
84
 
85
   INT startPos = FDKgetValidBits(hBs);
86
-  INT CRCLen = 0;
87
+  FDK_CRCINFO crcInfo;
88
+  INT crcReg = 0;
89
+  USHORT sbrCrc = 0;
90
+  UINT crcPoly;
91
+  UINT crcStartValue = 0;
92
+  UINT crcLen;
93
+
94
   HANDLE_FDK_BITSTREAM hBsOriginal = hBs;
95
   FDK_BITSTREAM bsBwd;
96
 
97
-  FDK_CRCINFO crcInfo;
98
-  INT crcReg = 0;
99
-  USHORT drmSbrCrc = 0;
100
   const int fGlobalIndependencyFlag = acFlags & AC_INDEP;
101
   const int bs_pvc = acElFlags[elementIndex] & AC_EL_USAC_PVC;
102
   const int bs_interTes = acElFlags[elementIndex] & AC_EL_USAC_ITES;
103
   int stereo;
104
   int fDoDecodeSbrData = 1;
105
+  int alignBits = 0;
106
 
107
   int lastSlot, lastHdrSlot = 0, thisHdrSlot = 0;
108
 
109
@@ -1278,27 +1279,23 @@
110
   if (fDoDecodeSbrData) {
111
     if (crcFlag) {
112
       switch (self->coreCodec) {
113
-        case AOT_ER_AAC_ELD:
114
-          FDKpushFor(hBs, 10);
115
-          /* check sbrcrc later: we don't know the payload length now */
116
-          break;
117
         case AOT_DRM_AAC:
118
         case AOT_DRM_SURROUND:
119
-          drmSbrCrc = (USHORT)FDKreadBits(hBs, 8);
120
-          /* Setup CRC decoder */
121
-          FDKcrcInit(&crcInfo, 0x001d, 0xFFFF, 8);
122
-          /* Start CRC region */
123
-          crcReg = FDKcrcStartReg(&crcInfo, hBs, 0);
124
+          crcPoly = 0x001d;
125
+          crcLen = 8;
126
+          crcStartValue = 0x000000ff;
127
           break;
128
         default:
129
-          CRCLen = bsPayLen - 10; /* change: 0 => i */
130
-          if (CRCLen < 0) {
131
-            fDoDecodeSbrData = 0;
132
-          } else {
133
-            fDoDecodeSbrData = SbrCrcCheck(hBs, CRCLen);
134
-          }
135
+          crcPoly = 0x0633;
136
+          crcLen = 10;
137
+          crcStartValue = 0x00000000;
138
           break;
139
       }
140
+      sbrCrc = (USHORT)FDKreadBits(hBs, crcLen);
141
+      /* Setup CRC decoder */
142
+      FDKcrcInit(&crcInfo, crcPoly, crcStartValue, crcLen);
143
+      /* Start CRC region */
144
+      crcReg = FDKcrcStartReg(&crcInfo, hBs, 0);
145
     }
146
   } /* if (fDoDecodeSbrData) */
147
 
148
@@ -1451,35 +1448,6 @@
149
         valBits = (INT)FDKgetValidBits(hBs);
150
       }
151
 
152
-      if (crcFlag) {
153
-        switch (self->coreCodec) {
154
-          case AOT_ER_AAC_ELD: {
155
-            /* late crc check for eld */
156
-            INT payloadbits =
157
-                (INT)startPos - (INT)FDKgetValidBits(hBs) - startPos;
158
-            INT crcLen = payloadbits - 10;
159
-            FDKpushBack(hBs, payloadbits);
160
-            fDoDecodeSbrData = SbrCrcCheck(hBs, crcLen);
161
-            FDKpushFor(hBs, crcLen);
162
-          } break;
163
-          case AOT_DRM_AAC:
164
-          case AOT_DRM_SURROUND:
165
-            /* End CRC region */
166
-            FDKcrcEndReg(&crcInfo, hBs, crcReg);
167
-            /* Check CRC */
168
-            if ((FDKcrcGetCRC(&crcInfo) ^ 0xFF) != drmSbrCrc) {
169
-              fDoDecodeSbrData = 0;
170
-              if (headerStatus != HEADER_NOT_PRESENT) {
171
-                headerStatus = HEADER_ERROR;
172
-                hSbrHeader->syncState = SBR_NOT_INITIALIZED;
173
-              }
174
-            }
175
-            break;
176
-          default:
177
-            break;
178
-        }
179
-      }
180
-
181
       /* sanity check of remaining bits */
182
       if (valBits < 0) {
183
         fDoDecodeSbrData = 0;
184
@@ -1490,7 +1458,7 @@
185
           case AOT_AAC_LC: {
186
             /* This sanity check is only meaningful with General Audio
187
              * bitstreams */
188
-            int alignBits = valBits & 0x7;
189
+            alignBits = valBits & 0x7;
190
 
191
             if (valBits > alignBits) {
192
               fDoDecodeSbrData = 0;
193
@@ -1509,6 +1477,20 @@
194
     errorStatus = SBRDEC_PARSE_ERROR;
195
   }
196
 
197
+  if (crcFlag && (hSbrHeader->syncState >= SBR_HEADER) && fDoDecodeSbrData) {
198
+    FDKpushFor(hBs, alignBits);
199
+    FDKcrcEndReg(&crcInfo, hBs, crcReg); /* End CRC region */
200
+    FDKpushBack(hBs, alignBits);
201
fdk-aac-2.0.1.tar.gz/libSBRenc/src/sbr_encoder.cpp -> fdk-aac-2.0.2.tar.gz/libSBRenc/src/sbr_encoder.cpp Changed
10
 
1
@@ -2560,7 +2560,7 @@
2
   info->version =
3
       LIB_VERSION(SBRENCODER_LIB_VL0, SBRENCODER_LIB_VL1, SBRENCODER_LIB_VL2);
4
   LIB_VERSION_STRING(info);
5
-#ifdef __ANDROID__
6
+#ifdef SUPPRESS_BUILD_DATE_INFO
7
   info->build_date = "";
8
   info->build_time = "";
9
 #else
10