xref: /aosp_15_r20/external/aac/libAACdec/src/usacdec_acelp.h (revision e54365361535b070c2db7374cec45c159c7d0e7a)
1*e5436536SAndroid Build Coastguard Worker /* -----------------------------------------------------------------------------
2*e5436536SAndroid Build Coastguard Worker Software License for The Fraunhofer FDK AAC Codec Library for Android
3*e5436536SAndroid Build Coastguard Worker 
4*e5436536SAndroid Build Coastguard Worker © Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
5*e5436536SAndroid Build Coastguard Worker Forschung e.V. All rights reserved.
6*e5436536SAndroid Build Coastguard Worker 
7*e5436536SAndroid Build Coastguard Worker  1.    INTRODUCTION
8*e5436536SAndroid Build Coastguard Worker The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
9*e5436536SAndroid Build Coastguard Worker that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
10*e5436536SAndroid Build Coastguard Worker scheme for digital audio. This FDK AAC Codec software is intended to be used on
11*e5436536SAndroid Build Coastguard Worker a wide variety of Android devices.
12*e5436536SAndroid Build Coastguard Worker 
13*e5436536SAndroid Build Coastguard Worker AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
14*e5436536SAndroid Build Coastguard Worker general perceptual audio codecs. AAC-ELD is considered the best-performing
15*e5436536SAndroid Build Coastguard Worker full-bandwidth communications codec by independent studies and is widely
16*e5436536SAndroid Build Coastguard Worker deployed. AAC has been standardized by ISO and IEC as part of the MPEG
17*e5436536SAndroid Build Coastguard Worker specifications.
18*e5436536SAndroid Build Coastguard Worker 
19*e5436536SAndroid Build Coastguard Worker Patent licenses for necessary patent claims for the FDK AAC Codec (including
20*e5436536SAndroid Build Coastguard Worker those of Fraunhofer) may be obtained through Via Licensing
21*e5436536SAndroid Build Coastguard Worker (www.vialicensing.com) or through the respective patent owners individually for
22*e5436536SAndroid Build Coastguard Worker the purpose of encoding or decoding bit streams in products that are compliant
23*e5436536SAndroid Build Coastguard Worker with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
24*e5436536SAndroid Build Coastguard Worker Android devices already license these patent claims through Via Licensing or
25*e5436536SAndroid Build Coastguard Worker directly from the patent owners, and therefore FDK AAC Codec software may
26*e5436536SAndroid Build Coastguard Worker already be covered under those patent licenses when it is used for those
27*e5436536SAndroid Build Coastguard Worker licensed purposes only.
28*e5436536SAndroid Build Coastguard Worker 
29*e5436536SAndroid Build Coastguard Worker Commercially-licensed AAC software libraries, including floating-point versions
30*e5436536SAndroid Build Coastguard Worker with enhanced sound quality, are also available from Fraunhofer. Users are
31*e5436536SAndroid Build Coastguard Worker encouraged to check the Fraunhofer website for additional applications
32*e5436536SAndroid Build Coastguard Worker information and documentation.
33*e5436536SAndroid Build Coastguard Worker 
34*e5436536SAndroid Build Coastguard Worker 2.    COPYRIGHT LICENSE
35*e5436536SAndroid Build Coastguard Worker 
36*e5436536SAndroid Build Coastguard Worker Redistribution and use in source and binary forms, with or without modification,
37*e5436536SAndroid Build Coastguard Worker are permitted without payment of copyright license fees provided that you
38*e5436536SAndroid Build Coastguard Worker satisfy the following conditions:
39*e5436536SAndroid Build Coastguard Worker 
40*e5436536SAndroid Build Coastguard Worker You must retain the complete text of this software license in redistributions of
41*e5436536SAndroid Build Coastguard Worker the FDK AAC Codec or your modifications thereto in source code form.
42*e5436536SAndroid Build Coastguard Worker 
43*e5436536SAndroid Build Coastguard Worker You must retain the complete text of this software license in the documentation
44*e5436536SAndroid Build Coastguard Worker and/or other materials provided with redistributions of the FDK AAC Codec or
45*e5436536SAndroid Build Coastguard Worker your modifications thereto in binary form. You must make available free of
46*e5436536SAndroid Build Coastguard Worker charge copies of the complete source code of the FDK AAC Codec and your
47*e5436536SAndroid Build Coastguard Worker modifications thereto to recipients of copies in binary form.
48*e5436536SAndroid Build Coastguard Worker 
49*e5436536SAndroid Build Coastguard Worker The name of Fraunhofer may not be used to endorse or promote products derived
50*e5436536SAndroid Build Coastguard Worker from this library without prior written permission.
51*e5436536SAndroid Build Coastguard Worker 
52*e5436536SAndroid Build Coastguard Worker You may not charge copyright license fees for anyone to use, copy or distribute
53*e5436536SAndroid Build Coastguard Worker the FDK AAC Codec software or your modifications thereto.
54*e5436536SAndroid Build Coastguard Worker 
55*e5436536SAndroid Build Coastguard Worker Your modified versions of the FDK AAC Codec must carry prominent notices stating
56*e5436536SAndroid Build Coastguard Worker that you changed the software and the date of any change. For modified versions
57*e5436536SAndroid Build Coastguard Worker of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
58*e5436536SAndroid Build Coastguard Worker must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
59*e5436536SAndroid Build Coastguard Worker AAC Codec Library for Android."
60*e5436536SAndroid Build Coastguard Worker 
61*e5436536SAndroid Build Coastguard Worker 3.    NO PATENT LICENSE
62*e5436536SAndroid Build Coastguard Worker 
63*e5436536SAndroid Build Coastguard Worker NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
64*e5436536SAndroid Build Coastguard Worker limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
65*e5436536SAndroid Build Coastguard Worker Fraunhofer provides no warranty of patent non-infringement with respect to this
66*e5436536SAndroid Build Coastguard Worker software.
67*e5436536SAndroid Build Coastguard Worker 
68*e5436536SAndroid Build Coastguard Worker You may use this FDK AAC Codec software or modifications thereto only for
69*e5436536SAndroid Build Coastguard Worker purposes that are authorized by appropriate patent licenses.
70*e5436536SAndroid Build Coastguard Worker 
71*e5436536SAndroid Build Coastguard Worker 4.    DISCLAIMER
72*e5436536SAndroid Build Coastguard Worker 
73*e5436536SAndroid Build Coastguard Worker This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
74*e5436536SAndroid Build Coastguard Worker holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
75*e5436536SAndroid Build Coastguard Worker including but not limited to the implied warranties of merchantability and
76*e5436536SAndroid Build Coastguard Worker fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
77*e5436536SAndroid Build Coastguard Worker CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
78*e5436536SAndroid Build Coastguard Worker or consequential damages, including but not limited to procurement of substitute
79*e5436536SAndroid Build Coastguard Worker goods or services; loss of use, data, or profits, or business interruption,
80*e5436536SAndroid Build Coastguard Worker however caused and on any theory of liability, whether in contract, strict
81*e5436536SAndroid Build Coastguard Worker liability, or tort (including negligence), arising in any way out of the use of
82*e5436536SAndroid Build Coastguard Worker this software, even if advised of the possibility of such damage.
83*e5436536SAndroid Build Coastguard Worker 
84*e5436536SAndroid Build Coastguard Worker 5.    CONTACT INFORMATION
85*e5436536SAndroid Build Coastguard Worker 
86*e5436536SAndroid Build Coastguard Worker Fraunhofer Institute for Integrated Circuits IIS
87*e5436536SAndroid Build Coastguard Worker Attention: Audio and Multimedia Departments - FDK AAC LL
88*e5436536SAndroid Build Coastguard Worker Am Wolfsmantel 33
89*e5436536SAndroid Build Coastguard Worker 91058 Erlangen, Germany
90*e5436536SAndroid Build Coastguard Worker 
91*e5436536SAndroid Build Coastguard Worker www.iis.fraunhofer.de/amm
92*e5436536SAndroid Build Coastguard Worker [email protected]
93*e5436536SAndroid Build Coastguard Worker ----------------------------------------------------------------------------- */
94*e5436536SAndroid Build Coastguard Worker 
95*e5436536SAndroid Build Coastguard Worker /**************************** AAC decoder library ******************************
96*e5436536SAndroid Build Coastguard Worker 
97*e5436536SAndroid Build Coastguard Worker    Author(s):   Matthias Hildenbrand
98*e5436536SAndroid Build Coastguard Worker 
99*e5436536SAndroid Build Coastguard Worker    Description: USAC ACELP frame decoder
100*e5436536SAndroid Build Coastguard Worker 
101*e5436536SAndroid Build Coastguard Worker *******************************************************************************/
102*e5436536SAndroid Build Coastguard Worker 
103*e5436536SAndroid Build Coastguard Worker #ifndef USACDEC_ACELP_H
104*e5436536SAndroid Build Coastguard Worker #define USACDEC_ACELP_H
105*e5436536SAndroid Build Coastguard Worker 
106*e5436536SAndroid Build Coastguard Worker #include "common_fix.h"
107*e5436536SAndroid Build Coastguard Worker #include "FDK_bitstream.h"
108*e5436536SAndroid Build Coastguard Worker #include "usacdec_const.h"
109*e5436536SAndroid Build Coastguard Worker #include "usacdec_rom.h"
110*e5436536SAndroid Build Coastguard Worker 
111*e5436536SAndroid Build Coastguard Worker //#define ENHANCED_TCX_TD_CONCEAL_ENABLE
112*e5436536SAndroid Build Coastguard Worker 
113*e5436536SAndroid Build Coastguard Worker /** Structure which holds the ACELP internal persistent memory */
114*e5436536SAndroid Build Coastguard Worker typedef struct {
115*e5436536SAndroid Build Coastguard Worker   FIXP_DBL old_exc_mem[PIT_MAX_MAX + L_INTERPOL];
116*e5436536SAndroid Build Coastguard Worker   FIXP_DBL old_syn_mem[M_LP_FILTER_ORDER]; /* synthesis filter states */
117*e5436536SAndroid Build Coastguard Worker   FIXP_SGL A[M_LP_FILTER_ORDER];
118*e5436536SAndroid Build Coastguard Worker   INT A_exp;
119*e5436536SAndroid Build Coastguard Worker   FIXP_DBL gc_threshold;
120*e5436536SAndroid Build Coastguard Worker   FIXP_DBL de_emph_mem;
121*e5436536SAndroid Build Coastguard Worker   FIXP_SGL past_gpit;
122*e5436536SAndroid Build Coastguard Worker   FIXP_DBL past_gcode;
123*e5436536SAndroid Build Coastguard Worker   USHORT old_T0;
124*e5436536SAndroid Build Coastguard Worker   UCHAR old_T0_frac;
125*e5436536SAndroid Build Coastguard Worker   FIXP_DBL deemph_mem_wsyn;
126*e5436536SAndroid Build Coastguard Worker   FIXP_DBL wsyn_rms;
127*e5436536SAndroid Build Coastguard Worker   SHORT seed_ace;
128*e5436536SAndroid Build Coastguard Worker } CAcelpStaticMem;
129*e5436536SAndroid Build Coastguard Worker 
130*e5436536SAndroid Build Coastguard Worker /** Structure which holds the parameter data needed to decode one ACELP frame.
131*e5436536SAndroid Build Coastguard Worker  */
132*e5436536SAndroid Build Coastguard Worker typedef struct {
133*e5436536SAndroid Build Coastguard Worker   UCHAR
134*e5436536SAndroid Build Coastguard Worker   acelp_core_mode;   /**< mean excitation energy index for whole ACELP frame
135*e5436536SAndroid Build Coastguard Worker                       */
136*e5436536SAndroid Build Coastguard Worker   UCHAR mean_energy; /**< acelp core mode for whole ACELP frame */
137*e5436536SAndroid Build Coastguard Worker   USHORT T0[NB_SUBFR];
138*e5436536SAndroid Build Coastguard Worker   UCHAR T0_frac[NB_SUBFR];
139*e5436536SAndroid Build Coastguard Worker   UCHAR ltp_filtering_flag[NB_SUBFR]; /**< controlls whether LTP postfilter is
140*e5436536SAndroid Build Coastguard Worker                                          active for each ACELP subframe */
141*e5436536SAndroid Build Coastguard Worker   SHORT icb_index[NB_SUBFR]
142*e5436536SAndroid Build Coastguard Worker                  [8]; /**< innovative codebook index for each ACELP subframe */
143*e5436536SAndroid Build Coastguard Worker   UCHAR gains[NB_SUBFR]; /**< gain index for each ACELP subframe */
144*e5436536SAndroid Build Coastguard Worker } CAcelpChannelData;
145*e5436536SAndroid Build Coastguard Worker 
146*e5436536SAndroid Build Coastguard Worker /**
147*e5436536SAndroid Build Coastguard Worker  * \brief Read the acelp_coding() bitstream part.
148*e5436536SAndroid Build Coastguard Worker  * \param[in] hBs bitstream handle to read data from.
149*e5436536SAndroid Build Coastguard Worker  * \param[out] acelpData pointer to structure to store the parsed data of one
150*e5436536SAndroid Build Coastguard Worker  * ACELP frame.
151*e5436536SAndroid Build Coastguard Worker  * \param[in] acelp_core_mode the ACELP core mode index.
152*e5436536SAndroid Build Coastguard Worker  * \param[in] coreCoderFrameLength length of core coder frame (1024|768)
153*e5436536SAndroid Build Coastguard Worker  */
154*e5436536SAndroid Build Coastguard Worker INT CLpd_AcelpRead(HANDLE_FDK_BITSTREAM hBs, CAcelpChannelData *acelpData,
155*e5436536SAndroid Build Coastguard Worker                    INT acelp_core_mode, INT i_offset, INT coreCoderFrameLength);
156*e5436536SAndroid Build Coastguard Worker /**
157*e5436536SAndroid Build Coastguard Worker  * \brief Initialization of memory before one LPD frame is decoded
158*e5436536SAndroid Build Coastguard Worker  * \param[out] synth_buf synthesis buffer to be initialized, exponent = SF_SYNTH
159*e5436536SAndroid Build Coastguard Worker  * \param[in] old_synth past synthesis of previous LPD frame, exponent =
160*e5436536SAndroid Build Coastguard Worker  * SF_SYNTH
161*e5436536SAndroid Build Coastguard Worker  * \param[out] synth_buf_fb fullband synthesis buffer to be initialized,
162*e5436536SAndroid Build Coastguard Worker  * exponent = SF_SYNTH
163*e5436536SAndroid Build Coastguard Worker  * \param[in] old_synth_fb past fullband synthesis of previous LPD frame,
164*e5436536SAndroid Build Coastguard Worker  * exponent = SF_SYNTH
165*e5436536SAndroid Build Coastguard Worker  * \param[out] pitch vector where decoded pitch lag values are stored
166*e5436536SAndroid Build Coastguard Worker  * \param[in] old_T_pf past pitch lag values of previous LPD frame
167*e5436536SAndroid Build Coastguard Worker  * \param[in] samplingRate sampling rate for pitch lag offset calculation
168*e5436536SAndroid Build Coastguard Worker  * \param[out] i_offset pitch lag offset for the decoding of the pitch lag
169*e5436536SAndroid Build Coastguard Worker  * \param[in] coreCoderFrameLength length of core coder frame (1024|768)
170*e5436536SAndroid Build Coastguard Worker  */
171*e5436536SAndroid Build Coastguard Worker void Acelp_PreProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
172*e5436536SAndroid Build Coastguard Worker                          INT *old_T_pf, FIXP_DBL *pit_gain,
173*e5436536SAndroid Build Coastguard Worker                          FIXP_DBL *old_gain_pf, INT samplingRate, INT *i_offset,
174*e5436536SAndroid Build Coastguard Worker                          INT coreCoderFrameLength, INT synSfd,
175*e5436536SAndroid Build Coastguard Worker                          INT nbSubfrSuperfr);
176*e5436536SAndroid Build Coastguard Worker 
177*e5436536SAndroid Build Coastguard Worker /**
178*e5436536SAndroid Build Coastguard Worker  * \brief Save tail of buffers for the initialization of the next LPD frame
179*e5436536SAndroid Build Coastguard Worker  * \param[in] synth_buf synthesis of current LPD frame, exponent = SF_SYNTH
180*e5436536SAndroid Build Coastguard Worker  * \param[out] old_synth memory where tail of fullband synth_buf is stored,
181*e5436536SAndroid Build Coastguard Worker  * exponent = SF_SYNTH
182*e5436536SAndroid Build Coastguard Worker  * \param[in] synth_buf_fb fullband synthesis of current LPD frame, exponent =
183*e5436536SAndroid Build Coastguard Worker  * SF_SYNTH
184*e5436536SAndroid Build Coastguard Worker  * \param[out] old_synth_fb memory where tail of fullband synth_buf is stored,
185*e5436536SAndroid Build Coastguard Worker  * exponent = SF_SYNTH
186*e5436536SAndroid Build Coastguard Worker  * \param[in] pitch decoded pitch lag values of current LPD frame
187*e5436536SAndroid Build Coastguard Worker  * \param[out] old_T_pf memory where last SYN_SFD pitch lag values are stored
188*e5436536SAndroid Build Coastguard Worker  */
189*e5436536SAndroid Build Coastguard Worker void Acelp_PostProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
190*e5436536SAndroid Build Coastguard Worker                           INT *old_T_pf, INT coreCoderFrameLength, INT synSfd,
191*e5436536SAndroid Build Coastguard Worker                           INT nbSubfrSuperfr);
192*e5436536SAndroid Build Coastguard Worker 
193*e5436536SAndroid Build Coastguard Worker /**
194*e5436536SAndroid Build Coastguard Worker  * \brief Decode one ACELP frame (three or four ACELP subframes with 64 samples
195*e5436536SAndroid Build Coastguard Worker  * each)
196*e5436536SAndroid Build Coastguard Worker  * \param[in,out] acelp_mem pointer to ACELP memory structure
197*e5436536SAndroid Build Coastguard Worker  * \param[in] i_offset pitch lag offset
198*e5436536SAndroid Build Coastguard Worker  * \param[in] lsp_old LPC filter in LSP domain corresponding to previous frame
199*e5436536SAndroid Build Coastguard Worker  * \param[in] lsp_new LPC filter in LSP domain corresponding to current frame
200*e5436536SAndroid Build Coastguard Worker  * \param[in] stab_fac stability factor constrained by 0<=stab_fac<=1.0,
201*e5436536SAndroid Build Coastguard Worker  * exponent = SF_STAB
202*e5436536SAndroid Build Coastguard Worker  * \param[in] acelpData pointer to struct with data which is needed for decoding
203*e5436536SAndroid Build Coastguard Worker  * one ACELP frame
204*e5436536SAndroid Build Coastguard Worker  * \param[out] synth ACELP output signal
205*e5436536SAndroid Build Coastguard Worker  * \param[out] pT four decoded pitch lag values
206*e5436536SAndroid Build Coastguard Worker  * \param[in] coreCoderFrameLength length of core coder frame (1024|768)
207*e5436536SAndroid Build Coastguard Worker  */
208*e5436536SAndroid Build Coastguard Worker void CLpd_AcelpDecode(CAcelpStaticMem *acelp_mem, INT i_offset,
209*e5436536SAndroid Build Coastguard Worker                       const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
210*e5436536SAndroid Build Coastguard Worker                       const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
211*e5436536SAndroid Build Coastguard Worker                       FIXP_SGL stab_fac, CAcelpChannelData *acelpData,
212*e5436536SAndroid Build Coastguard Worker                       INT numLostSubframes, int lastLpcLost, int frameCnt,
213*e5436536SAndroid Build Coastguard Worker                       FIXP_DBL synth[], int pT[], FIXP_DBL *pit_gain,
214*e5436536SAndroid Build Coastguard Worker                       INT coreCoderFrameLength);
215*e5436536SAndroid Build Coastguard Worker 
216*e5436536SAndroid Build Coastguard Worker /**
217*e5436536SAndroid Build Coastguard Worker  * \brief Reset ACELP internal memory.
218*e5436536SAndroid Build Coastguard Worker  * \param[out] acelp_mem pointer to ACELP memory structure
219*e5436536SAndroid Build Coastguard Worker  */
220*e5436536SAndroid Build Coastguard Worker void CLpd_AcelpReset(CAcelpStaticMem *acelp_mem);
221*e5436536SAndroid Build Coastguard Worker 
222*e5436536SAndroid Build Coastguard Worker /**
223*e5436536SAndroid Build Coastguard Worker  * \brief Initialize ACELP internal memory in case of FAC before ACELP decoder
224*e5436536SAndroid Build Coastguard Worker  * is called
225*e5436536SAndroid Build Coastguard Worker  * \param[in] synth points to end+1 of past valid synthesis signal, exponent =
226*e5436536SAndroid Build Coastguard Worker  * SF_SYNTH
227*e5436536SAndroid Build Coastguard Worker  * \param[in] last_lpd_mode last lpd mode
228*e5436536SAndroid Build Coastguard Worker  * \param[in] last_last_lpd_mode lpd mode before last_lpd_mode
229*e5436536SAndroid Build Coastguard Worker  * \param[in] A_new LP synthesis filter coeffs corresponding to last frame,
230*e5436536SAndroid Build Coastguard Worker  * exponent = SF_A_COEFFS
231*e5436536SAndroid Build Coastguard Worker  * \param[in] A_old LP synthesis filter coeffs corresponding to the frame before
232*e5436536SAndroid Build Coastguard Worker  * last frame, exponent = SF_A_COEFFS
233*e5436536SAndroid Build Coastguard Worker  * \param[in,out] acelp_mem pointer to ACELP memory structure
234*e5436536SAndroid Build Coastguard Worker  * \param[in] coreCoderFrameLength length of core coder frame (1024|768)
235*e5436536SAndroid Build Coastguard Worker  */
236*e5436536SAndroid Build Coastguard Worker void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
237*e5436536SAndroid Build Coastguard Worker                                   UCHAR last_last_lpd_mode,
238*e5436536SAndroid Build Coastguard Worker                                   const FIXP_LPC *A_new, const INT A_new_exp,
239*e5436536SAndroid Build Coastguard Worker                                   const FIXP_LPC *A_old, const INT A_old_exp,
240*e5436536SAndroid Build Coastguard Worker                                   CAcelpStaticMem *acelp_mem,
241*e5436536SAndroid Build Coastguard Worker                                   INT coreCoderFrameLength, INT clearOldExc,
242*e5436536SAndroid Build Coastguard Worker                                   UCHAR lpd_mode);
243*e5436536SAndroid Build Coastguard Worker 
244*e5436536SAndroid Build Coastguard Worker /**
245*e5436536SAndroid Build Coastguard Worker  * \brief Calculate zero input response (zir) of the acelp synthesis filter
246*e5436536SAndroid Build Coastguard Worker  * \param[in] A LP synthesis filter coefficients, exponent = SF_A_COEFFS
247*e5436536SAndroid Build Coastguard Worker  * \param[in,out] acelp_mem pointer to ACELP memory structure
248*e5436536SAndroid Build Coastguard Worker  * \param[in] length length of zir
249*e5436536SAndroid Build Coastguard Worker  * \param[out] zir pointer to zir output buffer, exponent = SF_SYNTH
250*e5436536SAndroid Build Coastguard Worker  */
251*e5436536SAndroid Build Coastguard Worker void CLpd_Acelp_Zir(const FIXP_LPC A[], const INT A_exp,
252*e5436536SAndroid Build Coastguard Worker                     CAcelpStaticMem *acelp_mem, const INT length,
253*e5436536SAndroid Build Coastguard Worker                     FIXP_DBL zir[], int doDeemph);
254*e5436536SAndroid Build Coastguard Worker 
255*e5436536SAndroid Build Coastguard Worker /**
256*e5436536SAndroid Build Coastguard Worker  * \brief Borrow static excitation memory from ACELP decoder
257*e5436536SAndroid Build Coastguard Worker  * \param[in] acelp_mem pointer to ACELP memory structure
258*e5436536SAndroid Build Coastguard Worker  * \param[in] length number of requested FIXP_DBL values
259*e5436536SAndroid Build Coastguard Worker  * \return pointer to requested memory
260*e5436536SAndroid Build Coastguard Worker  *
261*e5436536SAndroid Build Coastguard Worker  * The caller has to take care not to overwrite valid memory areas.
262*e5436536SAndroid Build Coastguard Worker  * During TCX/FAC calculations and before CLpd_AcelpPrepareInternalMem() is
263*e5436536SAndroid Build Coastguard Worker  * called, the following memory size is available:
264*e5436536SAndroid Build Coastguard Worker  * - 256 samples in case of ACELP -> TCX20 -> ACELP transition
265*e5436536SAndroid Build Coastguard Worker  * - PIT_MAX_MAX+L_INTERPOL samples in all other cases
266*e5436536SAndroid Build Coastguard Worker  */
267*e5436536SAndroid Build Coastguard Worker FIXP_DBL *CLpd_ACELP_GetFreeExcMem(CAcelpStaticMem *acelp_mem, INT length);
268*e5436536SAndroid Build Coastguard Worker 
269*e5436536SAndroid Build Coastguard Worker void CLpd_TcxTDConceal(CAcelpStaticMem *acelp_mem, SHORT *pitch,
270*e5436536SAndroid Build Coastguard Worker                        const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
271*e5436536SAndroid Build Coastguard Worker                        const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
272*e5436536SAndroid Build Coastguard Worker                        const FIXP_SGL stab_fac, INT numLostSubframes,
273*e5436536SAndroid Build Coastguard Worker                        FIXP_DBL synth[], INT coreCoderFrameLength,
274*e5436536SAndroid Build Coastguard Worker                        UCHAR last_tcx_noise_factor);
275*e5436536SAndroid Build Coastguard Worker 
E_UTIL_random(SHORT * seed)276*e5436536SAndroid Build Coastguard Worker inline SHORT E_UTIL_random(SHORT *seed) {
277*e5436536SAndroid Build Coastguard Worker   *seed = (SHORT)((((LONG)*seed * (LONG)31821) >> 1) + (LONG)13849);
278*e5436536SAndroid Build Coastguard Worker   return (*seed);
279*e5436536SAndroid Build Coastguard Worker }
280*e5436536SAndroid Build Coastguard Worker 
281*e5436536SAndroid Build Coastguard Worker #endif /* USACDEC_ACELP_H */
282