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 \author Robert Weidner
97 #include "rvlcconceal.h"
98 #include "aacdec_hcr.h"
100 /*---------------------------------------------------------------------------------------------
103 description: init RVLC by data from channelinfo, which was decoded previously and
105 -----------------------------------------------------------------------------------------------
106 input: - pointer rvlc structure
107 - pointer channel info structure
108 - pointer bitstream structure
109 -----------------------------------------------------------------------------------------------
111 -------------------------------------------------------------------------------------------- */
114 void rvlcInit (CErRvlcInfo
*pRvlc
,
115 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
116 HANDLE_FDK_BITSTREAM bs
)
118 /* RVLC common initialization part 2 of 2 */
119 SHORT
*pScfEsc
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfEsc
;
120 SHORT
*pScfFwd
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfFwd
;
121 SHORT
*pScfBwd
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfBwd
;
122 SHORT
*pScaleFactor
= pAacDecoderChannelInfo
->pDynData
->aScaleFactor
;
125 pAacDecoderChannelInfo
->pDynData
->specificTo
.aac
.rvlcIntensityUsed
= 0;
127 pRvlc
->numDecodedEscapeWordsEsc
= 0;
128 pRvlc
->numDecodedEscapeWordsFwd
= 0;
129 pRvlc
->numDecodedEscapeWordsBwd
= 0;
131 pRvlc
->intensity_used
= 0;
132 pRvlc
->errorLogRvlc
= 0;
134 pRvlc
->conceal_max
= CONCEAL_MAX_INIT
;
135 pRvlc
->conceal_min
= CONCEAL_MIN_INIT
;
137 pRvlc
->conceal_max_esc
= CONCEAL_MAX_INIT
;
138 pRvlc
->conceal_min_esc
= CONCEAL_MIN_INIT
;
140 pRvlc
->pHuffTreeRvlcEscape
= aHuffTreeRvlcEscape
;
141 pRvlc
->pHuffTreeRvlCodewds
= aHuffTreeRvlCodewds
;
143 /* init scf arrays (for savety (in case of there are only zero codebooks)) */
144 for (bnds
= 0; bnds
< RVLC_MAX_SFB
; bnds
++) {
148 pScaleFactor
[bnds
] = 0;
151 /* set base bitstream ptr to the RVL-coded part (start of RVLC data (ESC 2)) */
154 pRvlc
->bitstreamIndexRvlFwd
= FDKgetBitCnt(bs
); /* first bit within RVL coded block as start address for forward decoding */
155 pRvlc
->bitstreamIndexRvlBwd
= FDKgetBitCnt(bs
) + pRvlc
->length_of_rvlc_sf
- 1; /* last bit within RVL coded block as start address for backward decoding */
157 /* skip RVLC-bitstream-part -- pointing now to escapes (if present) or to TNS data (if present) */
158 FDKpushFor (bs
, pRvlc
->length_of_rvlc_sf
);
160 if ( pRvlc
->sf_escapes_present
!= 0 ) {
162 /* locate internal bitstream ptr at escapes (which is the second part) */
164 pRvlc
->bitstreamIndexEsc
= FDKgetBitCnt(bs
);
166 /* skip escapeRVLC-bitstream-part -- pointing to TNS data (if present) to make decoder continue */
167 /* decoding of RVLC should work despite this second pushFor during initialization because */
168 /* bitstream initialization is valid for both ESC2 data parts (RVL-coded values and ESC-coded values) */
169 FDKpushFor (bs
, pRvlc
->length_of_rvlc_escapes
);
172 #if VERBOSE_RVLC_INIT
173 DebugOutputInit(pRvlc
,pAacDecoderChannelInfo
);
178 /*---------------------------------------------------------------------------------------------
179 function: rvlcCheckIntensityCb
181 description: Check if a intensity codebook is used in the current channel.
182 -----------------------------------------------------------------------------------------------
183 input: - pointer rvlc structure
184 - pointer channel info structure
185 -----------------------------------------------------------------------------------------------
186 output: - intensity_used: 0 no intensity codebook is used
187 1 intensity codebook is used
188 -----------------------------------------------------------------------------------------------
190 -------------------------------------------------------------------------------------------- */
193 void rvlcCheckIntensityCb (CErRvlcInfo
*pRvlc
,
194 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
)
196 int group
, band
, bnds
;
198 pRvlc
->intensity_used
= 0;
200 for (group
=0; group
< pRvlc
->numWindowGroups
; group
++) {
201 for (band
=0; band
< pRvlc
->maxSfbTransmitted
; band
++) {
202 bnds
= 16*group
+band
;
203 if ( (pAacDecoderChannelInfo
->pDynData
->aCodeBook
[bnds
] == INTENSITY_HCB
) || (pAacDecoderChannelInfo
->pDynData
->aCodeBook
[bnds
] == INTENSITY_HCB2
) ) {
204 pRvlc
->intensity_used
= 1;
212 /*---------------------------------------------------------------------------------------------
213 function: rvlcDecodeEscapeWord
215 description: Decode a huffman coded RVLC Escape-word. This value is part of a DPCM coded
217 -----------------------------------------------------------------------------------------------
218 input: - pointer rvlc structure
219 -----------------------------------------------------------------------------------------------
220 return: - a single RVLC-Escape value which had to be applied to a DPCM value (which
221 has a absolute value of 7)
222 -------------------------------------------------------------------------------------------- */
225 SCHAR
rvlcDecodeEscapeWord (CErRvlcInfo
*pRvlc
,
226 HANDLE_FDK_BITSTREAM bs
)
235 USHORT
* pBitstreamIndexEsc
;
236 const UINT
* pEscTree
;
238 pEscTree
= pRvlc
->pHuffTreeRvlcEscape
;
239 pBitstreamIndexEsc
= &(pRvlc
->bitstreamIndexEsc
);
240 treeNode
= *pEscTree
; /* init at starting node */
242 for (i
=MAX_LEN_RVLC_ESCAPE_WORD
-1; i
>= 0; i
--) {
243 carryBit
= rvlcReadBitFromBitstream(bs
, /* get next bit */
247 CarryBitToBranchValue(carryBit
, /* huffman decoding, do a single step in huffman decoding tree */
252 if ((branchNode
& TEST_BIT_10
) == TEST_BIT_10
) { /* test bit 10 ; if set --> a RVLC-escape-word is completely decoded */
253 value
= (SCHAR
) branchNode
& CLR_BIT_10
;
254 pRvlc
->length_of_rvlc_escapes
-= (MAX_LEN_RVLC_ESCAPE_WORD
- i
);
256 if (pRvlc
->length_of_rvlc_escapes
< 0) {
257 pRvlc
->errorLogRvlc
|= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID
;
264 treeNode
= *(pEscTree
+ branchValue
); /* update treeNode for further step in decoding tree */
268 pRvlc
->errorLogRvlc
|= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID
;
270 return -1; /* should not be reached */
274 /*---------------------------------------------------------------------------------------------
275 function: rvlcDecodeEscapes
277 description: Decodes all huffman coded RVLC Escape Words.
278 Here a difference to the pseudo-code-implementation from standard can be
279 found. A while loop (and not two nested for loops) is used for two reasons:
281 1. The plain huffman encoded escapes are decoded before the RVL-coded
282 scalefactors. Therefore the escapes are present in the second step
283 when decoding the RVL-coded-scalefactor values in forward and
286 When the RVL-coded scalefactors are decoded and there a escape is
287 needed, then it is just taken out of the array in ascending order.
290 -----------------------------------------------------------------------------------------------
291 input: - pointer rvlc structure
292 - handle to FDK bitstream
293 -----------------------------------------------------------------------------------------------
294 return: - 0 ok the decoded escapes seem to be valid
295 - 1 error there was a error detected during decoding escapes
296 --> all escapes are invalid
297 -------------------------------------------------------------------------------------------- */
300 void rvlcDecodeEscapes (CErRvlcInfo
*pRvlc
,
302 HANDLE_FDK_BITSTREAM bs
)
306 SHORT
* pEscBitCntSum
;
308 pEscBitCntSum
= &(pRvlc
->length_of_rvlc_escapes
);
310 /* Decode all RVLC-Escape words with a plain Huffman-Decoder */
311 while ( *pEscBitCntSum
> 0 ) {
312 escWord
= rvlcDecodeEscapeWord(pRvlc
, bs
);
316 pEsc
[escCnt
] = escWord
;
320 pRvlc
->errorLogRvlc
|= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID
;
321 pRvlc
->numDecodedEscapeWordsEsc
= escCnt
;
325 } /* all RVLC escapes decoded */
327 pRvlc
->numDecodedEscapeWordsEsc
= escCnt
;
331 /*---------------------------------------------------------------------------------------------
332 function: decodeRVLCodeword
334 description: Decodes a RVL-coded dpcm-word (-part).
335 -----------------------------------------------------------------------------------------------
336 input: - FDK bitstream handle
337 - pointer rvlc structure
338 -----------------------------------------------------------------------------------------------
339 return: - a dpcm value which is within range [0,1,..,14] in case of no errors.
340 The offset of 7 must be subtracted to get a valid dpcm scalefactor value.
341 In case of errors a forbidden codeword is detected --> returning -1
342 -------------------------------------------------------------------------------------------- */
344 SCHAR
decodeRVLCodeword (HANDLE_FDK_BITSTREAM bs
, CErRvlcInfo
*pRvlc
)
352 const UINT
*pRvlCodeTree
= pRvlc
->pHuffTreeRvlCodewds
;
353 UCHAR direction
= pRvlc
->direction
;
354 USHORT
*pBitstrIndxRvl
= pRvlc
->pBitstrIndxRvl_RVL
;
355 UINT treeNode
= *pRvlCodeTree
;
357 for (i
=MAX_LEN_RVLC_CODE_WORD
-1; i
>= 0; i
--) {
358 carryBit
= rvlcReadBitFromBitstream(bs
, /* get next bit */
362 CarryBitToBranchValue(carryBit
, /* huffman decoding, do a single step in huffman decoding tree */
367 if ((branchNode
& TEST_BIT_10
) == TEST_BIT_10
) { /* test bit 10 ; if set --> a RVLC-codeword is completely decoded */
368 value
= (SCHAR
) (branchNode
& CLR_BIT_10
);
369 *pRvlc
->pRvlBitCnt_RVL
-= (MAX_LEN_RVLC_CODE_WORD
- i
);
371 /* check available bits for decoding */
372 if (*pRvlc
->pRvlBitCnt_RVL
< 0) {
373 if (direction
== FWD
) {
374 pRvlc
->errorLogRvlc
|= RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD
; }
376 pRvlc
->errorLogRvlc
|= RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD
; }
377 value
= -1; /* signalize an error in return value, because too many bits was decoded */
380 /* check max value of dpcm value */
381 if (value
> MAX_ALLOWED_DPCM_INDEX
) {
382 if (direction
== FWD
) {
383 pRvlc
->errorLogRvlc
|= RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD
;
386 pRvlc
->errorLogRvlc
|= RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD
;
388 value
= -1; /* signalize an error in return value, because a forbidden cw was detected*/
391 return value
; /* return a dpcm value with offset +7 or an error status */
394 treeNode
= *(pRvlCodeTree
+ branchValue
); /* update treeNode for further step in decoding tree */
402 /*---------------------------------------------------------------------------------------------
403 function: rvlcDecodeForward
405 description: Decode RVL-coded codewords in forward direction.
406 -----------------------------------------------------------------------------------------------
407 input: - pointer rvlc structure
408 - pointer channel info structure
409 - handle to FDK bitstream
410 -----------------------------------------------------------------------------------------------
412 -------------------------------------------------------------------------------------------- */
415 void rvlcDecodeForward (CErRvlcInfo
*pRvlc
,
416 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
417 HANDLE_FDK_BITSTREAM bs
)
425 SHORT factor
= pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
- SF_OFFSET
;
426 SHORT position
= - SF_OFFSET
;
427 SHORT noisenrg
= pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
- SF_OFFSET
- 90 - 256;
429 SHORT
* pScfFwd
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfFwd
;
430 SHORT
* pScfEsc
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfEsc
;
431 UCHAR
* pEscFwdCnt
= &(pRvlc
->numDecodedEscapeWordsFwd
);
433 pRvlc
->pRvlBitCnt_RVL
= &(pRvlc
->length_of_rvlc_sf_fwd
);
434 pRvlc
->pBitstrIndxRvl_RVL
= &(pRvlc
->bitstreamIndexRvlFwd
);
437 pRvlc
->direction
= FWD
;
438 pRvlc
->noise_used
= 0;
444 rvlcCheckIntensityCb(pRvlc
,pAacDecoderChannelInfo
);
446 /* main loop fwd long */
447 for (group
=0; group
< pRvlc
->numWindowGroups
; group
++) {
448 for (band
=0; band
< pRvlc
->maxSfbTransmitted
; band
++) {
449 bnds
= 16*group
+band
;
451 switch (pAacDecoderChannelInfo
->pDynData
->aCodeBook
[bnds
]) {
457 case INTENSITY_HCB2
:
459 /* store dpcm_is_position */
460 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
462 pRvlc
->conceal_max
= bnds
;
465 dpcm
-= TABLE_OFFSET
;
466 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
467 if (pRvlc
->length_of_rvlc_escapes
) {
468 pRvlc
->conceal_max
= bnds
;
472 if (dpcm
== MIN_RVL
) {
479 if (pRvlc
->conceal_max_esc
== CONCEAL_MAX_INIT
) {
480 pRvlc
->conceal_max_esc
= bnds
;
485 pScfFwd
[bnds
] = position
;
486 pRvlc
->lastIs
= position
;
490 if (pRvlc
->noise_used
== 0) {
491 pRvlc
->noise_used
= 1;
492 pRvlc
->first_noise_band
= bnds
;
493 noisenrg
+= pRvlc
->dpcm_noise_nrg
;
494 pScfFwd
[bnds
] = 100 + noisenrg
;
495 pRvlc
->lastNrg
= noisenrg
;
498 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
500 pRvlc
->conceal_max
= bnds
;
503 dpcm
-= TABLE_OFFSET
;
504 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
505 if (pRvlc
->length_of_rvlc_escapes
) {
506 pRvlc
->conceal_max
= bnds
;
510 if (dpcm
== MIN_RVL
) {
517 if (pRvlc
->conceal_max_esc
== CONCEAL_MAX_INIT
) {
518 pRvlc
->conceal_max_esc
= bnds
;
523 pScfFwd
[bnds
] = 100 + noisenrg
;
524 pRvlc
->lastNrg
= noisenrg
;
526 pAacDecoderChannelInfo
->data
.aac
.PnsData
.pnsUsed
[bnds
] = 1;
531 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
533 pRvlc
->conceal_max
= bnds
;
536 dpcm
-= TABLE_OFFSET
;
537 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
538 if (pRvlc
->length_of_rvlc_escapes
) {
539 pRvlc
->conceal_max
= bnds
;
543 if (dpcm
== MIN_RVL
) {
544 dpcm
-= *pScfEsc
++; }
549 if (pRvlc
->conceal_max_esc
== CONCEAL_MAX_INIT
) {
550 pRvlc
->conceal_max_esc
= bnds
;
555 pScfFwd
[bnds
] = factor
;
556 pRvlc
->lastScf
= factor
;
562 /* postfetch fwd long */
563 if (pRvlc
->intensity_used
) {
564 dpcm
= decodeRVLCodeword(bs
, pRvlc
); /* dpcm_is_last_position */
566 pRvlc
->conceal_max
= bnds
;
569 dpcm
-= TABLE_OFFSET
;
570 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
571 if (pRvlc
->length_of_rvlc_escapes
) {
572 pRvlc
->conceal_max
= bnds
;
576 if (dpcm
== MIN_RVL
) {
583 if (pRvlc
->conceal_max_esc
== CONCEAL_MAX_INIT
) {
584 pRvlc
->conceal_max_esc
= bnds
;
588 pRvlc
->dpcm_is_last_position
= dpcm
;
593 /*---------------------------------------------------------------------------------------------
594 function: rvlcDecodeBackward
596 description: Decode RVL-coded codewords in backward direction.
597 -----------------------------------------------------------------------------------------------
598 input: - pointer rvlc structure
599 - pointer channel info structure
600 - handle FDK bitstream
601 -----------------------------------------------------------------------------------------------
603 -------------------------------------------------------------------------------------------- */
606 void rvlcDecodeBackward (CErRvlcInfo
*pRvlc
,
607 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
608 HANDLE_FDK_BITSTREAM bs
)
610 SHORT band
, group
, dpcm
, offset
;
611 SHORT bnds
= pRvlc
->maxSfbTransmitted
-1;
613 SHORT factor
= pRvlc
->rev_global_gain
- SF_OFFSET
;
614 SHORT position
= pRvlc
->dpcm_is_last_position
- SF_OFFSET
;
615 SHORT noisenrg
= pRvlc
->rev_global_gain
+ pRvlc
->dpcm_noise_last_position
- SF_OFFSET
- 90 - 256;
617 SHORT
*pScfBwd
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfBwd
;
618 SHORT
*pScfEsc
= pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfEsc
;
619 UCHAR
*pEscEscCnt
= &(pRvlc
->numDecodedEscapeWordsEsc
);
620 UCHAR
*pEscBwdCnt
= &(pRvlc
->numDecodedEscapeWordsBwd
);
622 pRvlc
->pRvlBitCnt_RVL
= &(pRvlc
->length_of_rvlc_sf_bwd
);
623 pRvlc
->pBitstrIndxRvl_RVL
= &(pRvlc
->bitstreamIndexRvlBwd
);
626 pRvlc
->direction
= BWD
;
627 pScfEsc
+= *pEscEscCnt
- 1; /* set pScfEsc to last entry */
632 /* prefetch long BWD */
633 if (pRvlc
->intensity_used
) {
634 dpcm
= decodeRVLCodeword(bs
, pRvlc
); /* dpcm_is_last_position */
636 pRvlc
->dpcm_is_last_position
= 0;
637 pRvlc
->conceal_min
= bnds
;
640 dpcm
-= TABLE_OFFSET
;
641 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
642 if (pRvlc
->length_of_rvlc_escapes
) {
643 pRvlc
->conceal_min
= bnds
;
647 if (dpcm
== MIN_RVL
) {
654 if (pRvlc
->conceal_min_esc
== CONCEAL_MIN_INIT
) {
655 pRvlc
->conceal_min_esc
= bnds
;
659 pRvlc
->dpcm_is_last_position
= dpcm
;
662 /* main loop long BWD */
663 for (group
=pRvlc
->numWindowGroups
-1; group
>= 0; group
--) {
664 for (band
=pRvlc
->maxSfbTransmitted
-1; band
>= 0; band
--) {
665 bnds
= 16*group
+band
;
666 if ((band
== 0) && (pRvlc
->numWindowGroups
!= 1))
667 offset
= 16 - pRvlc
->maxSfbTransmitted
+ 1;
671 switch (pAacDecoderChannelInfo
->pDynData
->aCodeBook
[bnds
]) {
677 case INTENSITY_HCB2
:
679 /* store dpcm_is_position */
680 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
682 pScfBwd
[bnds
] = position
;
683 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
686 dpcm
-= TABLE_OFFSET
;
687 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
688 if (pRvlc
->length_of_rvlc_escapes
) {
689 pScfBwd
[bnds
] = position
;
690 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
694 if (dpcm
== MIN_RVL
) {
701 if (pRvlc
->conceal_min_esc
== CONCEAL_MIN_INIT
) {
702 pRvlc
->conceal_min_esc
= FDKmax(0,bnds
-offset
);
706 pScfBwd
[bnds
] = position
;
708 pRvlc
->firstIs
= position
;
712 if ( bnds
== pRvlc
->first_noise_band
) {
713 pScfBwd
[bnds
] = pRvlc
->dpcm_noise_nrg
+ pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
- SF_OFFSET
- 90 - 256;
714 pRvlc
->firstNrg
= pScfBwd
[bnds
];
717 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
719 pScfBwd
[bnds
] = noisenrg
;
720 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
723 dpcm
-= TABLE_OFFSET
;
724 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
725 if (pRvlc
->length_of_rvlc_escapes
) {
726 pScfBwd
[bnds
] = noisenrg
;
727 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
731 if (dpcm
== MIN_RVL
) {
738 if (pRvlc
->conceal_min_esc
== CONCEAL_MIN_INIT
) {
739 pRvlc
->conceal_min_esc
= FDKmax(0,bnds
-offset
);
743 pScfBwd
[bnds
] = noisenrg
;
745 pRvlc
->firstNrg
= noisenrg
;
750 dpcm
= decodeRVLCodeword(bs
, pRvlc
);
752 pScfBwd
[bnds
] = factor
;
753 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
756 dpcm
-= TABLE_OFFSET
;
757 if ((dpcm
== MIN_RVL
) || (dpcm
== MAX_RVL
)) {
758 if (pRvlc
->length_of_rvlc_escapes
) {
759 pScfBwd
[bnds
] = factor
;
760 pRvlc
->conceal_min
= FDKmax(0,bnds
-offset
);
764 if (dpcm
== MIN_RVL
) {
771 if (pRvlc
->conceal_min_esc
== CONCEAL_MIN_INIT
) {
772 pRvlc
->conceal_min_esc
= FDKmax(0,bnds
-offset
);
776 pScfBwd
[bnds
] = factor
;
778 pRvlc
->firstScf
= factor
;
786 /*---------------------------------------------------------------------------------------------
787 function: rvlcFinalErrorDetection
789 description: Call RVLC concealment if error was detected in decoding process
790 -----------------------------------------------------------------------------------------------
791 input: - pointer rvlc structure
792 - pointer channel info structure
793 -----------------------------------------------------------------------------------------------
795 -------------------------------------------------------------------------------------------- */
798 void rvlcFinalErrorDetection (CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
799 CAacDecoderStaticChannelInfo
*pAacDecoderStaticChannelInfo
)
801 CErRvlcInfo
*pRvlc
= &pAacDecoderChannelInfo
->pComData
->overlay
.aac
.erRvlcInfo
;
802 UCHAR ErrorStatusComplete
= 0;
803 UCHAR ErrorStatusLengthFwd
= 0;
804 UCHAR ErrorStatusLengthBwd
= 0;
805 UCHAR ErrorStatusLengthEscapes
= 0;
806 UCHAR ErrorStatusFirstScf
= 0;
807 UCHAR ErrorStatusLastScf
= 0;
808 UCHAR ErrorStatusFirstNrg
= 0;
809 UCHAR ErrorStatusLastNrg
= 0;
810 UCHAR ErrorStatusFirstIs
= 0;
811 UCHAR ErrorStatusLastIs
= 0;
812 UCHAR ErrorStatusForbiddenCwFwd
= 0;
813 UCHAR ErrorStatusForbiddenCwBwd
= 0;
814 UCHAR ErrorStatusNumEscapesFwd
= 0;
815 UCHAR ErrorStatusNumEscapesBwd
= 0;
816 UCHAR ConcealStatus
= 1;
817 UCHAR currentBlockType
; /* short: 0, not short: 1*/
819 #if VERBOSE_RVLC_OUTPUT
820 CHAR Strategy
[60]="No";
825 pAacDecoderChannelInfo
->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
= 1;
827 /* invalid escape words, bit counter unequal zero, forbidden codeword detected */
828 if (pRvlc
->errorLogRvlc
& RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD
)
829 ErrorStatusForbiddenCwFwd
= 1;
831 if (pRvlc
->errorLogRvlc
& RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD
)
832 ErrorStatusForbiddenCwBwd
= 1;
834 /* bit counter forward unequal zero */
835 if (pRvlc
->length_of_rvlc_sf_fwd
)
836 ErrorStatusLengthFwd
= 1;
838 /* bit counter backward unequal zero */
839 if (pRvlc
->length_of_rvlc_sf_bwd
)
840 ErrorStatusLengthBwd
= 1;
842 /* bit counter escape sequences unequal zero */
843 if (pRvlc
->sf_escapes_present
)
844 if (pRvlc
->length_of_rvlc_escapes
)
845 ErrorStatusLengthEscapes
= 1;
847 if (pRvlc
->sf_used
) {
848 /* first decoded scf does not match to global gain in backward direction */
849 if (pRvlc
->firstScf
!= (pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
- SF_OFFSET
) )
850 ErrorStatusFirstScf
= 1;
852 /* last decoded scf does not match to rev global gain in forward direction */
853 if (pRvlc
->lastScf
!= (pRvlc
->rev_global_gain
- SF_OFFSET
) )
854 ErrorStatusLastScf
= 1;
857 if (pRvlc
->noise_used
) {
858 /* first decoded nrg does not match to dpcm_noise_nrg in backward direction */
859 if (pRvlc
->firstNrg
!= (pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
+ pRvlc
->dpcm_noise_nrg
- SF_OFFSET
-90 - 256) )
860 ErrorStatusFirstNrg
= 1;
862 /* last decoded nrg does not match to dpcm_noise_last_position in forward direction */
863 if (pRvlc
->lastNrg
!= (pRvlc
->rev_global_gain
+ pRvlc
->dpcm_noise_last_position
- SF_OFFSET
- 90 - 256) )
864 ErrorStatusLastNrg
= 1;
867 if (pRvlc
->intensity_used
) {
868 /* first decoded is position does not match in backward direction */
869 if (pRvlc
->firstIs
!= (-SF_OFFSET
) )
870 ErrorStatusFirstIs
= 1;
872 /* last decoded is position does not match in forward direction */
873 if (pRvlc
->lastIs
!= (pRvlc
->dpcm_is_last_position
- SF_OFFSET
) )
874 ErrorStatusLastIs
= 1;
877 /* decoded escapes and used escapes in forward direction do not fit */
878 if ((pRvlc
->numDecodedEscapeWordsFwd
!= pRvlc
->numDecodedEscapeWordsEsc
) && (pRvlc
->conceal_max
== CONCEAL_MAX_INIT
)) {
879 ErrorStatusNumEscapesFwd
= 1;
882 /* decoded escapes and used escapes in backward direction do not fit */
883 if ((pRvlc
->numDecodedEscapeWordsBwd
!= pRvlc
->numDecodedEscapeWordsEsc
) && (pRvlc
->conceal_min
== CONCEAL_MIN_INIT
)) {
884 ErrorStatusNumEscapesBwd
= 1;
887 #if VERBOSE_RVLC_OUTPUT
888 conceal_max
= pRvlc
->conceal_max
;
889 conceal_min
= pRvlc
->conceal_min
;
892 if ( ErrorStatusLengthEscapes
894 ( (pRvlc
->conceal_max
== CONCEAL_MAX_INIT
)
895 && (pRvlc
->numDecodedEscapeWordsFwd
!= pRvlc
->numDecodedEscapeWordsEsc
)
896 && (ErrorStatusLastScf
|| ErrorStatusLastNrg
|| ErrorStatusLastIs
) )
900 ( (pRvlc
->conceal_min
== CONCEAL_MIN_INIT
)
901 && (pRvlc
->numDecodedEscapeWordsBwd
!= pRvlc
->numDecodedEscapeWordsEsc
)
902 && (ErrorStatusFirstScf
|| ErrorStatusFirstNrg
|| ErrorStatusFirstIs
) )
904 || ( (pRvlc
->conceal_max
== CONCEAL_MAX_INIT
)
905 && ((pRvlc
->rev_global_gain
- SF_OFFSET
- pRvlc
->lastScf
) < -15)
907 || ( (pRvlc
->conceal_min
== CONCEAL_MIN_INIT
)
908 && ((pAacDecoderChannelInfo
->pDynData
->RawDataInfo
.GlobalGain
- SF_OFFSET
- pRvlc
->firstScf
) < -15)
911 if ((pRvlc
->conceal_max
== CONCEAL_MAX_INIT
) || (pRvlc
->conceal_min
== CONCEAL_MIN_INIT
)) {
912 pRvlc
->conceal_max
= 0;
913 pRvlc
->conceal_min
= FDKmax(0, (pRvlc
->numWindowGroups
-1)*16+pRvlc
->maxSfbTransmitted
-1);
916 pRvlc
->conceal_max
= FDKmin(pRvlc
->conceal_max
,pRvlc
->conceal_max_esc
);
917 pRvlc
->conceal_min
= FDKmax(pRvlc
->conceal_min
,pRvlc
->conceal_min_esc
);
921 ErrorStatusComplete
= ErrorStatusLastScf
|| ErrorStatusFirstScf
|| ErrorStatusLastNrg
|| ErrorStatusFirstNrg
922 || ErrorStatusLastIs
|| ErrorStatusFirstIs
|| ErrorStatusForbiddenCwFwd
|| ErrorStatusForbiddenCwBwd
923 || ErrorStatusLengthFwd
|| ErrorStatusLengthBwd
|| ErrorStatusLengthEscapes
|| ErrorStatusNumEscapesFwd
924 || ErrorStatusNumEscapesBwd
;
926 currentBlockType
= (GetWindowSequence(&pAacDecoderChannelInfo
->icsInfo
) == EightShortSequence
) ? 0 : 1;
929 if (!ErrorStatusComplete
) {
935 lastSfbIndex
= (pRvlc
->numWindowGroups
> 1) ? 16 : 64;
937 for (group
=0; group
< pRvlc
->numWindowGroups
; group
++) {
938 for (band
=0; band
<pRvlc
->maxSfbTransmitted
; band
++) {
939 bnds
= 16*group
+band
;
940 pAacDecoderChannelInfo
->pDynData
->aScaleFactor
[bnds
] = pAacDecoderStaticChannelInfo
->concealmentInfo
.aRvlcPreviousScaleFactor
[bnds
] = pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfFwd
[bnds
];
944 for (group
=0; group
< pRvlc
->numWindowGroups
; group
++)
946 for (band
=0; band
<pRvlc
->maxSfbTransmitted
; band
++) {
947 bnds
= 16*group
+band
;
948 pAacDecoderStaticChannelInfo
->concealmentInfo
.aRvlcPreviousCodebook
[bnds
] = pAacDecoderChannelInfo
->pDynData
->aCodeBook
[bnds
];
950 for (; band
<lastSfbIndex
; band
++) {
951 bnds
= 16*group
+band
;
952 FDK_ASSERT(bnds
>= 0 && bnds
< RVLC_MAX_SFB
);
953 pAacDecoderStaticChannelInfo
->concealmentInfo
.aRvlcPreviousCodebook
[bnds
] = ZERO_HCB
;
961 /* A single bit error was detected in decoding of dpcm values. It also could be an error with more bits in decoding
962 of escapes and dpcm values whereby an illegal codeword followed not directly after the corrupted bits but just
963 after decoding some more (wrong) scalefactors. Use the smaller scalefactor from forward decoding, backward decoding
964 and previous frame. */
965 if ( ((pRvlc
->conceal_min
!= CONCEAL_MIN_INIT
) || (pRvlc
->conceal_max
!= CONCEAL_MAX_INIT
)) && (pRvlc
->conceal_min
<= pRvlc
->conceal_max
)
966 && (pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousBlockType
== currentBlockType
) && pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousScaleFactorOK
967 && pRvlc
->sf_concealment
&& ConcealStatus
)
969 BidirectionalEstimation_UseScfOfPrevFrameAsReference (pAacDecoderChannelInfo
, pAacDecoderStaticChannelInfo
);
971 #if VERBOSE_RVLC_OUTPUT
972 FDKstrcpy(Strategy
,"Yes (BidirectionalEstimation_UseScfOfPrevFrameAsReference)");
976 /* A single bit error was detected in decoding of dpcm values. It also could be an error with more bits in decoding
977 of escapes and dpcm values whereby an illegal codeword followed not directly after the corrupted bits but just
978 after decoding some more (wrong) scalefactors. Use the smaller scalefactor from forward and backward decoding. */
979 if ( (pRvlc
->conceal_min
<= pRvlc
->conceal_max
) && ((pRvlc
->conceal_min
!= CONCEAL_MIN_INIT
) || (pRvlc
->conceal_max
!= CONCEAL_MAX_INIT
))
980 && !(pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousScaleFactorOK
&& pRvlc
->sf_concealment
&& (pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousBlockType
== currentBlockType
))
983 BidirectionalEstimation_UseLowerScfOfCurrentFrame (pAacDecoderChannelInfo
);
985 #if VERBOSE_RVLC_OUTPUT
986 FDKstrcpy(Strategy
,"Yes (BidirectionalEstimation_UseLowerScfOfCurrentFrame)");
990 /* No errors were detected in decoding of escapes and dpcm values however the first and last value
991 of a group (is,nrg,sf) is incorrect */
992 if ( (pRvlc
->conceal_min
<= pRvlc
->conceal_max
) && ((ErrorStatusLastScf
&& ErrorStatusFirstScf
)
993 || (ErrorStatusLastNrg
&& ErrorStatusFirstNrg
) || (ErrorStatusLastIs
&& ErrorStatusFirstIs
))
994 && !(ErrorStatusForbiddenCwFwd
|| ErrorStatusForbiddenCwBwd
|| ErrorStatusLengthEscapes
) && ConcealStatus
)
996 StatisticalEstimation (pAacDecoderChannelInfo
);
998 #if VERBOSE_RVLC_OUTPUT
999 FDKstrcpy(Strategy
,"Yes (StatisticalEstimation)");
1003 /* A error with more bits in decoding of escapes and dpcm values was detected. Use the smaller scalefactor from forward
1004 decoding, backward decoding and previous frame. */
1005 if ( (pRvlc
->conceal_min
<= pRvlc
->conceal_max
) && pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousScaleFactorOK
&& pRvlc
->sf_concealment
1006 && (pAacDecoderStaticChannelInfo
->concealmentInfo
.rvlcPreviousBlockType
== currentBlockType
) && ConcealStatus
)
1008 PredictiveInterpolation(pAacDecoderChannelInfo
, pAacDecoderStaticChannelInfo
);
1010 #if VERBOSE_RVLC_OUTPUT
1011 FDKstrcpy(Strategy
,"Yes (PredictiveInterpolation)");
1015 /* Call frame concealment, because no better strategy was found. Setting the scalefactors to zero is done for debugging
1017 if (ConcealStatus
) {
1018 for (group
=0; group
< pRvlc
->numWindowGroups
; group
++) {
1019 for (band
=0; band
<pRvlc
->maxSfbTransmitted
; band
++) {
1020 pAacDecoderChannelInfo
->pDynData
->aScaleFactor
[16*group
+band
] = 0;
1023 pAacDecoderChannelInfo
->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
= 0;
1024 #if VERBOSE_RVLC_OUTPUT
1025 FDKstrcpy(Strategy
,"Yes (FrameConcealment)");
1030 #if VERBOSE_RVLC_OUTPUT
1031 DebugOutputDistortedBitstreams(pRvlc
,pAacDecoderChannelInfo
,ErrorStatusLengthFwd
,ErrorStatusLengthBwd
,
1032 ErrorStatusLengthEscapes
,ErrorStatusFirstScf
,ErrorStatusLastScf
,
1033 ErrorStatusFirstNrg
,ErrorStatusLastNrg
,ErrorStatusFirstIs
,ErrorStatusLastIs
,
1034 ErrorStatusForbiddenCwFwd
,ErrorStatusForbiddenCwBwd
,ErrorStatusNumEscapesFwd
,
1035 ErrorStatusNumEscapesBwd
,conceal_max
,conceal_min
,Strategy
);
1040 /*---------------------------------------------------------------------------------------------
1041 function: CRvlc_Read
1043 description: Read RVLC ESC1 data (side info) from bitstream.
1044 -----------------------------------------------------------------------------------------------
1045 input: - pointer rvlc structure
1046 - pointer channel info structure
1047 - pointer bitstream structure
1048 -----------------------------------------------------------------------------------------------
1050 -------------------------------------------------------------------------------------------- */
1053 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
1054 HANDLE_FDK_BITSTREAM bs
)
1056 CErRvlcInfo
*pRvlc
= &pAacDecoderChannelInfo
->pComData
->overlay
.aac
.erRvlcInfo
;
1060 /* RVLC long specific initialization Init part 1 of 2 */
1061 pRvlc
->numWindowGroups
= GetWindowGroups(&pAacDecoderChannelInfo
->icsInfo
);
1062 pRvlc
->maxSfbTransmitted
= GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo
->icsInfo
);
1063 pRvlc
->noise_used
= 0; /* noise detection */
1064 pRvlc
->dpcm_noise_nrg
= 0; /* only for debugging */
1065 pRvlc
->dpcm_noise_last_position
= 0; /* only for debugging */
1066 pRvlc
->length_of_rvlc_escapes
= -1; /* default value is used for error detection and concealment */
1068 /* read only error sensitivity class 1 data (ESC 1 - data) */
1069 pRvlc
->sf_concealment
= FDKreadBits(bs
,1); /* #1 */
1070 pRvlc
->rev_global_gain
= FDKreadBits(bs
,8); /* #2 */
1072 if (GetWindowSequence(&pAacDecoderChannelInfo
->icsInfo
) == EightShortSequence
) {
1073 pRvlc
->length_of_rvlc_sf
= FDKreadBits(bs
,11); /* #3 */
1076 pRvlc
->length_of_rvlc_sf
= FDKreadBits(bs
,9); /* #3 */
1079 /* check if noise codebook is used */
1080 for (group
= 0; group
< pRvlc
->numWindowGroups
; group
++) {
1081 for (band
=0; band
< pRvlc
->maxSfbTransmitted
; band
++) {
1082 if (pAacDecoderChannelInfo
->pDynData
->aCodeBook
[16*group
+band
] == NOISE_HCB
) {
1083 pRvlc
->noise_used
= 1;
1089 if (pRvlc
->noise_used
)
1090 pRvlc
->dpcm_noise_nrg
= FDKreadBits(bs
, 9); /* #4 PNS */
1092 pRvlc
->sf_escapes_present
= FDKreadBits(bs
, 1); /* #5 */
1094 if ( pRvlc
->sf_escapes_present
) {
1095 pRvlc
->length_of_rvlc_escapes
= FDKreadBits(bs
, 8); /* #6 */
1098 if (pRvlc
->noise_used
) {
1099 pRvlc
->dpcm_noise_last_position
= FDKreadBits(bs
, 9); /* #7 PNS */
1100 pRvlc
->length_of_rvlc_sf
-= 9;
1103 pRvlc
->length_of_rvlc_sf_fwd
= pRvlc
->length_of_rvlc_sf
;
1104 pRvlc
->length_of_rvlc_sf_bwd
= pRvlc
->length_of_rvlc_sf
;
1108 /*---------------------------------------------------------------------------------------------
1109 function: CRvlc_Decode
1111 description: Decode rvlc data
1112 The function reads both the escape sequences and the scalefactors in forward
1113 and backward direction. If an error occured during decoding process which can
1114 not be concealed with the rvlc concealment frame concealment will be initiated.
1115 Then the element "rvlcCurrentScaleFactorOK" in the decoder channel info is set
1116 to 0 otherwise it is set to 1.
1117 -----------------------------------------------------------------------------------------------
1118 input: - pointer rvlc structure
1119 - pointer channel info structure
1120 - pointer to persistent channel info structure
1121 - pointer bitstream structure
1122 -----------------------------------------------------------------------------------------------
1123 return: ErrorStatus = AAC_DEC_OK
1124 -------------------------------------------------------------------------------------------- */
1127 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
,
1128 CAacDecoderStaticChannelInfo
*pAacDecoderStaticChannelInfo
,
1129 HANDLE_FDK_BITSTREAM bs
1132 CErRvlcInfo
*pRvlc
= &pAacDecoderChannelInfo
->pComData
->overlay
.aac
.erRvlcInfo
;
1136 rvlcInit(pRvlc
,pAacDecoderChannelInfo
,bs
);
1138 /* save bitstream position */
1139 saveBitCnt
= FDKgetBitCnt(bs
);
1141 #if RVLC_ADVANCED_BITSTREAM_ERROR_GENERATOR_SF
1142 GenerateSingleBitError(pRvlc
,
1143 &(pRvlc
->bitstreamIndexRvlFwd
),
1144 pRvlc
->length_of_rvlc_sf
,
1148 #if RVLC_ADVANCED_BITSTREAM_ERROR_GENERATOR_ESC
1149 if (pRvlc
->sf_escapes_present
)
1150 GenerateSingleBitError(pRvlc
,
1151 &(pRvlc
->bitstreamIndexEsc
),
1152 pRvlc
->length_of_rvlc_escapes
,
1156 if ( pRvlc
->sf_escapes_present
)
1157 rvlcDecodeEscapes(pRvlc
, pAacDecoderChannelInfo
->pComData
->overlay
.aac
.aRvlcScfEsc
, bs
);
1159 rvlcDecodeForward(pRvlc
,pAacDecoderChannelInfo
, bs
);
1160 rvlcDecodeBackward(pRvlc
,pAacDecoderChannelInfo
, bs
);
1161 rvlcFinalErrorDetection(pAacDecoderChannelInfo
, pAacDecoderStaticChannelInfo
);
1163 pAacDecoderChannelInfo
->pDynData
->specificTo
.aac
.rvlcIntensityUsed
= pRvlc
->intensity_used
;
1164 pAacDecoderChannelInfo
->data
.aac
.PnsData
.PnsActive
= pRvlc
->noise_used
;
1166 /* restore bitstream position */
1167 bitCntOffst
= saveBitCnt
- FDKgetBitCnt(bs
);
1169 FDKpushBiDirectional(bs
, bitCntOffst
);
1173 void CRvlc_ElementCheck (
1174 CAacDecoderChannelInfo
*pAacDecoderChannelInfo
[],
1175 CAacDecoderStaticChannelInfo
*pAacDecoderStaticChannelInfo
[],
1177 const INT elChannels
1182 /* Required for MPS residuals. */
1183 if (pAacDecoderStaticChannelInfo
== NULL
) {
1187 /* RVLC specific sanity checks */
1188 if ( (flags
& AC_ER_RVLC
) && (elChannels
== 2)) { /* to be reviewed */
1189 if ( ( (pAacDecoderChannelInfo
[0]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
== 0) ||
1190 (pAacDecoderChannelInfo
[1]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
== 0) )
1191 && pAacDecoderChannelInfo
[0]->pComData
->jointStereoData
.MsMaskPresent
) {
1192 pAacDecoderChannelInfo
[0]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
= 0;
1193 pAacDecoderChannelInfo
[1]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
= 0;
1196 if ( (pAacDecoderChannelInfo
[0]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
== 0)
1197 && (pAacDecoderChannelInfo
[1]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
== 1)
1198 && (pAacDecoderChannelInfo
[1]->pDynData
->specificTo
.aac
.rvlcIntensityUsed
== 1) ){
1199 pAacDecoderChannelInfo
[1]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
= 0;
1203 for (ch
= 0; ch
< elChannels
; ch
++)
1205 pAacDecoderStaticChannelInfo
[ch
]->concealmentInfo
.rvlcPreviousBlockType
= (GetWindowSequence(&pAacDecoderChannelInfo
[ch
]->icsInfo
) == EightShortSequence
) ? 0 : 1;
1206 if (flags
& AC_ER_RVLC
) {
1207 pAacDecoderStaticChannelInfo
[ch
]->concealmentInfo
.rvlcPreviousScaleFactorOK
= pAacDecoderChannelInfo
[ch
]->pDynData
->specificTo
.aac
.rvlcCurrentScaleFactorOK
;
1210 pAacDecoderStaticChannelInfo
[ch
]->concealmentInfo
.rvlcPreviousScaleFactorOK
= 0;