2 /* -----------------------------------------------------------------------------------------------------------
3 Software License for The Fraunhofer FDK AAC Codec Library for Android
5 © Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
9 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
10 the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
11 This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
14 audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
15 independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
16 of the MPEG specifications.
18 Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
19 may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
20 individually for the purpose of encoding or decoding bit streams in products that are compliant with
21 the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
22 these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
23 software may already be covered under those patent licenses when it is used for those licensed purposes only.
25 Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
26 are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
27 applications information and documentation.
31 Redistribution and use in source and binary forms, with or without modification, are permitted without
32 payment of copyright license fees provided that you satisfy the following conditions:
34 You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
35 your modifications thereto in source code form.
37 You must retain the complete text of this software license in the documentation and/or other materials
38 provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
39 You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
40 modifications thereto to recipients of copies in binary form.
42 The name of Fraunhofer may not be used to endorse or promote products derived from this library without
43 prior written permission.
45 You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
46 software or your modifications thereto.
48 Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
49 and the date of any change. For modified versions of the FDK AAC Codec, the term
50 "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
51 "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
55 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
56 ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
57 respect to this software.
59 You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
60 by appropriate patent licenses.
64 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
65 "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
66 of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
67 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
68 including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
69 or business interruption, however caused and on any theory of liability, whether in contract, strict
70 liability, or tort (including negligence), arising in any way out of the use of this software, even if
71 advised of the possibility of such damage.
73 5. CONTACT INFORMATION
75 Fraunhofer Institute for Integrated Circuits IIS
76 Attention: Audio and Multimedia Departments - FDK AAC LL
78 91058 Erlangen, Germany
80 www.iis.fraunhofer.de/amm
81 amm-info@iis.fraunhofer.de
82 ----------------------------------------------------------------------------------------------------------- */
87 /*****************************************************************************
89 functionname: FDKsbrEnc_InitSbrHuffmanTables
90 description: initializes Huffman Tables dependent on chosen amp_res
95 *****************************************************************************/
97 FDKsbrEnc_InitSbrHuffmanTables (HANDLE_SBR_ENV_DATA sbrEnvData
,
98 HANDLE_SBR_CODE_ENVELOPE henv
,
99 HANDLE_SBR_CODE_ENVELOPE hnoise
,
102 if ( (!henv
) || (!hnoise
) || (!sbrEnvData
) )
103 return (1); /* not init. */
105 sbrEnvData
->init_sbr_amp_res
= amp_res
;
108 case SBR_AMP_RES_3_0
:
111 /*Level/Pan - coding */
112 sbrEnvData
->hufftableLevelTimeC
= v_Huff_envelopeLevelC11T
;
113 sbrEnvData
->hufftableLevelTimeL
= v_Huff_envelopeLevelL11T
;
114 sbrEnvData
->hufftableBalanceTimeC
= bookSbrEnvBalanceC11T
;
115 sbrEnvData
->hufftableBalanceTimeL
= bookSbrEnvBalanceL11T
;
117 sbrEnvData
->hufftableLevelFreqC
= v_Huff_envelopeLevelC11F
;
118 sbrEnvData
->hufftableLevelFreqL
= v_Huff_envelopeLevelL11F
;
119 sbrEnvData
->hufftableBalanceFreqC
= bookSbrEnvBalanceC11F
;
120 sbrEnvData
->hufftableBalanceFreqL
= bookSbrEnvBalanceL11F
;
122 /*Right/Left - coding */
123 sbrEnvData
->hufftableTimeC
= v_Huff_envelopeLevelC11T
;
124 sbrEnvData
->hufftableTimeL
= v_Huff_envelopeLevelL11T
;
125 sbrEnvData
->hufftableFreqC
= v_Huff_envelopeLevelC11F
;
126 sbrEnvData
->hufftableFreqL
= v_Huff_envelopeLevelL11F
;
128 sbrEnvData
->codeBookScfLavBalance
= CODE_BOOK_SCF_LAV_BALANCE11
;
129 sbrEnvData
->codeBookScfLav
= CODE_BOOK_SCF_LAV11
;
131 sbrEnvData
->si_sbr_start_env_bits
= SI_SBR_START_ENV_BITS_AMP_RES_3_0
;
132 sbrEnvData
->si_sbr_start_env_bits_balance
= SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0
;
135 case SBR_AMP_RES_1_5
:
138 /*Level/Pan - coding */
139 sbrEnvData
->hufftableLevelTimeC
= v_Huff_envelopeLevelC10T
;
140 sbrEnvData
->hufftableLevelTimeL
= v_Huff_envelopeLevelL10T
;
141 sbrEnvData
->hufftableBalanceTimeC
= bookSbrEnvBalanceC10T
;
142 sbrEnvData
->hufftableBalanceTimeL
= bookSbrEnvBalanceL10T
;
144 sbrEnvData
->hufftableLevelFreqC
= v_Huff_envelopeLevelC10F
;
145 sbrEnvData
->hufftableLevelFreqL
= v_Huff_envelopeLevelL10F
;
146 sbrEnvData
->hufftableBalanceFreqC
= bookSbrEnvBalanceC10F
;
147 sbrEnvData
->hufftableBalanceFreqL
= bookSbrEnvBalanceL10F
;
149 /*Right/Left - coding */
150 sbrEnvData
->hufftableTimeC
= v_Huff_envelopeLevelC10T
;
151 sbrEnvData
->hufftableTimeL
= v_Huff_envelopeLevelL10T
;
152 sbrEnvData
->hufftableFreqC
= v_Huff_envelopeLevelC10F
;
153 sbrEnvData
->hufftableFreqL
= v_Huff_envelopeLevelL10F
;
155 sbrEnvData
->codeBookScfLavBalance
= CODE_BOOK_SCF_LAV_BALANCE10
;
156 sbrEnvData
->codeBookScfLav
= CODE_BOOK_SCF_LAV10
;
158 sbrEnvData
->si_sbr_start_env_bits
= SI_SBR_START_ENV_BITS_AMP_RES_1_5
;
159 sbrEnvData
->si_sbr_start_env_bits_balance
= SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5
;
163 return (1); /* undefined amp_res mode */
166 /* these are common to both amp_res values */
169 /*Level/Pan - coding */
170 sbrEnvData
->hufftableNoiseLevelTimeC
= v_Huff_NoiseLevelC11T
;
171 sbrEnvData
->hufftableNoiseLevelTimeL
= v_Huff_NoiseLevelL11T
;
172 sbrEnvData
->hufftableNoiseBalanceTimeC
= bookSbrNoiseBalanceC11T
;
173 sbrEnvData
->hufftableNoiseBalanceTimeL
= bookSbrNoiseBalanceL11T
;
175 sbrEnvData
->hufftableNoiseLevelFreqC
= v_Huff_envelopeLevelC11F
;
176 sbrEnvData
->hufftableNoiseLevelFreqL
= v_Huff_envelopeLevelL11F
;
177 sbrEnvData
->hufftableNoiseBalanceFreqC
= bookSbrEnvBalanceC11F
;
178 sbrEnvData
->hufftableNoiseBalanceFreqL
= bookSbrEnvBalanceL11F
;
181 /*Right/Left - coding */
182 sbrEnvData
->hufftableNoiseTimeC
= v_Huff_NoiseLevelC11T
;
183 sbrEnvData
->hufftableNoiseTimeL
= v_Huff_NoiseLevelL11T
;
184 sbrEnvData
->hufftableNoiseFreqC
= v_Huff_envelopeLevelC11F
;
185 sbrEnvData
->hufftableNoiseFreqL
= v_Huff_envelopeLevelL11F
;
187 sbrEnvData
->si_sbr_start_noise_bits
= SI_SBR_START_NOISE_BITS_AMP_RES_3_0
;
188 sbrEnvData
->si_sbr_start_noise_bits_balance
= SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0
;
191 /* init envelope tables and codebooks */
192 henv
->codeBookScfLavBalanceTime
= sbrEnvData
->codeBookScfLavBalance
;
193 henv
->codeBookScfLavBalanceFreq
= sbrEnvData
->codeBookScfLavBalance
;
194 henv
->codeBookScfLavLevelTime
= sbrEnvData
->codeBookScfLav
;
195 henv
->codeBookScfLavLevelFreq
= sbrEnvData
->codeBookScfLav
;
196 henv
->codeBookScfLavTime
= sbrEnvData
->codeBookScfLav
;
197 henv
->codeBookScfLavFreq
= sbrEnvData
->codeBookScfLav
;
199 henv
->hufftableLevelTimeL
= sbrEnvData
->hufftableLevelTimeL
;
200 henv
->hufftableBalanceTimeL
= sbrEnvData
->hufftableBalanceTimeL
;
201 henv
->hufftableTimeL
= sbrEnvData
->hufftableTimeL
;
202 henv
->hufftableLevelFreqL
= sbrEnvData
->hufftableLevelFreqL
;
203 henv
->hufftableBalanceFreqL
= sbrEnvData
->hufftableBalanceFreqL
;
204 henv
->hufftableFreqL
= sbrEnvData
->hufftableFreqL
;
206 henv
->codeBookScfLavFreq
= sbrEnvData
->codeBookScfLav
;
207 henv
->codeBookScfLavTime
= sbrEnvData
->codeBookScfLav
;
209 henv
->start_bits
= sbrEnvData
->si_sbr_start_env_bits
;
210 henv
->start_bits_balance
= sbrEnvData
->si_sbr_start_env_bits_balance
;
213 /* init noise tables and codebooks */
215 hnoise
->codeBookScfLavBalanceTime
= CODE_BOOK_SCF_LAV_BALANCE11
;
216 hnoise
->codeBookScfLavBalanceFreq
= CODE_BOOK_SCF_LAV_BALANCE11
;
217 hnoise
->codeBookScfLavLevelTime
= CODE_BOOK_SCF_LAV11
;
218 hnoise
->codeBookScfLavLevelFreq
= CODE_BOOK_SCF_LAV11
;
219 hnoise
->codeBookScfLavTime
= CODE_BOOK_SCF_LAV11
;
220 hnoise
->codeBookScfLavFreq
= CODE_BOOK_SCF_LAV11
;
222 hnoise
->hufftableLevelTimeL
= sbrEnvData
->hufftableNoiseLevelTimeL
;
223 hnoise
->hufftableBalanceTimeL
= sbrEnvData
->hufftableNoiseBalanceTimeL
;
224 hnoise
->hufftableTimeL
= sbrEnvData
->hufftableNoiseTimeL
;
225 hnoise
->hufftableLevelFreqL
= sbrEnvData
->hufftableNoiseLevelFreqL
;
226 hnoise
->hufftableBalanceFreqL
= sbrEnvData
->hufftableNoiseBalanceFreqL
;
227 hnoise
->hufftableFreqL
= sbrEnvData
->hufftableNoiseFreqL
;
230 hnoise
->start_bits
= sbrEnvData
->si_sbr_start_noise_bits
;
231 hnoise
->start_bits_balance
= sbrEnvData
->si_sbr_start_noise_bits_balance
;
233 /* No delta coding in time from the previous frame due to 1.5dB FIx-FIX rule */
239 /*******************************************************************************
240 Functionname: indexLow2High
241 *******************************************************************************
243 Description: Nice small patch-functions in order to cope with non-factor-2
244 ratios between high-res and low-res
246 Arguments: INT offset, INT index, FREQ_RES res
250 *******************************************************************************/
251 static INT
indexLow2High(INT offset
, INT index
, FREQ_RES res
)
254 if(res
== FREQ_RES_LOW
)
261 return(2*index
- offset
);
267 return(2*index
+index
);
269 return(2*index
+ offset
);
278 /*******************************************************************************
279 Functionname: mapLowResEnergyVal
280 *******************************************************************************
284 Arguments: INT currVal,INT* prevData, INT offset, INT index, FREQ_RES res
288 *******************************************************************************/
289 static void mapLowResEnergyVal(SCHAR currVal
, SCHAR
* prevData
, INT offset
, INT index
, FREQ_RES res
)
292 if(res
== FREQ_RES_LOW
)
297 prevData
[index
] = currVal
;
300 prevData
[2*index
- offset
] = currVal
;
301 prevData
[2*index
+1 - offset
] = currVal
;
309 prevData
[3*index
] = currVal
;
310 prevData
[3*index
+1] = currVal
;
311 prevData
[3*index
+2] = currVal
;
315 prevData
[2*index
+ offset
] = currVal
;
316 prevData
[2*index
+ 1 + offset
] = currVal
;
321 prevData
[index
] = currVal
;
326 /*******************************************************************************
327 Functionname: computeBits
328 *******************************************************************************
332 Arguments: INT delta,
333 INT codeBookScfLavLevel,
334 INT codeBookScfLavBalance,
335 const UCHAR * hufftableLevel,
336 const UCHAR * hufftableBalance, INT coupling, INT channel)
340 *******************************************************************************/
342 computeBits (SCHAR
*delta
,
343 INT codeBookScfLavLevel
,
344 INT codeBookScfLavBalance
,
345 const UCHAR
* hufftableLevel
,
346 const UCHAR
* hufftableBalance
, INT coupling
, INT channel
)
355 index
= fixMax(*delta
, -codeBookScfLavBalance
);
357 index
= fixMin(*delta
, codeBookScfLavBalance
);
359 if (index
!= *delta
) {
364 delta_bits
= hufftableBalance
[index
+ codeBookScfLavBalance
];
368 index
= fixMax(*delta
, -codeBookScfLavLevel
);
370 index
= fixMin(*delta
, codeBookScfLavLevel
);
372 if (index
!= *delta
) {
376 delta_bits
= hufftableLevel
[index
+ codeBookScfLavLevel
];
381 index
= fixMax(*delta
, -codeBookScfLavLevel
);
383 index
= fixMin(*delta
, codeBookScfLavLevel
);
385 if (index
!= *delta
) {
389 delta_bits
= hufftableLevel
[index
+ codeBookScfLavLevel
];
398 /*******************************************************************************
399 Functionname: FDKsbrEnc_codeEnvelope
400 *******************************************************************************
404 Arguments: INT *sfb_nrg,
405 const FREQ_RES *freq_res,
406 SBR_CODE_ENVELOPE * h_sbrCodeEnvelope,
407 INT *directionVec, INT scalable, INT nEnvelopes, INT channel,
411 h_sbrCodeEnvelope->sfb_nrg_prev is modified !
413 h_sbrCodeEnvelope->update is modfied !
414 *directionVec is modified
416 *******************************************************************************/
418 FDKsbrEnc_codeEnvelope(SCHAR
*sfb_nrg
,
419 const FREQ_RES
*freq_res
,
420 SBR_CODE_ENVELOPE
*h_sbrCodeEnvelope
,
427 INT i
, no_of_bands
, band
;
428 FIXP_DBL tmp1
,tmp2
,tmp3
,dF_edge_1stEnv
;
431 INT codeBookScfLavLevelTime
;
432 INT codeBookScfLavLevelFreq
;
433 INT codeBookScfLavBalanceTime
;
434 INT codeBookScfLavBalanceFreq
;
435 const UCHAR
*hufftableLevelTimeL
;
436 const UCHAR
*hufftableBalanceTimeL
;
437 const UCHAR
*hufftableLevelFreqL
;
438 const UCHAR
*hufftableBalanceFreqL
;
440 INT offset
= h_sbrCodeEnvelope
->offset
;
441 INT envDataTableCompFactor
;
443 INT delta_F_bits
= 0, delta_T_bits
= 0;
446 SCHAR delta_F
[MAX_FREQ_COEFFS
];
447 SCHAR delta_T
[MAX_FREQ_COEFFS
];
448 SCHAR last_nrg
, curr_nrg
;
450 tmp1
= FL2FXCONST_DBL(0.5f
) >> (DFRACT_BITS
-16-1);
451 tmp2
= h_sbrCodeEnvelope
->dF_edge_1stEnv
>> (DFRACT_BITS
-16);
452 tmp3
= (FIXP_DBL
)(((INT
)(LONG
)h_sbrCodeEnvelope
->dF_edge_incr
*h_sbrCodeEnvelope
->dF_edge_incr_fac
) >> (DFRACT_BITS
-16));
454 dF_edge_1stEnv
= tmp1
+ tmp2
+ tmp3
;
457 codeBookScfLavLevelTime
= h_sbrCodeEnvelope
->codeBookScfLavLevelTime
;
458 codeBookScfLavLevelFreq
= h_sbrCodeEnvelope
->codeBookScfLavLevelFreq
;
459 codeBookScfLavBalanceTime
= h_sbrCodeEnvelope
->codeBookScfLavBalanceTime
;
460 codeBookScfLavBalanceFreq
= h_sbrCodeEnvelope
->codeBookScfLavBalanceFreq
;
461 hufftableLevelTimeL
= h_sbrCodeEnvelope
->hufftableLevelTimeL
;
462 hufftableBalanceTimeL
= h_sbrCodeEnvelope
->hufftableBalanceTimeL
;
463 hufftableLevelFreqL
= h_sbrCodeEnvelope
->hufftableLevelFreqL
;
464 hufftableBalanceFreqL
= h_sbrCodeEnvelope
->hufftableBalanceFreqL
;
467 codeBookScfLavLevelTime
= h_sbrCodeEnvelope
->codeBookScfLavTime
;
468 codeBookScfLavLevelFreq
= h_sbrCodeEnvelope
->codeBookScfLavFreq
;
469 codeBookScfLavBalanceTime
= h_sbrCodeEnvelope
->codeBookScfLavTime
;
470 codeBookScfLavBalanceFreq
= h_sbrCodeEnvelope
->codeBookScfLavFreq
;
471 hufftableLevelTimeL
= h_sbrCodeEnvelope
->hufftableTimeL
;
472 hufftableBalanceTimeL
= h_sbrCodeEnvelope
->hufftableTimeL
;
473 hufftableLevelFreqL
= h_sbrCodeEnvelope
->hufftableFreqL
;
474 hufftableBalanceFreqL
= h_sbrCodeEnvelope
->hufftableFreqL
;
477 if(coupling
== 1 && channel
== 1)
478 envDataTableCompFactor
= 1; /*should be one when the new huffman-tables are ready*/
480 envDataTableCompFactor
= 0;
483 if (h_sbrCodeEnvelope
->deltaTAcrossFrames
== 0)
484 h_sbrCodeEnvelope
->upDate
= 0;
486 /* no delta coding in time in case of a header */
488 h_sbrCodeEnvelope
->upDate
= 0;
491 for (i
= 0; i
< nEnvelopes
; i
++)
493 if (freq_res
[i
] == FREQ_RES_HIGH
)
494 no_of_bands
= h_sbrCodeEnvelope
->nSfb
[FREQ_RES_HIGH
];
496 no_of_bands
= h_sbrCodeEnvelope
->nSfb
[FREQ_RES_LOW
];
502 delta_F
[0] = curr_nrg
>> envDataTableCompFactor
;
504 if (coupling
&& channel
== 1)
505 delta_F_bits
= h_sbrCodeEnvelope
->start_bits_balance
;
507 delta_F_bits
= h_sbrCodeEnvelope
->start_bits
;
510 if(h_sbrCodeEnvelope
->upDate
!= 0)
512 delta_T
[0] = (curr_nrg
- h_sbrCodeEnvelope
->sfb_nrg_prev
[0]) >> envDataTableCompFactor
;
514 delta_T_bits
= computeBits (&delta_T
[0],
515 codeBookScfLavLevelTime
,
516 codeBookScfLavBalanceTime
,
518 hufftableBalanceTimeL
, coupling
, channel
);
522 mapLowResEnergyVal(curr_nrg
, h_sbrCodeEnvelope
->sfb_nrg_prev
, offset
, 0, freq_res
[i
]);
524 /* ensure that nrg difference is not higher than codeBookScfLavXXXFreq */
525 if ( coupling
&& channel
== 1 ) {
526 for (band
= no_of_bands
- 1; band
> 0; band
--) {
527 if ( ptr_nrg
[band
] - ptr_nrg
[band
-1] > codeBookScfLavBalanceFreq
) {
528 ptr_nrg
[band
-1] = ptr_nrg
[band
] - codeBookScfLavBalanceFreq
;
531 for (band
= 1; band
< no_of_bands
; band
++) {
532 if ( ptr_nrg
[band
-1] - ptr_nrg
[band
] > codeBookScfLavBalanceFreq
) {
533 ptr_nrg
[band
] = ptr_nrg
[band
-1] - codeBookScfLavBalanceFreq
;
538 for (band
= no_of_bands
- 1; band
> 0; band
--) {
539 if ( ptr_nrg
[band
] - ptr_nrg
[band
-1] > codeBookScfLavLevelFreq
) {
540 ptr_nrg
[band
-1] = ptr_nrg
[band
] - codeBookScfLavLevelFreq
;
543 for (band
= 1; band
< no_of_bands
; band
++) {
544 if ( ptr_nrg
[band
-1] - ptr_nrg
[band
] > codeBookScfLavLevelFreq
) {
545 ptr_nrg
[band
] = ptr_nrg
[band
-1] - codeBookScfLavLevelFreq
;
552 for (band
= 1; band
< no_of_bands
; band
++)
554 last_nrg
= (*ptr_nrg
);
556 curr_nrg
= (*ptr_nrg
);
558 delta_F
[band
] = (curr_nrg
- last_nrg
) >> envDataTableCompFactor
;
560 delta_F_bits
+= computeBits (&delta_F
[band
],
561 codeBookScfLavLevelFreq
,
562 codeBookScfLavBalanceFreq
,
564 hufftableBalanceFreqL
, coupling
, channel
);
566 if(h_sbrCodeEnvelope
->upDate
!= 0)
568 delta_T
[band
] = curr_nrg
- h_sbrCodeEnvelope
->sfb_nrg_prev
[indexLow2High(offset
, band
, freq_res
[i
])];
569 delta_T
[band
] = delta_T
[band
] >> envDataTableCompFactor
;
572 mapLowResEnergyVal(curr_nrg
, h_sbrCodeEnvelope
->sfb_nrg_prev
, offset
, band
, freq_res
[i
]);
574 if(h_sbrCodeEnvelope
->upDate
!= 0)
576 delta_T_bits
+= computeBits (&delta_T
[band
],
577 codeBookScfLavLevelTime
,
578 codeBookScfLavBalanceTime
,
580 hufftableBalanceTimeL
, coupling
, channel
);
584 /* Replace sfb_nrg with deltacoded samples and set flag */
587 tmp_bits
= (((delta_T_bits
* dF_edge_1stEnv
) >> (DFRACT_BITS
-18)) + (FIXP_DBL
)1) >> 1;
588 use_dT
= (h_sbrCodeEnvelope
->upDate
!= 0 && (delta_F_bits
> tmp_bits
));
591 use_dT
= (delta_T_bits
< delta_F_bits
&& h_sbrCodeEnvelope
->upDate
!= 0);
595 directionVec
[i
] = TIME
;
596 FDKmemcpy (sfb_nrg
, delta_T
, no_of_bands
* sizeof (SCHAR
));
599 h_sbrCodeEnvelope
->upDate
= 0;
600 directionVec
[i
] = FREQ
;
601 FDKmemcpy (sfb_nrg
, delta_F
, no_of_bands
* sizeof (SCHAR
));
603 sfb_nrg
+= no_of_bands
;
604 h_sbrCodeEnvelope
->upDate
= 1;
610 /*******************************************************************************
611 Functionname: FDKsbrEnc_InitSbrCodeEnvelope
612 *******************************************************************************
620 *******************************************************************************/
622 FDKsbrEnc_InitSbrCodeEnvelope (HANDLE_SBR_CODE_ENVELOPE h_sbrCodeEnvelope
,
624 INT deltaTAcrossFrames
,
625 FIXP_DBL dF_edge_1stEnv
,
626 FIXP_DBL dF_edge_incr
)
629 FDKmemclear(h_sbrCodeEnvelope
,sizeof(SBR_CODE_ENVELOPE
));
631 h_sbrCodeEnvelope
->deltaTAcrossFrames
= deltaTAcrossFrames
;
632 h_sbrCodeEnvelope
->dF_edge_1stEnv
= dF_edge_1stEnv
;
633 h_sbrCodeEnvelope
->dF_edge_incr
= dF_edge_incr
;
634 h_sbrCodeEnvelope
->dF_edge_incr_fac
= 0;
635 h_sbrCodeEnvelope
->upDate
= 0;
636 h_sbrCodeEnvelope
->nSfb
[FREQ_RES_LOW
] = nSfb
[FREQ_RES_LOW
];
637 h_sbrCodeEnvelope
->nSfb
[FREQ_RES_HIGH
] = nSfb
[FREQ_RES_HIGH
];
638 h_sbrCodeEnvelope
->offset
= 2*h_sbrCodeEnvelope
->nSfb
[FREQ_RES_LOW
] - h_sbrCodeEnvelope
->nSfb
[FREQ_RES_HIGH
];